結果

問題 No.2768 Password Crack
ユーザー 矢澤式WINTER
提出日時 2024-05-31 22:02:07
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 1,936 bytes
コンパイル時間 3,286 ms
コンパイル使用メモリ 253,300 KB
実行使用メモリ 25,220 KB
平均クエリ数 955.37
最終ジャッジ日時 2024-12-20 23:27:22
合計ジャッジ時間 7,026 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
/*/
#include <atcoder/all>
using namespace atcoder;
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
//*/
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define dbgv(x); for(auto now : x) cout << now << " "; cout << endl;
//using P = pair<int,int>;
using ll = long long;
using ull = unsigned long long;
//*/
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vint;
random_device rnd;
mt19937 rng(rnd());


vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if(n/i != i) ret.push_back(n/i);
        }
    }
    sort(ret.begin(),ret.end());
    return ret;
}


void solve(){
  int n; cin >> n;
  string ans = "";
  auto valid = [&](int id)->void{
    string test = string(n,'a');
    int prev = -1;
    for(char c = 'a';c < 'z';c++){
      test[id] = c;
      if(c == 'a'){
        cout << "? " << test << endl;
        cin >> prev;
      }else{
        cout << "? " << test << endl;
        int x; cin >> x;
        if(x < prev){
          ans += 'a';
          return;
        }
        if(x > prev){
          ans += c;
          return;
        }
      }
    }
    ans += 'z';
    return;
  };
  rep(i,n){
    valid(i);
  }
  cout << "! " << ans << endl;
}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1; //cin >> t;
  rep(testcases,t) solve();
}
0