結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
  #define _GLIBCXX_DEBUG
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> ans(0);
  rep(x, 12) {
    set<int> s;
    s.insert(x), s.insert((x + 2) % 12), s.insert((x + 4) % 12), s.insert((x + 5) % 12), s.insert((x + 7) % 12), s.insert((x + 9) % 12), s.insert((x + 11) % 12);
    bool ok = true;
    rep(i, n) {
      if (!s.contains(a[i])) ok = false;
    }
    if (ok) ans.push_back(x);
  }
  if (ans.size() == 1) {
    cout << ans[0] << endl;
  }
  else {
    cout << -1 << endl;
  }
  return 0;
}
0