結果

問題 No.934 Explosive energy drink
ユーザー potoooooooopotoooooooo
提出日時 2019-11-29 22:04:40
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 311 ms / 2,000 ms
コード長 718 bytes
コンパイル時間 3,162 ms
コンパイル使用メモリ 165,036 KB
実行使用メモリ 24,360 KB
平均クエリ数 709.58
最終ジャッジ日時 2023-09-23 18:30:45
合計ジャッジ時間 7,410 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,964 KB
testcase_01 AC 300 ms
23,952 KB
testcase_02 AC 24 ms
23,964 KB
testcase_03 AC 148 ms
23,796 KB
testcase_04 AC 295 ms
23,796 KB
testcase_05 AC 24 ms
24,360 KB
testcase_06 AC 24 ms
24,324 KB
testcase_07 AC 23 ms
23,616 KB
testcase_08 AC 24 ms
23,676 KB
testcase_09 AC 23 ms
24,024 KB
testcase_10 AC 23 ms
23,340 KB
testcase_11 AC 25 ms
24,000 KB
testcase_12 AC 25 ms
23,340 KB
testcase_13 AC 28 ms
23,388 KB
testcase_14 AC 29 ms
23,472 KB
testcase_15 AC 99 ms
23,376 KB
testcase_16 AC 39 ms
24,312 KB
testcase_17 AC 59 ms
23,640 KB
testcase_18 AC 64 ms
23,640 KB
testcase_19 AC 119 ms
23,376 KB
testcase_20 AC 199 ms
23,388 KB
testcase_21 AC 214 ms
23,544 KB
testcase_22 AC 293 ms
23,964 KB
testcase_23 AC 311 ms
23,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int except_query(int a, int n) {
    cout << "? " << n-1 << "\n";
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (i == a) continue;
        if (count) cout << " ";
        cout << i;
        count++;
    }
    cout << "\n" << flush;
    int ans; cin >> ans;
    return ans;
}

void answer(vector<int> &ans) {
    cout << "! " << ans.size() << "\n";
    for (int i = 0; i < ans.size(); i++) {
        if (i) cout << " ";
        cout << ans[i];
    }
    cout << "\n";
}

int main() {
    int n; cin >> n;
    vector<int> ans;
    for (int i = 1; i <= n; i++) {
        if (!except_query(i, n)) ans.emplace_back(i);
    }
    answer(ans);
    return 0;
}
0