結果

問題 No.1959 Prefix MinMax
ユーザー momoyuumomoyuu
提出日時 2023-07-16 01:17:55
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,602 bytes
コンパイル時間 2,921 ms
コンパイル使用メモリ 251,476 KB
実行使用メモリ 24,492 KB
平均クエリ数 39.69
最終ジャッジ日時 2023-10-17 11:17:43
合計ジャッジ時間 7,755 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
24,480 KB
testcase_01 AC 24 ms
24,480 KB
testcase_02 AC 24 ms
24,480 KB
testcase_03 AC 25 ms
24,480 KB
testcase_04 AC 24 ms
24,480 KB
testcase_05 AC 24 ms
24,480 KB
testcase_06 AC 24 ms
24,480 KB
testcase_07 AC 48 ms
24,480 KB
testcase_08 AC 49 ms
24,480 KB
testcase_09 AC 49 ms
24,480 KB
testcase_10 AC 47 ms
24,480 KB
testcase_11 AC 49 ms
24,480 KB
testcase_12 AC 48 ms
24,480 KB
testcase_13 AC 50 ms
24,480 KB
testcase_14 AC 48 ms
24,480 KB
testcase_15 AC 48 ms
24,480 KB
testcase_16 AC 51 ms
24,480 KB
testcase_17 AC 51 ms
24,480 KB
testcase_18 AC 49 ms
24,480 KB
testcase_19 AC 49 ms
24,480 KB
testcase_20 AC 50 ms
24,480 KB
testcase_21 AC 50 ms
24,480 KB
testcase_22 AC 49 ms
24,480 KB
testcase_23 AC 47 ms
24,480 KB
testcase_24 AC 50 ms
24,480 KB
testcase_25 AC 50 ms
24,480 KB
testcase_26 AC 49 ms
24,480 KB
testcase_27 AC 53 ms
24,480 KB
testcase_28 AC 52 ms
24,480 KB
testcase_29 AC 41 ms
24,480 KB
testcase_30 AC 43 ms
24,480 KB
testcase_31 AC 54 ms
24,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> p(n,-1);
        cout<<"?";
        string now = "";
        for(int i = 0;i<n-1;i++){
            cout<<" ";
            if(i%2==0) {
                cout<<1;
                now += "1";
            }
            else {
                cout<<0;
                now += "0";
            }
        }
        cout<<endl;
        vector<int> s(n);
        for(int i = 0;i<n;i++) cin>>s[i];
       
        int q = 10;
        while(q--){
            p[0] = s[0];
            for(int i = 1;i<n;i++){
                if(s[i-1]!=s[i]) p[i] = s[i];
            }
            bool ok = true;
            for(int i = 0;i<n;i++){
                if(p[i] == -1) ok = false;
            }
            if(ok) break;
            if(q==0) break;
            cout<<"?";
            string nxt = "";
            for(int i = 0;i<n-1;i++){
                cout<<" ";
                if(p[i+1]!=-1){
                    cout<<now[i];
                    nxt += now[i];
                }else{
                    if(now[i]=='1'){
                        cout<<0;
                        nxt += "0";
                    }else{
                        cout<<1;
                        nxt += "1";
                    }
                }
            }
            cout<<endl;
            for(int i = 0;i<n;i++) cin>>s[i];
            swap(now,nxt);
        }
        cout<<"!";
        for(int i = 0;i<n;i++) cout<<" "<<p[i];
        cout<<endl;
    }
}


0