結果

問題 No.2768 Password Crack
ユーザー ococonomy1ococonomy1
提出日時 2024-05-31 22:03:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 2,301 bytes
コンパイル時間 1,104 ms
コンパイル使用メモリ 108,312 KB
実行使用メモリ 25,476 KB
平均クエリ数 955.37
最終ジャッジ日時 2024-05-31 22:03:29
合計ジャッジ時間 4,862 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
24,812 KB
testcase_01 AC 25 ms
24,568 KB
testcase_02 AC 100 ms
24,964 KB
testcase_03 AC 31 ms
24,580 KB
testcase_04 AC 68 ms
24,836 KB
testcase_05 AC 31 ms
24,964 KB
testcase_06 AC 66 ms
24,580 KB
testcase_07 AC 34 ms
24,580 KB
testcase_08 AC 36 ms
25,220 KB
testcase_09 AC 65 ms
25,092 KB
testcase_10 AC 70 ms
25,220 KB
testcase_11 AC 66 ms
24,836 KB
testcase_12 AC 70 ms
25,220 KB
testcase_13 AC 71 ms
24,580 KB
testcase_14 AC 68 ms
24,964 KB
testcase_15 AC 61 ms
25,220 KB
testcase_16 AC 65 ms
24,836 KB
testcase_17 AC 65 ms
25,160 KB
testcase_18 AC 65 ms
24,580 KB
testcase_19 AC 47 ms
24,580 KB
testcase_20 AC 52 ms
24,836 KB
testcase_21 AC 64 ms
24,964 KB
testcase_22 AC 59 ms
25,476 KB
testcase_23 AC 35 ms
24,580 KB
testcase_24 AC 44 ms
24,836 KB
testcase_25 AC 65 ms
25,220 KB
testcase_26 AC 45 ms
24,836 KB
testcase_27 AC 59 ms
24,964 KB
testcase_28 AC 36 ms
24,964 KB
testcase_29 AC 39 ms
25,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#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 false
void 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;
}
0