結果

問題 No.1717 Levi-Civita Triangle
ユーザー chocoruskchocorusk
提出日時 2021-10-22 21:47:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 2,063 bytes
コンパイル時間 3,281 ms
コンパイル使用メモリ 192,816 KB
実行使用メモリ 4,432 KB
最終ジャッジ日時 2023-10-24 12:51:03
合計ジャッジ時間 5,371 ms
ジャッジサーバーID
(参考情報)
judge13 / 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 5 ms
4,348 KB
testcase_07 AC 20 ms
4,348 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 12 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 26 ms
4,348 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 4 ms
4,348 KB
testcase_22 AC 19 ms
4,348 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 3 ms
4,348 KB
testcase_27 AC 9 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 3 ms
4,348 KB
testcase_32 AC 27 ms
4,348 KB
testcase_33 AC 33 ms
4,432 KB
testcase_34 AC 33 ms
4,432 KB
testcase_35 AC 33 ms
4,432 KB
testcase_36 AC 32 ms
4,432 KB
testcase_37 AC 33 ms
4,432 KB
testcase_38 AC 33 ms
4,432 KB
testcase_39 AC 33 ms
4,432 KB
testcase_40 AC 34 ms
4,432 KB
testcase_41 AC 33 ms
4,432 KB
testcase_42 AC 32 ms
4,432 KB
testcase_43 AC 32 ms
4,432 KB
testcase_44 AC 33 ms
4,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n; cin>>n;
    int a[200020];
    for(int i=0; i<2*n+1; i++) cin>>a[i];
    int a1[2][4]={{0,2,1,2},{0,1,2,1}};
    bool b1=1, b2=1;
    for(int i=1; i<2*n+1; i++){
        int x=(a[i]-a[0]+3)%3;
        if(x!=a1[n%2][i%4]){
            b1=0;
        }
        if(x!=a1[(n%2)^1][i%4]){
            b2=0;
        }
    }
    if(b1)cout<<1<<endl;
    else if(b2)cout<<2<<endl;
    else cout<<0<<endl;
    return 0;
    set<vector<int>> st;
    auto dfs=[&](auto dfs, vector<int> &v)->void{
        if(v.size()==2*n+1){
            auto w=v;
            for(int i=0; i<n; i++){
                vector<int> w1;
                for(int j=1; j<(int)w.size()-1; j++){
                    if((w[j]-w[j-1]+3)%3==1 && (w[j+1]-w[j]+3)%3==1){
                        w1.push_back(1);
                    }else if((w[j]-w[j-1]+3)%3==2 && (w[j+1]-w[j]+3)%3==2){
                        w1.push_back(2);
                    }else{
                        w1.push_back(0);
                    }
                }
                swap(w, w1);
            }
            if(w[0]==2){
                for(int i=0; i<2*n+1; i++) cout<<v[i]<<" ";
                cout<<endl;
                st.insert(v);
            }
            return;
        }
        for(int i=0; i<3; i++){
            v.push_back(i);
            dfs(dfs, v);
            v.pop_back();
        }
    };
    vector<int> v0;
    dfs(dfs, v0);
    cout<<st.size()<<endl;
    

    return 0;
}
0