結果

問題 No.1717 Levi-Civita Triangle
ユーザー zkouzkou
提出日時 2021-08-04 21:55:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,187 bytes
コンパイル時間 2,641 ms
コンパイル使用メモリ 192,956 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-24 11:25:54
合計ジャッジ時間 11,906 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,076 KB
testcase_01 AC 3 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 33 ms
4,348 KB
testcase_06 AC 418 ms
4,348 KB
testcase_07 TLE -
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 41 ms
4,348 KB
testcase_11 AC 379 ms
4,348 KB
testcase_12 AC 1,532 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 4 ms
4,348 KB
testcase_15 AC 25 ms
4,348 KB
testcase_16 AC 309 ms
4,348 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// 高速化愚直解 想定 TLE 

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int main(){
    int N;
    scanf("%d", &N);

    bitset<200010> bit_0, bit_1, bit_2;
    
    int a;
    for (int i = 0; i < 2 * N + 1; i++) {
        scanf("%d", &a);
        // cout << a << endl;
        if (a == 0) {
            bit_0.set(i);
        } else if (a == 1) {
            bit_1.set(i);
        } else {
            bit_2.set(i);
        }
    }

    // cout << -1 << " 0 " << bit_0.any() << endl;
    // cout << -1 << " 1 " << bit_1.any() << endl;
    // cout << -1 << " 2 " << bit_2.any() << endl;

    for (int i = 0; i < N; i++) {
        bitset<200010> new_bit_0, new_bit_1, new_bit_2;
        bitset<200010> bit_01 = bit_0 & (bit_1 >> 1);
        new_bit_1 |= bit_01 & (bit_2 >> 2);
        new_bit_1 |= bit_1 & (bit_2 >> 1) & (bit_0 >> 2);
        new_bit_1 |= bit_2 & (bit_01 >> 1);
        bitset<200010> bit_10 = bit_1 & (bit_0 >> 1);
        new_bit_2 |= bit_0 & (bit_2 >> 1) & (bit_1 >> 2);
        new_bit_2 |= bit_2 & (bit_10 >> 1);
        new_bit_2 |= bit_10 & (bit_2 >> 2);
        bit_1 = new_bit_1;
        bit_2 = new_bit_2;
        bit_0 = (bit_1 ^ bit_2).flip();
        // cout << i << " 0 " << bit_0.any() << endl;
        // cout << i << " 1 " << bit_1.any() << endl;
        // cout << i << " 2 " << bit_2.any() << endl;
    }

    if (bit_1.any()) putchar('1');
    else if (bit_2.any()) putchar('2');
    else putchar('0');
    
    
    return 0;
}

// for i in range(N):
//     l = 2 * (N - i) - 1
//     bit_10 = bit_1 & (bit_0 >> 1)
//     new_bit_1 = 0
//     new_bit_1 |= bit_0 & (bit_2 >> 1) & (bit_1 >> 2)
//     new_bit_1 |= bit_2 & (bit_10 >> 1)
//     new_bit_1 |= bit_10 & (bit_2 >> 2)
//     bit_01 = bit_0 & (bit_1 >> 1)
//     new_bit_2 = 0
//     new_bit_2 |= bit_01 & (bit_2 >> 2)
//     new_bit_2 |= bit_1 & (bit_2 >> 1) & (bit_0 >> 2)
//     new_bit_2 |= bit_2 & (bit_01 >> 1)
//     bit_1 = new_bit_1
//     bit_2 = new_bit_2
//     bit_0 = (-1) ^ bit_1 ^ bit_2

// if bit_1:
//     print(1)
// elif bit_2:
//     print(2)
// else:
//     print(0)
0