結果
問題 |
No.239 にゃんぱすー
|
ユーザー |
|
提出日時 | 2025-09-15 02:21:51 |
言語 | Standard ML (MLton 20210117) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 1,274 bytes |
コンパイル時間 | 3,387 ms |
コンパイル使用メモリ | 691,832 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-15 02:22:14 |
合計ジャッジ時間 | 5,250 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
fun readInt () = valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn) fun readStr () = let fun scan reader stream = SOME (StringCvt.splitl (not o Char.isSpace) reader (StringCvt.skipWS reader stream)) in valOf (TextIO.scanStream scan TextIO.stdIn) end fun intString n = if 0 <= n then Int.toString n else "-" ^ Int.toString (abs n) fun tally limit index l = if index = limit then [] else ( (index, List.foldl (fn (arr, acc) => if Array.sub (arr, index) = "nyanpass" then acc + 1 else acc) 0 l ) :: (tally limit (index + 1) l) ) fun findAns n ls = let val withIndex = tally n 0 ls val filtered = List.filter (fn (_, x) => x = n - 1) withIndex in if List.length filtered = 1 then #1 (List.hd filtered) + 1 else ~1 end val () = let val n = readInt () val a_s = List.tabulate (n, fn _ => Array.fromList (List.tabulate (n, fn _ => readStr ()))) val ans = findAns n a_s in print (intString ans ^ "\n") end