1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AtCoder Beginner Contest 392 振り返り

Posted at

ABC392の振り返りです。

結果

ABCの3完でした。今回簡単目だったためか、ratingあまり上がりませんでした

スクリーンショット 2025-02-09 15.23.13.png

スクリーンショット 2025-02-09 15.25.06.png

ふりかえり

A問題

permutations使って全パターン試します

main :: IO ()
main = do
  as <- permutations <$> getInts

  let ans = [b3| [b1, b2, b3] <- as, b1 * b2 == b3 ]
  printYN $ not $ null ans

B問題

[1 .. n]全てに対してnotElem使いましょう

main :: IO ()
main = do
  [n, _] <- getInts
  as <- getInts

  let ans = [show i | i <- [1 .. n], i `notElem` as]
  print $ length ans
  putStrLn $ unwords ans

C問題

ゼッケンと見つめる先をIntMapにして管理します。
見つめる先はVectorとして管理して取得するようにしました。

main :: IO ()
main = do
  n <- readLn @Int
  ps <- getInts
  qs <- getInts

  let qps = zip qs ps
      im = IM.fromList qps
      as = map (\i -> fromJust $ IM.lookup i im) [1 .. n]
      v = VU.fromList qs
      ans = map (\a -> show $ v VU.! (a - 1)) as

  putStrLn $ unwords ans

全体を振り返って

もっとHaskellと仲良くなりたいので引き続き頑張ります!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?