結果

問題 No.239 にゃんぱすー
コンテスト
ユーザー バカらっく
提出日時 2018-03-01 14:26:28
言語 Swift
(6.2.4)
コンパイル:
swiftc _filename_ -Ounchecked -o a.out
実行:
./a.out
結果
WA  
実行時間 -
コード長 591 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 967 ms
コンパイル使用メモリ 145,196 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2026-05-24 03:27:00
合計ジャッジ時間 2,350 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 16 WA * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.swift:5:5: warning: immutable value 'i' was never used; consider replacing with '_' or removing it [#no-usage]
 3 | var map = [[String]]()
 4 | 
 5 | for i in 0..<murabito {
   |     `- warning: immutable value 'i' was never used; consider replacing with '_' or removing it [#no-usage]
 6 |         map.append(readLine()!.split(separator:" ").map(String.init))
 7 | }

Main.swift:33:11: warning: expression implicitly coerced from 'Int?' to 'Any'
31 |     print(-1)
32 | } else {
33 |     print(ans)
   |           |- warning: expression implicitly coerced from 'Int?' to 'Any'
   |           |- note: provide a default value to avoid this warning
   |           |- note: force-unwrap the value to avoid this warning
   |           `- note: explicitly cast to 'Any' with 'as Any' to silence this warning
34 | }

ソースコード

diff #
raw source code

let murabito = Int(readLine()!)!

var map = [[String]]()

for i in 0..<murabito {
        map.append(readLine()!.split(separator:" ").map(String.init))
}

var ans:Int? = nil
for i in 0..<murabito {
    var isNyan = true
    for j in 0..<murabito {
        if(map[j][i]=="nyanpass" || map[j][i] == "-") {
            
        } else {
            isNyan = false
            break
        }
    }
    if(isNyan) {
        if(ans == nil) {
            ans = i+1
        } else {
            ans = nil
            break
        }
    }
}

if(ans == nil) {
    print(-1)
} else {
    print(ans)
}
0