結果

問題 No.1109 調の判定
コンテスト
ユーザー Kome_soudou
提出日時 2022-11-11 17:20:36
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 573 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,854 ms
コンパイル使用メモリ 186,608 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-04 05:13:02
合計ジャッジ時間 2,722 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
}
0