結果

問題 No.1149 色塗りゲーム
ユーザー chocoruskchocorusk
提出日時 2020-08-07 21:42:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 2,253 bytes
コンパイル時間 1,427 ms
コンパイル使用メモリ 133,352 KB
実行使用メモリ 24,384 KB
平均クエリ数 20.92
最終ジャッジ日時 2023-09-24 04:14:29
合計ジャッジ時間 7,505 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
23,328 KB
testcase_01 AC 41 ms
23,976 KB
testcase_02 AC 42 ms
24,024 KB
testcase_03 AC 42 ms
23,676 KB
testcase_04 AC 42 ms
23,796 KB
testcase_05 AC 42 ms
23,964 KB
testcase_06 AC 42 ms
24,228 KB
testcase_07 AC 42 ms
23,844 KB
testcase_08 AC 42 ms
23,544 KB
testcase_09 AC 41 ms
24,360 KB
testcase_10 AC 43 ms
23,508 KB
testcase_11 AC 43 ms
24,024 KB
testcase_12 AC 43 ms
23,340 KB
testcase_13 AC 44 ms
24,216 KB
testcase_14 AC 44 ms
23,376 KB
testcase_15 AC 44 ms
23,412 KB
testcase_16 AC 43 ms
23,592 KB
testcase_17 AC 45 ms
23,976 KB
testcase_18 AC 45 ms
23,376 KB
testcase_19 AC 45 ms
23,340 KB
testcase_20 AC 46 ms
23,412 KB
testcase_21 AC 45 ms
23,580 KB
testcase_22 AC 45 ms
23,832 KB
testcase_23 AC 45 ms
23,388 KB
testcase_24 AC 46 ms
23,484 KB
testcase_25 AC 47 ms
23,352 KB
testcase_26 AC 47 ms
23,412 KB
testcase_27 AC 48 ms
23,412 KB
testcase_28 AC 47 ms
24,000 KB
testcase_29 AC 48 ms
23,340 KB
testcase_30 AC 88 ms
24,252 KB
testcase_31 AC 85 ms
23,388 KB
testcase_32 AC 89 ms
23,496 KB
testcase_33 AC 90 ms
24,240 KB
testcase_34 AC 93 ms
23,604 KB
testcase_35 AC 92 ms
23,544 KB
testcase_36 AC 96 ms
23,412 KB
testcase_37 AC 98 ms
23,796 KB
testcase_38 AC 93 ms
24,048 KB
testcase_39 AC 102 ms
23,784 KB
testcase_40 AC 100 ms
23,652 KB
testcase_41 AC 103 ms
23,328 KB
testcase_42 AC 110 ms
23,400 KB
testcase_43 AC 108 ms
23,664 KB
testcase_44 AC 110 ms
23,784 KB
testcase_45 AC 108 ms
23,508 KB
testcase_46 AC 112 ms
24,384 KB
testcase_47 AC 113 ms
23,376 KB
testcase_48 AC 116 ms
24,240 KB
testcase_49 AC 116 ms
24,036 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>
#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]=0;
    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