結果

問題 No.1149 色塗りゲーム
ユーザー chocoruskchocorusk
提出日時 2020-08-07 21:41:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,253 bytes
コンパイル時間 1,300 ms
コンパイル使用メモリ 132,064 KB
実行使用メモリ 36,572 KB
平均クエリ数 0.10
最終ジャッジ日時 2023-09-24 04:14:13
合計ジャッジ時間 5,053 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
24,348 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
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 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます

ソースコード

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>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n;
    cin>>n;
    int g[102];
    g[0]=1;
    for(int i=1; i<=n; i++){
        set<int> st;
        for(int j=0; j<=i-1; j++){
            st.insert(g[j]^g[i-1-j]);
        }
        for(int j=0; j<=i-2; j++){
            st.insert(g[j]^g[i-2-j]);
        }
        for(int j=0; ; j++){
            if(st.find(j)==st.end()){
                g[i]=j; break;
            }
        }
    }
    int a[105]={};
    a[n]=1;
    while(1){
        bool ok=0;
        for(int i=0; i<n; i++){
            if(a[i]) continue;
            a[i]=1;
            int s=0, c=0;
            for(int j=0; j<=n; j++){
                if(a[j]){
                    s^=g[c];
                    c=0;
                }else{
                    c++;
                }
            }
            if(s==0){
                ok=1;
                cout<<1<<" "<<i+1<<endl;
                break;
            }
            a[i]=0;
        }
        if(!ok){
            for(int i=0; i<n-1; i++){
                if(a[i] || a[i+1]) continue;
                a[i]=1, a[i+1]=1;
                int s=0, c=0;
                for(int j=0; j<=n; j++){
                    if(a[j]){
                        s^=g[c];
                        c=0;
                    }else{
                        c++;
                    }
                }
                if(s==0){
                    ok=1;
                    cout<<2<<" "<<i+1<<endl;
                    break;
                }
                a[i]=0, a[i+1]=0;
            }
        }
        int t; cin>>t;
        if(t<=2){
            return 0;
        }
        int k, x; cin>>k>>x;
        x--;
        if(k==1) a[x]=1;
        else a[x]=a[x+1]=1;
    }
    return 0;
}
0