結果
| 問題 | 
                            No.2768 Password Crack
                             | 
                    
| コンテスト | |
| ユーザー | 
                             eve__fuyuki
                         | 
                    
| 提出日時 | 2024-05-31 23:00:24 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 100 ms / 2,000 ms | 
| コード長 | 842 bytes | 
| コンパイル時間 | 2,260 ms | 
| コンパイル使用メモリ | 194,696 KB | 
| 最終ジャッジ日時 | 2025-02-21 18:26:40 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 29 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}
int main() {
    fast_io();
    int n;
    cin >> n;
    string ans(n, 'a');
    for (int i = 0; i < n; i++) {
        vector<int> cnt(25);
        for (int j = 0; j < 25; j++) {
            ans[i] = 'a' + j;
            cout << "? " << ans << endl;
            cin >> cnt[j];
        }
        bool all_same = true;
        int ma_idx = 0;
        for (int j = 1; j < 25; j++) {
            if (cnt[j] != cnt[ma_idx]) {
                all_same = false;
            }
            if (cnt[j] > cnt[ma_idx]) {
                ma_idx = j;
            }
        }
        if (all_same) {
            ans[i] = 'z';
        } else {
            ans[i] = 'a' + ma_idx;
        }
    }
    cout << "! " << ans << endl;
}
            
            
            
        
            
eve__fuyuki