結果

問題 No.3347 Guess The Array
コンテスト
ユーザー Rubikun
提出日時 2025-11-13 23:25:19
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 414 ms / 2,000 ms
コード長 2,864 bytes
コンパイル時間 2,339 ms
コンパイル使用メモリ 210,868 KB
実行使用メモリ 25,984 KB
平均クエリ数 3607.41
最終ジャッジ日時 2025-11-13 23:25:38
合計ジャッジ時間 18,071 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vvii vector<vector<pair<int,int>>>
#define vvll vector<vector<pair<ll,ll>>>
#define vst vector<string>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define mkunique(x) sort(all(x));(x).erase(unique(all(x)),(x).end())
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=15<<26;

vi Z={0};

int askcn=0;

bool check(vi S){
    int i=0;
    for(int j=0;j<si(S);j++){
        while(i<si(Z)&&Z[i]!=S[j]) i++;
        if(i==si(Z)) return false;
        i++;
    }
    return true;
}
int NN;
bool ask(vi S){
    if(si(S)>NN) return false;
    askcn++;
    cout<<"? ";
    cout<<si(S);
    for(int x:S) cout<<" "<<x+1;
    cout<<endl;
    //return check(S);
    
    string T;cin>>T;
    if(T=="Yes") return true;
    else return false;
}

int main(){
    
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    
    auto rd=[&](ll momo){
        ll x=rng()%momo;
        if(x<0) x+=momo;
        return x;
    };
    int N;cin>>N;
    NN=N;
    Z.resize(N);
    vi miru(N);
    for(int i=0;i<N;i++){
        Z[i]=i;
        miru[i]=i;
    }
    shuffle(all(miru),rng);
    deque<vi> Q;
    for(int i:miru){
        vi T;
        for(int j=1;;j++){
            T.pb(i);
            if(ask(T)){
                
            }else{
                T.pop_back();
                break;
            }
        }
        if(si(T)) Q.pb(T);
    }
    
    while(si(Q)>1){
        auto A=Q.front();Q.pop_front();
        auto B=Q.front();Q.pop_front();
        if(si(A)<si(B)) swap(A,B);
        vi C;
        
        int j=0;
        for(int i=0;i<si(B);i++){
            vi T=C;
            int po=si(T);
            T.pb(B[i]);
            for(int s=j;s<si(A);s++) T.pb(A[s]);
            while(1){
                bool f;
                if(j==si(A)){
                    f=true;
                }else{
                    f=ask(T);
                }
                if(f){
                    C.pb(B[i]);
                    break;
                }else{
                    j++;
                    C.pb(T[po+1]);
                    swap(T[po],T[po+1]);
                    po++;
                }
            }
        }
        for(int s=j;s<si(A);s++) C.pb(A[s]);
        Q.pb(C);
    }
    
    cout<<"!";
    for(int x:Q.front()) cout<<" "<<x+1;
    cout<<endl;
    
}


0