結果
| 問題 |
No.2768 Password Crack
|
| コンテスト | |
| ユーザー |
Tatsu_mr
|
| 提出日時 | 2024-06-01 01:18:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 101 ms / 2,000 ms |
| コード長 | 861 bytes |
| コンパイル時間 | 2,106 ms |
| コンパイル使用メモリ | 198,768 KB |
| 最終ジャッジ日時 | 2025-02-21 18:43:39 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<char> ans(n);
for (int i = 0; i < n; i++) {
vector<int> num;
string ask = "";
for (int j = 0; j < n; j++) {
ask += "a";
}
for (char c = 'a'; c < 'z'; c++) {
ask[i] = c;
cout << "? " << ask << endl;
int cnt;
cin >> cnt;
num.push_back(cnt);
}
int id = max_element(num.begin(), num.end()) - num.begin();
bool same = true;
for (int j = 0; j < (int)num.size() - 1; j++) {
if (num[j] != num[j + 1]) {
same = false;
}
}
ans[i] = (same ? 'z' : (char)(id + 97));
}
cout << "! ";
for (auto c : ans) {
cout << c;
}
cout << endl;
return 0;
}
Tatsu_mr