結果

問題 No.2768 Password Crack
ユーザー winguwingu
提出日時 2024-05-31 22:24:46
言語 C++23(gcc13)
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,536 bytes
コンパイル時間 4,218 ms
コンパイル使用メモリ 286,544 KB
実行使用メモリ 25,580 KB
平均クエリ数 77.07
最終ジャッジ日時 2024-05-31 22:25:00
合計ジャッジ時間 13,845 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 WA -
testcase_03 WA -
testcase_04 RE -
testcase_05 RE -
testcase_06 WA -
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/modint>
using namespace atcoder;
#ifdef DEFINED_ONLY_IN_LOCAL
#include <dump.hpp>
#define dump(...) cpp_dump(__VA_ARGS__)
#else
#undef dump
#define dump(...)
#endif
template<class T>inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep1(i,a) for(int i=0;i<(int)(a);i++)
#define rep2(i,a,b) for(int i =(int)(a);i<(int)(b);i++)
#define rep3(i,a,b,c) for(int i=(int)(a);i<(int)(b);i+=(int)(c))
#define overloadRep(a,b,c,d,e,...)e
#define rep(...) overloadRep(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define drep(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
using P=pair<long,long>;
using T=tuple<long,long,long>;
const int inf=1e9;
const long INF=1e18;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
bool bit(long x, int p){return (x>>p)&1;}
bool out(int ni, int nj, int h, int w){return (ni<0 or ni>=h or nj<0 or nj>=w);}
int pc(long x){return __builtin_popcountl(x);}
using mint=modint998244353;

int main(){
    int n;cin>>n;

    auto get=[&](string t){
        cout<<"? "<<t<<endl;
        int res;cin>>res;
        return res;
    };

    vector<int>now(26);
    rep(i,26){
        string s(n,'a'+i);
        int x=get(s);
        now[i]=x;
    }
    string ans(n,'.');
    rep(i,n){
        string s(n,'a');
        // int mx=0,id=0;
        // vector<bool>used(26);
        // rep(j,26)if(chmax(mx,now[j]))id=j;
        set<pair<int,int>>st;
        rep(j,26)st.emplace(now[j],j);
        int id=st.rbegin()->first;
        st.erase(*st.rbegin());
        s[i]=char(id+'a');
        // used[id]=true;
        int pre=get(s);
        while(true){
            // int nmx=0,nid=0;
            // rep(j,26)if(!used[j]){
            //     if(chmax(nmx,now[j]))nid=j;
            // }
            // used[nid]=true;
            int nid=st.rbegin()->first;
            st.erase(*st.rbegin());
            s[i]=char(nid+'a');
            int nex=get(s);
            if(pre==nex){
                pre=nex;
                id=nid;
            }else if(nex==pre-1){
                ans[i]=char(id+'a');
                now[id]--;
                break;
            }else{
                ans[i]=char(nid+'a');
                now[nid]--;
                break;
            }
        }
    }

    cout<<"! "<<ans<<endl;
    return 0;
}
0