結果

問題 No.2768 Password Crack
ユーザー tobbie
提出日時 2024-07-17 21:20:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 712 bytes
コンパイル時間 1,715 ms
コンパイル使用メモリ 170,116 KB
実行使用メモリ 25,464 KB
平均クエリ数 856.53
最終ジャッジ日時 2024-07-17 21:20:59
合計ジャッジ時間 5,891 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 28 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)

int main() {
  int N;
  cin >> N;
  string S = "";
  rep(i, N)
    S += 'z';
  cout << "? " << S << endl;
  int m;
  cin >> m;
  vector<int> a(N, 0);
  rep(i, 26) {
    int pren = 0;
    rep(j, N) {
      if (a[j] > 0)
	continue;
      string T = S;
      T[j] = 'a' + i;
      cout << "? " << T << endl;
      int n;
      cin >> n;
      if (n < pren) {
	a[j] = 1;
      } else {
	if (n - m > 0) {
	  if (a[j] == 0) {
	    S[j] = 'a' + i;
	    a[j] = 1;
	    m++;
	  }
	}
	pren = n;
      }
      if (n == N) {
	cout << "! " << S << endl;
	return 0;
      }
    }
  }
  cout << "! " << S << endl;
  return 0;
}
0