Submission #788194

#TimeUsernameProblemLanguageResultExecution timeMemory
788194APROHACKCombo (IOI18_combo)C++17
5 / 100
1 ms296 KiB
#include <bits/stdc++.h>
#include "combo.h"
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;




std::string guess_sequence(int N) {
  string p = "";
  string posi = "ABXY";
  string ans = "";
  char comienza;
  string newPosi = "";
  int best = 0, res = 0;
  for(int j = 0 ; j < 3 ; j ++){
	  p = ans;
	  p+= posi[j];
	  int coin = press(p);
	  if(coin > res){
		  res = coin;
		  best = j;
		  break;
	  }
  }
  if(res == 0)best = 3;
  ans += posi[best];	
  for(auto i : posi)if(i != posi[best])newPosi += i;
  //for (auto i : newPosi)cout << i << endl;
  for(int i = 1 ; i < N-1 ; i ++){
	  best = 0, res = 0;
	  p = ans;
	  p+=newPosi[0];
	  for(int j = 0 ; j < 3 ; j ++){
		  p += ans;
		  p += newPosi[1];
		  p += newPosi[j];
	  }
	  int coin = press(p);
	  //cout << " got " << coin << endl;
	  if(coin == i){
		  ans += newPosi[2];
	  }else if(coin == i+1){
		  ans += newPosi[0];
	  }else{
		  ans += newPosi[1];
	  }
  }
  p = ans;
  p += newPosi[0];
  if(press(p) == N){
	  return ans + newPosi[0];
  }
  p = ans;
  p+= newPosi[1];
  if(press(p) == N){
	  return ans + newPosi[1];
  }
  //cout << ans << endl;
  return ans + newPosi[2];
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:16:8: warning: unused variable 'comienza' [-Wunused-variable]
   16 |   char comienza;
      |        ^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...