Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 54fcd03

Browse files
committed
ABC181-C, D
1 parent eceeb52 commit 54fcd03

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

‎abc/README.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,3 +427,14 @@
427427
* [ ] D - Friends
428428
* [x] E - Coprime
429429
* [ ] F - I hate Shortest Path Problem
430+
431+
## AtCoder Beginner Contest 181
432+
433+
<https://atcoder.jp/contests/abc181>
434+
435+
* [ ] A - Heavy Rotation
436+
* [ ] B - Trapezoid Sum
437+
* [x] C - Collinearity
438+
* [x] D - Hachi
439+
* [ ] E - Transformable Teacher
440+
* [ ] F - Silver Woods

‎abc/abc181-c/Main.hs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- https://github.com/minoki/my-atcoder-solutions
2+
{-# LANGUAGE TypeApplications #-}
3+
import Data.Char (isSpace)
4+
import Data.List
5+
import Control.Monad
6+
import qualified Data.ByteString.Char8 as BS
7+
8+
det2 a b c d = a * d - b * c
9+
10+
main = do
11+
n <- readLn @Int
12+
points <- replicateM n $ do
13+
[x,y] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
14+
return (x,y)
15+
let result = or [ det2 (x1-x0) (y1-y0) (x2-x0) (y2-y0) == 0 | (x0,y0):ps <- tails points, (x1,y1):ps' <- tails ps, (x2,y2) <- ps' ]
16+
putStrLn $ if result then "Yes" else "No"

‎abc/abc181-d/Main.hs‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
-- https://github.com/minoki/my-atcoder-solutions
2+
{-# LANGUAGE TypeApplications #-}
3+
import Data.List
4+
import qualified Data.ByteString.Char8 as BS
5+
6+
shortCase :: String -> Bool
7+
shortCase xs = or $ do
8+
ys <- permutations xs
9+
return (read @Int ys `rem` 8 == 0)
10+
11+
multiplesOf8 :: [[(Char, Int)]]
12+
multiplesOf8 = [ if c0 == c2 then
13+
[(c0,3)]
14+
else if c0 == c1 then
15+
[(c0,2),(c2,1)]
16+
else if c1 == c2 then
17+
[(c0,1),(c1,2)]
18+
else
19+
[(c0,1),(c1,1),(c2,1)]
20+
| n <- [13 .. 124]
21+
, let [c0,c1,c2] = sort $ show (8 * n)
22+
]
23+
24+
longCase :: BS.ByteString -> Bool
25+
longCase s = or $ do
26+
m <- multiplesOf8
27+
return $ all (\(c,n) -> BS.count c s >= n) m
28+
29+
main = do
30+
s <- BS.getLine
31+
let result = if BS.length s <= 2 then
32+
shortCase (BS.unpack s)
33+
else
34+
longCase s
35+
putStrLn $ if result then "Yes" else "No"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /