結果

問題 No.1109 調の判定
ユーザー SSRS
提出日時 2020-07-10 21:26:02
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 586 bytes
コンパイル時間 1,699 ms
コンパイル使用メモリ 174,724 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-11 07:39:17
合計ジャッジ時間 2,958 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
vector<int> d = {0, 2, 4, 5, 7, 9, 11};
int main(){
  int N;
  cin >> N;
  vector<int> T(N);
  for (int i = 0; i < N; i++){
    cin >> T[i];
  }
  set<int> ans;
  for (int i = 0; i < 12; i++){
    set<int> st;
    for (int j = 0; j < 7; j++){
      st.insert((i + d[j]) % 12);
    }
    bool ok = true;
    for (int j = 0; j < N; j++){
      if (!st.count(T[j])){
        ok = false;
      }
    }
    if (ok){
      ans.insert(i);
    }
  }
  if (ans.size() != 1){
    cout << -1 << endl;
  } else {
    cout << *ans.begin() << endl;
  }
}
0