結果
| 問題 |
No.1109 調の判定
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-01 06:24:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 899 bytes |
| コンパイル時間 | 813 ms |
| コンパイル使用メモリ | 78,804 KB |
| 最終ジャッジ日時 | 2025-01-12 12:12:29 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 |
ソースコード
#include <iostream>
#include <vector>
constexpr int M = 12;
const std::vector<int> ds{0, 2, 4, 5, 7, 9, 11};
template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
void solve() {
int n;
std::cin >> n;
auto judge = vec(M, vec(M, false));
for (int i = 0; i < M; ++i) {
for (auto d : ds) {
judge[i][(i + d) % M] = true;
}
}
std::vector<bool> result(M, true);
while (n--) {
int x;
std::cin >> x;
for (int i = 0; i < M; ++i) {
if (!judge[i][x]) result[i] = false;
}
}
std::vector<int> ans;
for (int i = 0; i < M; ++i) {
if (result[i]) ans.push_back(i);
}
std::cout << ((int)ans.size() == 1 ? ans.front() : -1) << "\n";
}
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
solve();
return 0;
}