結果
| 問題 | No.239 にゃんぱすー |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-15 02:21:51 |
| 言語 | Standard ML (MLton 20241230) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| + 757µs | |
| コード長 | 1,274 bytes |
| 記録 | |
| コンパイル時間 | 5,140 ms |
| コンパイル使用メモリ | 704,488 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-15 02:18:22 |
| 合計ジャッジ時間 | 7,916 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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