結果

問題 No.1717 Levi-Civita Triangle
ユーザー ぷらぷら
提出日時 2021-10-22 22:49:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 1,235 bytes
コンパイル時間 2,269 ms
コンパイル使用メモリ 210,484 KB
実行使用メモリ 5,168 KB
最終ジャッジ日時 2023-10-24 14:14:57
合計ジャッジ時間 4,098 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 6 ms
4,348 KB
testcase_07 AC 27 ms
4,456 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 3 ms
4,348 KB
testcase_11 AC 5 ms
4,348 KB
testcase_12 AC 16 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 4 ms
4,348 KB
testcase_17 AC 33 ms
4,980 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 5 ms
4,348 KB
testcase_22 AC 24 ms
4,436 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 11 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 4 ms
4,348 KB
testcase_32 AC 34 ms
5,020 KB
testcase_33 AC 43 ms
5,168 KB
testcase_34 AC 42 ms
5,168 KB
testcase_35 AC 41 ms
5,168 KB
testcase_36 AC 41 ms
5,168 KB
testcase_37 AC 42 ms
5,168 KB
testcase_38 AC 42 ms
5,168 KB
testcase_39 AC 43 ms
5,168 KB
testcase_40 AC 43 ms
5,168 KB
testcase_41 AC 42 ms
5,168 KB
testcase_42 AC 41 ms
5,168 KB
testcase_43 AC 42 ms
5,168 KB
testcase_44 AC 42 ms
5,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int>A(2*N+1);
    for(int i = 0; i <= 2*N; i++) {
        cin >> A[i];
    }
    vector<int>B;
    vector<vector<int>>base1 = {{0,1,2},{1,2,0},{2,0,1}};
    vector<vector<int>>base2 = {{2,1,0},{1,0,2},{0,2,1}};
    for(int i = 0; i+2 <= 2*N; i++) {
        vector<int>C = {A[i],A[i+1],A[i+2]};
        if(C == base1[0] || C == base1[1] || C == base1[2]) {
            B.push_back(1);
        }
        else if(C == base2[0] || C == base2[1] || C == base2[2]) {
            B.push_back(2);
        }
        else {
            B.push_back(0);
        }
    }
    A = B;
    int f = A[0] != 0;
    for(int i = 1; i < A.size(); i += 2) {
        if(A[i] != 0) {
            f = 0;
        }
    }
    if(f == 0) {
        cout << 0 << endl;
    }
    else {
        for(int i = 2; i < A.size(); i += 2) {
            if(A[i] == 0 || A[i-2] == A[i]) {
                f = 0;
            }
        }
        if(f == 0) {
            cout << 0 << endl;
        }
        else {
            if(N%2 != A[0]%2) {
                cout << 2 << endl;
            }
            else {
                cout << 1 << endl;
            }
        }
    }
}
0