結果
| 問題 | No.2768 Password Crack |
| コンテスト | |
| ユーザー |
ortogawa
|
| 提出日時 | 2025-07-25 06:58:06 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 155 ms / 2,000 ms |
| + 2µs | |
| コード長 | 617 bytes |
| 記録 | |
| コンパイル時間 | 1,135 ms |
| コンパイル使用メモリ | 211,000 KB |
| 実行使用メモリ | 5,888 KB |
| 平均クエリ数 | 885.00 |
| 最終ジャッジ日時 | 2026-07-13 11:33:29 |
| 合計ジャッジ時間 | 3,831 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int query(string s) {
cout << "? " << s << endl;
int ans; cin >> ans;
return ans;
}
int main() {
int n; cin >> n;
int cnt = query(string(n, 'a'));
string ans;
for (int i = 0; i < n; i++) {
string t(n, 'a');
t[i] = 'b';
int ncnt = query(t);
if (ncnt > cnt) {
ans += 'b';
} else if (ncnt < cnt) {
ans += 'a';
} else {
bool found = false;
for (char x = 'c'; x < 'z'; x++) {
t[i] = x;
if (query(t) > cnt) {
ans += x;
found = true;
break;
}
}
if (!found) ans += 'z';
}
}
cout << "! " << ans << endl;
}
ortogawa