結果

問題 No.1109 調の判定
ユーザー snrnsidy
提出日時 2021-06-14 02:33:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 2,038 ms
コンパイル使用メモリ 195,964 KB
最終ジャッジ日時 2025-01-22 08:08:28
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	vector <int> add = { 0,2,4,5,7,9,11 };
	vector <int> v;
	int n, t;
	int cnt = 0;
	int res = -1;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> t;
		v.push_back(t);
	}

	for (int i = 0;i<12;i++)
	{
		bool check[12];
		memset(check, false, sizeof(check));
		for (int j = 0; j < add.size(); j++)
		{
			int val = add[j] + i;
			val %= 12;
			check[val] = true;
		}
		bool ok = true;
		for (int j = 0; j < n; j++)
		{
			if (check[v[j]] == false)
			{
				ok = false;
				break;
			}
		}
		if (ok)
		{
			cnt++;
			res = i;
		}
	}

	if (cnt > 1) res = -1;
	cout << res << '\n';
	return 0;
}
0