結果

問題 No.2768 Password Crack
ユーザー InTheBloomInTheBloom
提出日時 2024-05-31 22:58:37
言語 C++23(gcc13)
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,940 bytes
コンパイル時間 1,703 ms
コンパイル使用メモリ 139,416 KB
実行使用メモリ 25,476 KB
平均クエリ数 858.37
最終ジャッジ日時 2024-05-31 22:58:48
合計ジャッジ時間 8,720 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <random>
#include <cassert>

using namespace std;
using ll = long long;

constexpr int iINF = 1'000'000'000;
constexpr ll llINF = 1'000'000'000'000'000'000;

void solve (int N) {
    // AAA..Aを送り付ける
    // BAA..Aを送り付ける
    // ABA..Aを送り付ける
    // -> N回でAの場所を特定できる。
    // というわけで、A~Yまでを2500回以内で特定できて、ハッピーというわけです。

    vector<vector<int>> idx(26);

    map<int, bool> found;

    int query = 0;
    vector<int> normal(N);

    for (int i = 0; i < 26; i++) {
        vector<char> S(N, (char)(i + 'a'));
        query++;
        assert(query <= 2500);
        cout << "? ";
        for (auto c : S) cout << c;
        cout << endl;
        cin >> normal[i];

        if (normal[i] == N) {
            for (int j = 0; j < N; j++) {
                found[j] = true;
                idx[i].push_back(j);
            }
            continue;
        }
    }

    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < N; j++) {
            // 回数節約
            if (found.find(j) != found.end()) continue;

            vector<char> S(N, (char)(i + 'a'));
            S[j] = (char) (i + 'a' + 1);
            query++;
            assert(query <= 2500);
            cout << "? ";
            for (auto c : S) cout << c;
            cout << endl;

            int res; cin >> res;
            if (res < normal[i]) {
                idx[i].push_back(j);
                found[j] = true;
            }
        }
    }

    vector<char> ans(N, '_');
    for (int i = 0; i < 26; i++) {
        for (auto j : idx[i]) ans[j] = (char) (i + 'a');
    }

    for (int i = 0; i < N; i++) if (ans[i] == '_') ans[i] = 'z';

    cout << "! ";
    for (auto c : ans) cout << c;
    cout << endl;
}

int main () {
    int N; cin >> N;
    solve(N);
}
0