結果

問題 No.1149 色塗りゲーム
コンテスト
ユーザー Mister
提出日時 2020-08-07 21:54:48
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 729 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 731 ms
コンパイル使用メモリ 87,788 KB
実行使用メモリ 30,180 KB
平均クエリ数 19.82
最終ジャッジ日時 2026-06-12 02:51:17
合計ジャッジ時間 6,124 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>

void query(int k, int x) {
    std::cout << k << " " << x << std::endl;
}

std::pair<int, int> get() {
    int t;
    std::cin >> t;
    if (t <= 1) std::exit(0);

    int k, x;
    std::cin >> k >> x;
    if (t == 2) std::exit(0);

    return std::make_pair(k, x);
}

void solve() {
    int n;
    std::cin >> n;

    if (n % 2 == 0) {
        query(2, n / 2);
    } else {
        query(1, (n + 1) / 2);
    }

    while (true) {
        auto [k, x] = get();
        if (k == 1) {
            query(1, n - x + 1);
        } else {
            query(2, n - x);
        }
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0