結果
問題 | No.1109 調の判定 |
ユーザー |
![]() |
提出日時 | 2020-07-10 21:26:31 |
言語 | Swift (6.0.3) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 916 bytes |
コンパイル時間 | 1,172 ms |
コンパイル使用メモリ | 127,724 KB |
実行使用メモリ | 9,344 KB |
最終ジャッジ日時 | 2024-11-30 19:01:01 |
合計ジャッジ時間 | 3,146 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
struct Scanner { private var stack = [String]() private var index = 0 mutating func peek() -> String { if stack.count == index { stack += readLine()!.split(separator: " ").map{ String($0) } } return stack[index] } mutating func next() -> String { let value = peek() index += 1 return value } mutating func nextInt() -> Int { return Int(next())! } mutating func nextDouble() -> Double { return Double(next())! } } var scanner = Scanner() let N = scanner.nextInt() let T = (0 ..< N).map { _ in scanner.nextInt() } func check(_ k: Int) -> Bool { let list = [0, 2, 4, 5, 7, 9, 11].map { ($0 + k) % 12 } return T.allSatisfy { list.contains($0) } } let candidates = (0 ..< 12).filter(check) if candidates.count == 1 { print(candidates.first!) } else { print("-1") }