結果

問題 No.2768 Password Crack
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2024-05-09 08:06:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,347 bytes
コンパイル時間 3,155 ms
コンパイル使用メモリ 212,984 KB
実行使用メモリ 25,476 KB
平均クエリ数 704.30
最終ジャッジ日時 2024-05-09 19:30:11
合計ジャッジ時間 5,942 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
25,452 KB
testcase_01 AC 23 ms
24,580 KB
testcase_02 AC 50 ms
25,220 KB
testcase_03 AC 49 ms
24,964 KB
testcase_04 AC 52 ms
24,580 KB
testcase_05 AC 24 ms
24,836 KB
testcase_06 AC 49 ms
24,964 KB
testcase_07 RE -
testcase_08 AC 31 ms
24,824 KB
testcase_09 AC 51 ms
24,580 KB
testcase_10 AC 56 ms
24,836 KB
testcase_11 AC 51 ms
24,964 KB
testcase_12 RE -
testcase_13 AC 52 ms
25,220 KB
testcase_14 AC 51 ms
24,836 KB
testcase_15 RE -
testcase_16 AC 52 ms
25,220 KB
testcase_17 AC 52 ms
24,836 KB
testcase_18 AC 56 ms
25,220 KB
testcase_19 AC 37 ms
24,964 KB
testcase_20 AC 37 ms
24,836 KB
testcase_21 AC 52 ms
24,836 KB
testcase_22 AC 46 ms
24,836 KB
testcase_23 AC 28 ms
24,580 KB
testcase_24 AC 38 ms
24,964 KB
testcase_25 AC 51 ms
24,964 KB
testcase_26 AC 36 ms
24,964 KB
testcase_27 AC 46 ms
25,220 KB
testcase_28 AC 28 ms
24,836 KB
testcase_29 AC 30 ms
24,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int cnt = 0;

void query(string &S){
	cnt++;
	assert(cnt <= 1000);
    cout << "? " << S << endl;
}
void answer(string &T){
    cout << "! " << T << endl;
}

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

    int N, q, r, n;
    cin >> N;
    q = N / 3;
    r = N % 3;

    string S = string(N, 'a');

    for (int i=0; i<q; i++){
        vector<pair<int, int>> a(26);
        for (int j=0; j<26; j++){
            S[i*3] = char(j+'a');
            S[i*3+1] = char(j+'a');
            S[i*3+2] = char(j+'a');
            query(S);
            cin >> n;
            a[j] = {n, j};
        }
        sort(a.rbegin(), a.rend());
        if (a[0].first == a.back().first+3){
            S[i*3] = char(a[0].second+'a');
            S[i*3+1] = char(a[0].second+'a');
            S[i*3+2] = char(a[0].second+'a');
        }
        else if (a[0].first == a.back().first+2){
            assert(a[1].first == a.back().first+1);
            for (int j=0; j<3; j++){
                S[i*3] = char(a[0].second+'a');
                S[i*3+1] = char(a[0].second+'a');
                S[i*3+2] = char(a[0].second+'a');
                S[i*3+j] = char(a[1].second+'a');
                query(S);
                cin >> n;
                if (n == a.back().first+3){
                    break;
                }
            }
        }
        else{
            assert(a[0].first == a.back().first+1);
            assert(a[1].first == a.back().first+1);
            assert(a[2].first == a.back().first+1);
            vector<int> v = {0,1,2};
            do{
                S[i*3] = char(a[v[0]].second+'a');
                S[i*3+1] = char(a[v[1]].second+'a');
                S[i*3+2] = char(a[v[2]].second+'a');
                query(S);
                cin >> n;
                if (n == a.back().first+3){
                    break;
                }
            } while(next_permutation(v.begin(), v.end()));
        }
    }

    for (int i=0; i<r; i++){
        vector<pair<int, int>> a(26);
        for (int j=0; j<26; j++){
            S[N-1-i] = char(j+'a');
            query(S);
            cin >> n;
            a[j] = {n, j};
        }
        sort(a.rbegin(), a.rend());
        S[N-1-i] = char(a[0].second+'a');
    }

    answer(S);

    return 0;
}
0