結果
| 問題 |
No.2768 Password Crack
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-31 22:55:32 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,262 bytes |
| コンパイル時間 | 3,141 ms |
| コンパイル使用メモリ | 141,460 KB |
| 実行使用メモリ | 25,476 KB |
| 平均クエリ数 | 986.47 |
| 最終ジャッジ日時 | 2024-12-21 01:02:37 |
| 合計ジャッジ時間 | 9,364 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 WA * 25 |
ソースコード
#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;
random_device rd;
vector<bool> used(26, false);
int ban = rd() % 26;
int query = 0;
for (int i = 0; i < 26; i++) {
// らんたくしましょ。そうしましょ。
if (i == ban) continue;
used[i] = true;
{
vector<char> S(N, (char)(i + 'a'));
query++;
assert(query <= 2500);
cout << "? ";
for (auto c : S) cout << c;
cout << endl;
}
int normal; cin >> normal;
if (normal == N) {
for (int j = 0; j < N; j++) {
found[j] = true;
idx[i].push_back(j);
}
continue;
}
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) {
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');
}
char unused = 0;
for (int i = 0; i < 26; i++) if (!used[i]) unused = (char) ('a' + i);
assert('a' <= unused && unused <= 'z');
for (int i = 0; i < N; i++) if (ans[i] == '_') ans[i] = unused;
cout << "! ";
for (auto c : ans) cout << c;
cout << endl;
}
int main () {
int N; cin >> N;
solve(N);
}