結果
問題 | No.1109 調の判定 |
ユーザー |
|
提出日時 | 2020-07-10 21:33:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,185 bytes |
コンパイル時間 | 1,030 ms |
コンパイル使用メモリ | 106,280 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 08:03:23 |
合計ジャッジ時間 | 2,254 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<iomanip> #include<math.h> #include<complex> #include<queue> #include<deque> #include<stack> #include<map> #include<set> #include<bitset> #include<functional> #include<assert.h> #include<numeric> using namespace std; typedef pair<int,int> P; typedef long long ll; typedef long double ld; const int inf=1e9+7; const ll longinf=1LL<<60; #define REP(i,m,n) for(ll i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) #define F first #define S second constexpr char ln = '\n'; const int mx=200010; const ll mod=1e9+7; int main(){ int n; cin >> n; vector<int> a(n); rep(i,n){ cin >> a[i]; } vector<int> ans; rep(i,12){ set<int> st; st.insert(i%12); st.insert((i+2)%12); st.insert((i+4)%12); st.insert((i+5)%12); st.insert((i+7)%12); st.insert((i+9)%12); st.insert((i+11)%12); bool flag = true; rep(j,n){ if(st.find(a[j])==st.end()){ flag = false; break; } } if(flag){ ans.emplace_back(i); } } if(ans.size()==1){ cout << ans[0] << ln; } else { cout << -1 << ln; } return 0; }