結果
問題 | No.1109 調の判定 |
ユーザー |
![]() |
提出日時 | 2022-11-11 17:20:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 573 bytes |
コンパイル時間 | 1,831 ms |
コンパイル使用メモリ | 174,992 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 12:30:06 |
合計ジャッジ時間 | 3,142 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> t(n); for(int i = 0; i < n; i++) cin >> t[i]; const int d[7] = {0, 2, 4, 5, 7, 9, 11}; int ans = -1; bool check; for(int i = 0; i < 12; i++) { check = true; set<int> st; for(int j = 0; j < 7; j++) st.insert((i + d[j]) % 12); for(int j = 0; j < n; j++) { if(!st.count(t[j])) { check = false; break; } } if(check) { if(ans == -1) ans = i; else { cout << -1 << endl; return 0; } } } cout << ans << endl; return 0; }