Submission #1309363

#TimeUsernameProblemLanguageResultExecution timeMemory
1309363husseinjuanda콤보 (IOI18_combo)C++20
5 / 100
1 ms404 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

string id = "ABXY";

string guess_sequence(int n){
  vector<vector<int>> c(4, vector<int>(4));
  for(int i = 0; i < 4; i++){
    for(int y = 0; y < 4; y++){
      if(i == y) continue;
      string ans = "";
      ans += id[i];
      ans += id[y];
      c[i][y] = press(ans);
    }
  }
  vector<int> freq(4);
  vector<int> f(4);
  for(int i = 0; i < 4; i++){
    for(int y = 0; y < 4; y++){
      if(i == y) continue;
      if(c[i][y] < 2) continue;
      freq[i]++;
      f[y]++;
    }
  }
  string ns = "";
  for(int i = 0; i < 4; i++){
    if(freq[i] != 0 && f[i] == 0){
      ns += id[i];
      for(int y = 0; y < 4; y++){
        if(c[i][y] == 2){
          ns += id[y];
          break;
        }
      }
      break;
    }
  }
  for(int i = 0; i < n-2; i++){
    string h = id;
    shuffle(h.begin(), h.end(), rng);
    for(int y = 0; y < 4; y++){
      ns += h[y];
      int c = press(ns);
      if(c == i+3) break;
      ns.pop_back();
    }
  }
  return ns;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...