Submission #434003

#TimeUsernameProblemLanguageResultExecution timeMemory
434003ApiramCombo (IOI18_combo)C++14
30 / 100
89 ms648 KiB
#include<bits/stdc++.h>
#include "combo.h"
using namespace std;
//int press(string s);
std::string guess_sequence(int N) {
  int counts=0;
  string p;
  int maxxy = 4*N;
  string k = "ABXY";
  bool ok=false;
  for (int i =0;i<3;++i){
  	string c = string(maxxy - 1,k[i]);
  	int cost=press(p+c);
    if (cost>counts){
    	if (cost-counts>1){
    		for (int j = 0;j<cost-counts;++j)p+=k[i];
    		counts+=cost-counts;
    		k.erase(i,1);
    		ok=true;
    		break;
    	}
      counts++;
      p+=k[i];
      k.erase(i,1);
      ok=true;
      break;
    }
  }
  if (!ok){
  	k.erase(3,1);
  	counts++;
  	p+='Y';
  }
  while(p.length()<N){
  	ok=false;
  for (int i =0;i<2;++i){
  	char c =k[i];
  	string s = string(maxxy - p.length(),k[i]);
  	if (c==p[p.length()-1])continue;
  	 	int cost=press(p+s);
  if (cost>counts){
  	if (cost-counts>1){
    		for (int j = 0;j<cost-counts;++j)p+=c;
    		counts+=cost-counts;
    		ok=true;
    		break;
    	}
    counts++;
    p+=c;
    ok=true;
    break;
  }
  }
  if (!ok){
  	p+=k[2];
  	counts++;
  }
  }
  return p;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |   while(p.length()<N){
      |         ~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...