結果

問題 No.1109 調の判定
ユーザー oooooba
提出日時 2021-06-07 21:12:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,028 bytes
コンパイル時間 1,755 ms
コンパイル使用メモリ 115,884 KB
最終ジャッジ日時 2025-01-22 04:49:29
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int32_t n;
    cin >> n;
    vector<int32_t> ts(n);
    for (auto &&t : ts) {
        cin >> t;
    }
    vector<int32_t> ans;
    vector<int32_t> dds = {0, 2, 4, 5, 7, 9, 11};
    for (auto d = 0; d < 12; ++d) {
        bool found = true;
        for (auto t : ts) {
            bool matches = false;
            for (auto dd : dds) {
                if ((d + dd) % 12 == t) {
                    matches = true;
                    break;
                }
            }
            if (!matches) {
                found = false;
                break;
            }
        }
        if (found)
            ans.push_back(d);
    }
    cout << (ans.size() == 1 ? ans[0] : -1) << endl;
    return 0;
}
0