結果

問題 No.1149 色塗りゲーム
ユーザー yuji9511yuji9511
提出日時 2020-08-07 22:34:50
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 2,310 bytes
コンパイル時間 2,336 ms
コンパイル使用メモリ 206,472 KB
実行使用メモリ 24,444 KB
平均クエリ数 19.52
最終ジャッジ日時 2023-09-24 04:41:47
合計ジャッジ時間 7,358 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
23,964 KB
testcase_01 AC 33 ms
23,664 KB
testcase_02 AC 34 ms
23,964 KB
testcase_03 AC 33 ms
23,508 KB
testcase_04 AC 36 ms
23,376 KB
testcase_05 AC 32 ms
24,264 KB
testcase_06 AC 34 ms
24,312 KB
testcase_07 AC 34 ms
24,372 KB
testcase_08 AC 34 ms
23,448 KB
testcase_09 AC 33 ms
24,000 KB
testcase_10 AC 35 ms
23,472 KB
testcase_11 AC 36 ms
23,988 KB
testcase_12 AC 34 ms
24,324 KB
testcase_13 AC 33 ms
23,388 KB
testcase_14 AC 39 ms
24,060 KB
testcase_15 AC 36 ms
23,496 KB
testcase_16 AC 35 ms
24,276 KB
testcase_17 AC 35 ms
24,000 KB
testcase_18 AC 39 ms
23,496 KB
testcase_19 AC 35 ms
23,496 KB
testcase_20 AC 36 ms
23,784 KB
testcase_21 AC 37 ms
23,484 KB
testcase_22 AC 37 ms
23,376 KB
testcase_23 AC 38 ms
23,388 KB
testcase_24 AC 38 ms
23,448 KB
testcase_25 AC 37 ms
24,192 KB
testcase_26 AC 36 ms
24,192 KB
testcase_27 AC 38 ms
23,340 KB
testcase_28 AC 40 ms
23,340 KB
testcase_29 AC 40 ms
23,676 KB
testcase_30 AC 71 ms
24,072 KB
testcase_31 AC 69 ms
24,444 KB
testcase_32 AC 67 ms
23,652 KB
testcase_33 AC 73 ms
23,796 KB
testcase_34 AC 75 ms
23,448 KB
testcase_35 AC 70 ms
24,060 KB
testcase_36 AC 77 ms
24,072 KB
testcase_37 AC 80 ms
23,868 KB
testcase_38 AC 77 ms
23,580 KB
testcase_39 AC 82 ms
23,568 KB
testcase_40 AC 82 ms
23,460 KB
testcase_41 AC 80 ms
23,604 KB
testcase_42 AC 82 ms
23,616 KB
testcase_43 AC 82 ms
23,988 KB
testcase_44 AC 91 ms
24,060 KB
testcase_45 AC 87 ms
23,880 KB
testcase_46 AC 90 ms
23,664 KB
testcase_47 AC 92 ms
23,568 KB
testcase_48 AC 89 ms
23,580 KB
testcase_49 AC 99 ms
24,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    ll N;
    cin >> N;
    ll state[110] = {};
    state[N] = 1;
    while(true){
        ll K = -1,X = -1;
        bool end = false;
        // printa(state,N);
        rep(i,0,N){
            rep(k,1,3){
                if(state[i] == 1) continue;
                if(k == 2 && state[i+1] == 1) continue;
                rep(j,i,i+k){
                    state[j] = 1;
                }
                ll num = 0;
                map<ll,ll> mp;
                rep(j,0,N+1){
                    if(state[j] == 0){
                        num++;
                    }else{
                        if(num > 0){
                            mp[num]++;
                            num = 0;
                        }
                    }
                }
                rep(j,i,i+k){
                    state[j] = 0;
                }
                bool ok = true;
                for(auto &e: mp){
                    if(e.second % 2 == 1) ok = false;
                }
                if(ok){
                    end = true;
                    // print("ok",k,i);
                    K = k;
                    X = i;
                    break;
                }
            }
            if(end) break;
        }
        if(K == -1 || X == -1){
            exit(1);
        }
        rep(i,X,X+K){
            state[i] = 1;
        }

        cout << K << " " << X+1 << endl;
        ll t;
        cin >> t;
        if(t == 0 || t == 2){
            return;
        }else if(t == 1){
            // exit(1);
        }else{
            ll k,x;
            cin >> k >> x;
            if(k == 1){
                state[x-1] = 1;
            }else{
                state[x-1] = 1;
                state[x] = 1;
            }

        }
        
    }
    

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}
0