結果

問題 No.2124 Guess the Permutation
ユーザー kokatsukokatsu
提出日時 2022-11-18 21:29:41
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 496 bytes
コンパイル時間 2,198 ms
コンパイル使用メモリ 206,764 KB
実行使用メモリ 24,252 KB
平均クエリ数 374.60
最終ジャッジ日時 2023-09-04 18:57:09
合計ジャッジ時間 4,827 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
23,628 KB
testcase_01 AC 25 ms
23,400 KB
testcase_02 AC 25 ms
24,252 KB
testcase_03 AC 25 ms
23,880 KB
testcase_04 AC 26 ms
23,988 KB
testcase_05 AC 28 ms
23,880 KB
testcase_06 AC 43 ms
23,652 KB
testcase_07 AC 57 ms
23,676 KB
testcase_08 AC 57 ms
24,036 KB
testcase_09 AC 57 ms
23,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    int N;
    readf("%d\n", N);

    auto res = new int[](N);

    int ttl= N * (N + 1) / 2, rem = ttl;
    foreach (i; 0 .. N-2) {
        writefln("? %d %d", i+2, N);
        stdout.flush;

        int S;
        readf("%d\n", S);

        res[i] = rem - S;
        rem -= res[i];
    }

    writefln("? %d %d", 1, N-1);
    stdout.flush;

    int S;
    readf("%d\n", S);

    res[N-2] = S - res.sum;
    res[N-1] = ttl - res.sum;

    writefln("! %(%s %)", res);
}
0