結果

問題 No.2768 Password Crack
ユーザー kaede2020
提出日時 2024-05-31 22:24:26
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,208 bytes
コンパイル時間 6,328 ms
コンパイル使用メモリ 335,808 KB
実行使用メモリ 40,276 KB
平均クエリ数 177.47
最終ジャッジ日時 2024-12-21 00:01:58
合計ジャッジ時間 60,237 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12 TLE * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
//using mint = modint998244353;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};

int n;
int ok[111];
int main(){
    cin>>n;
    string ans="";
    rep(i,26){
        string s="";
        rep(j,n)s.push_back(char('a'+i));
        cout<<"? "<<s<<endl;
        int x;
        cin>>x;
        rep(j,x)ans.push_back(char('a'+i));
    }
    cout<<"? "<<ans<<endl;
    int x;
    cin>>x;
    int now=x;
    while(x!=n){
        rep(i,n-1){
            if(ok[i])continue;
            for(int j=i+1;j<n;j++){
                string t=ans;
                swap(t[i],t[j]);
                cout<<"? "<<t<<endl;
                cin>>now;
                if(x<now){
                    if(now-x==2){
                        ok[i]=1;
                        ok[j]=1;
                    }else{
                        ok[i]=1;
                    }
                    ans=t;
                    x=now;
                }
                if(x==n)break;
            }
        }
        if(x==n)break;
    }
    cout<<"! "<<ans<<endl;
    return 0;
}
0