結果

問題 No.282 おもりと天秤(2)
ユーザー eve__fuyukieve__fuyuki
提出日時 2018-03-16 21:51:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,735 ms / 5,000 ms
コード長 1,192 bytes
コンパイル時間 1,242 ms
コンパイル使用メモリ 53,340 KB
実行使用メモリ 24,396 KB
平均クエリ数 212.58
最終ジャッジ日時 2023-09-24 01:43:57
合計ジャッジ時間 16,852 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,388 KB
testcase_01 AC 27 ms
23,424 KB
testcase_02 AC 26 ms
23,688 KB
testcase_03 AC 24 ms
24,300 KB
testcase_04 AC 25 ms
24,024 KB
testcase_05 AC 27 ms
23,652 KB
testcase_06 AC 28 ms
24,060 KB
testcase_07 AC 24 ms
23,376 KB
testcase_08 AC 27 ms
23,652 KB
testcase_09 AC 21 ms
23,436 KB
testcase_10 AC 405 ms
23,664 KB
testcase_11 AC 1,489 ms
23,628 KB
testcase_12 AC 477 ms
23,364 KB
testcase_13 AC 728 ms
23,640 KB
testcase_14 AC 1,243 ms
23,652 KB
testcase_15 AC 1,510 ms
23,976 KB
testcase_16 AC 89 ms
24,000 KB
testcase_17 AC 646 ms
24,204 KB
testcase_18 AC 1,041 ms
24,288 KB
testcase_19 AC 1,130 ms
23,520 KB
testcase_20 AC 1,624 ms
23,616 KB
testcase_21 AC 1,733 ms
24,396 KB
testcase_22 AC 1,735 ms
23,664 KB
testcase_23 AC 23 ms
24,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
int main(){
    int N,buf;
    int odd[1000] = {};
    int even[1000] = {};
    int A[501];
    char ans[500];
    bool flag=true;
    cin >> N;
    for(int i=0;i<=N;i++) A[i] = i;
    for(int i=1;i<=(N/2)*2;i++) even[i-1] = i;
    for(int i=1;i<=(N/2)*2-(N-1)%2*2;i++) odd[i-1] = i+1;
    while(flag){
        flag = false;
        cout << "? ";
        for(int i=0;i<2*N;i++) cout << A[even[i]] << " ";
        cout << endl;
        for(int i=0;i<N;i++){
            cin >> ans[i];
            if(ans[i] == '>'){
                buf = A[even[2*i]];
                A[even[2*i]] = A[even[2*i+1]];
                A[even[2*i+1]] = buf;
                flag = true;
            }
        }
        cout << "? ";
        for(int i=0;i<2*N;i++) cout << A[odd[i]] << " ";
        cout << endl;
        for(int i=0;i<N;i++){
            cin >> ans[i];
            if(ans[i] == '>'){
                buf = A[odd[2*i]];
                A[odd[2*i]] = A[odd[2*i+1]];
                A[odd[2*i+1]] = buf;
                flag = buf;
            }
        }
    }
    cout << "! ";
    for(int i=1;i<=N;i++) cout << A[i] << " ";
    cout << endl;
    return 0;
}
0