結果
| 問題 |
No.2768 Password Crack
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-01 12:37:03 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 893 bytes |
| コンパイル時間 | 1,625 ms |
| コンパイル使用メモリ | 101,092 KB |
| 実行使用メモリ | 25,568 KB |
| 平均クエリ数 | 1513.37 |
| 最終ジャッジ日時 | 2024-12-21 19:20:23 |
| 合計ジャッジ時間 | 12,046 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 WA * 22 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:26:14: warning: 'c' may be used uninitialized [-Wmaybe-uninitialized]
26 | s[i] = c;
main.cpp:12:14: note: 'c' was declared here
12 | char c;
| ^
ソースコード
#include <iostream>
#include <ranges>
constexpr int INF = 1 << 30;
template <class T> constexpr inline bool chmin(T& a, const T& b) noexcept { if(a > b){ a = b; return true; } return false; }
template <class T> constexpr inline bool chmax(T& a, const T& b) noexcept { if(a < b){ a = b; return true; } return false; }
int main() {
int n, cnt = 0;
std::cin >> n;
std::string s(n, 'a');
for(const auto i: std::views::iota(0, n)) {
int chk = INF;
char c;
for(const auto j: std::views::iota(0, 25)) {
s[i] = 'a' + j;
std::cout << "? " + s << std::endl;
int now;
std::cin >> now;
if(chmax(cnt, now)) {
c = 'a' + j;
}
chmin(chk, now);
}
if(chk == cnt) {
c = 'z';
}
s[i] = c;
}
std::cout << "! " + s + "\n";
}