結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  vector<int> ret;
  rep(D,12){
    map<int,bool> ok;
    ok[D%12] = true;
    ok[(D+2)%12] = true;
    ok[(D+4)%12] = true;
    ok[(D+5)%12] = true;
    ok[(D+7)%12] = true;
    ok[(D+9)%12] = true;
    ok[(D+11)%12] = true;

    bool ck = true;
    rep(j,v.size()){
      if(ok.count(v[j]%12) == 0) ck = false;
    }
    if(ck) ret.push_back(D);
  }
  
  if(ret.size() == 1) cout << ret[0] << endl;
  else cout << -1 << endl;
  return 0;
}

0