結果

問題 No.2768 Password Crack
ユーザー a01sa01to
提出日時 2024-06-28 00:38:46
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 805 bytes
コンパイル時間 2,801 ms
コンパイル使用メモリ 244,644 KB
実行使用メモリ 25,476 KB
平均クエリ数 885.00
最終ジャッジ日時 2024-06-28 00:38:53
合計ジャッジ時間 6,081 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
  #define _GLIBCXX_DEBUG
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

inline int Query(const string& s) {
  cout << "? " << s << endl;
  int res;
  cin >> res;
  return res;
}

int main() {
  int n;
  cin >> n;
  string s(n, 'a');
  int base = Query(s);
  rep(i, n) {
    rep(j, 24) {
      s[i] = 'b' + j;
      int res = Query(s);
      if (res > base) {
        s[i] = 'b' + j;
        base = res;
        break;
      }
      else if (res < base) {
        s[i] = 'a';
        break;
      }
      if (j == 23) {
        s[i] = 'z';
        base++;
      }
    }
  }
  cout << "! " << s << endl;
  return 0;
}
0