結果

問題 No.2768 Password Crack
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-12-12 19:29:25
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 722 bytes
コンパイル時間 2,302 ms
コンパイル使用メモリ 200,300 KB
実行使用メモリ 25,476 KB
平均クエリ数 1785.17
最終ジャッジ日時 2024-12-20 21:45:13
合計ジャッジ時間 7,373 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void query(string &S){
    cout << "? " << S << endl;
}
void answer(string &T){
    cout << "! " << T << endl;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int N, M;
    cin >> N;
    string S=string(N, 'a');
    for (int i=0; i<N; i++){
        int mi=1e9, mx=0;
        char c='.';
        for (int j=0; j<25; j++){
            S[i] = char('a'+j);
            query(S);
            cin >> M;
            if (M > mx){
                mx = M;
                c = char('a'+j);
            }
            mi = min(mi, M);
        }
        if (mi == mx) c = 'z';
        S[i] = c;
    }

    answer(S);

    return 0;
}
0