結果

問題 No.2768 Password Crack
ユーザー kokosei
提出日時 2024-06-01 14:23:08
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 768 bytes
コンパイル時間 970 ms
コンパイル使用メモリ 84,084 KB
実行使用メモリ 25,348 KB
平均クエリ数 955.37
最終ジャッジ日時 2024-12-21 23:20:22
合計ジャッジ時間 4,663 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
using ll = long long;

int N;
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> N;
    string ans(N, 'z');
    for(int i = 0;i < N;i++){
        int base;
        cout << "? " << string(i, 'z') << "a" << string(N - 1 - i, 'z') << endl;
        cin >> base;
        for(char c = 'b';c < 'z';c++){
            string s = string(i, 'z') + c + string(N - 1 - i, 'z');
            cout << "? " << s << endl;
            int x; cin >> x;
            if(base == x + 1){
                ans[i] = 'a';
                break;
            }
            if(x == base + 1){
                ans[i] = c;
                break;
            }
        }
    }
    cout << "! " << ans << endl;
    return 0;
}
0