結果

問題 No.1149 色塗りゲーム
ユーザー ぷら
提出日時 2020-08-07 22:26:17
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 2,088 bytes
コンパイル時間 1,625 ms
コンパイル使用メモリ 170,728 KB
実行使用メモリ 25,476 KB
平均クエリ数 3.92
最終ジャッジ日時 2024-07-17 04:51:59
合計ジャッジ時間 7,153 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 WA * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main(){
    int N;
    cin >> N;
    vector<bool>ok(N,true);
    if(N == 1 || N == 2) {
        cout << N << " " << 1 << endl;
        int t;cin >> t;
        return 0;
    }
    cout << (N+1)%2+1 << " " << (N-1)/2+1 << endl;
    for(int i = (N-1)/2; i < (N+1)/2+(N+1)%2; i++) {
        ok[i] = false;
    }
    int cnt = (N-1)/2*2;
    while(true) {
        int t;cin >> t;
        if(t == 0) {
            return 0;
        }
        int k,x;cin >> k >> x;
        for(int i = 0; i < x; i++) {
            ok[k-1+i] = false;
        }
        cnt -= x;
        if(cnt <= 2) {
            cout << "a" << endl;
            for(int i = 0; i < N; i++) {
                if(ok[i]) {
                    cout << cnt << " " << i+1 << endl;
                    break;
                }
            }
            int t;cin >> t;
            return 0;
        }
        int res = 0;
        for(int i = 0; i < N; i++) {
            if(ok[i]) {
                res++;
            }
            else {
                if(res >= 3) {
                    cout << (res+1)%2+1 << " " << (i+i-res)/2+1 << endl;
                    cnt -= (res+1)%2+1;
                    for(int j = (i+i-res)/2; j < (i+i-res)/2+(res+1)%2+1; j++) {
                        ok[j] = false;
                    }
                    goto prime;
                }
                res = 0;
            }
        }
        if(res >= 3) {
            cout << (res+1)%2+1 << " " << (N+N-res)/2+1 << endl;
            cnt -= (res+1)%2+1;
            for(int j = (N+N-res)/2; j < (N+N-res)/2+(res+1)%2+1; j++) {
                ok[j] = false;
            }
            goto prime;
        }
        res = 0;
        for(int i = 0; i < N; i++) {
            if(ok[i]) {
                ok[i] = false;
                cout << 1 << " " << i+1 << endl;
                cnt -= 1;
                break;
            }
        }
    prime:;
    }
}
0