結果
問題 | No.2768 Password Crack |
ユーザー |
![]() |
提出日時 | 2024-05-31 22:03:24 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 101 ms / 2,000 ms |
コード長 | 2,301 bytes |
コンパイル時間 | 1,110 ms |
コンパイル使用メモリ | 108,344 KB |
実行使用メモリ | 25,604 KB |
平均クエリ数 | 955.37 |
最終ジャッジ日時 | 2024-12-20 23:29:45 |
合計ジャッジ時間 | 4,731 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 29 |
ソースコード
//#pragma GCC target("avx2")//#pragma GCC optimize("O3")//#pragma GCC optimize("unroll-loops")#include <algorithm>#include <bitset>#include <cassert>#include <cmath>#include <complex>#include <climits>#include <deque>#include <iomanip>#include <iostream>#include <map>#include <queue>#include <set>#include <string>#include <tuple>#include <vector>using namespace std;using ll = long long;using pii = pair<int,int>;using pll = pair<ll,ll>;using pli = pair<ll,int>;#define TEST cerr << "TEST" << endl#define AMARI 998244353//#define AMARI 1000000007#define el '\n'#define El '\n'int print_question(string const& s){cout << "? ";cout << s << endl;int x;cin >> x;return x;}#define MULTI_TEST_CASE falsevoid solve(void){//問題を見たらまず「この問題設定から言えること」をいっぱい言う//一個回答に繋がりそうな解法が見えても、実装や細かい詰めに時間がかかりそうなら別の方針を考えてみる//添え字回りで面倒になりそうなときは楽になる言い換えを実装の前にじっくり考える//ある程度考察しても全然取っ掛かりが見えないときは実験をしてみる//よりシンプルな問題に言い換えられたら、言い換えた先の問題を自然言語ではっきりと書くint n;cin >> n;string s;string ans;for(int i = 0; i < n; i++)ans.push_back('a');for(int i = 0; i < n; i++){int aval = print_question(ans);ans[i] = 'b';int bval = print_question(ans);if(aval > bval){ans[i] = 'a';continue;}if(aval < bval){ans[i] = 'b';continue;}bool br = false;for(char c = 'c'; c < 'z'; c++){ans[i] = c;if(print_question(ans) > aval){br = true;break;}}if(!br)ans[i] = 'z';}cout << "! ";cout << ans << endl;return;}void calc(void){return;}signed main(void){cin.tie(nullptr);ios::sync_with_stdio(false);calc();int t = 1;if(MULTI_TEST_CASE)cin >> t;while(t--){solve();}return 0;}