Submission #508145

#TimeUsernameProblemLanguageResultExecution timeMemory
508145CasperWongCombo (IOI18_combo)C++11
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
std::string guess_sequence(int N) {
    long long n=N,x,y;
    string str="",temp;
    string ch[]={"A","B","X","Y"};
    vector<string>posi={};
    if(n==1){
    	for(auto i:ch){
    		if(i==ch[3]) return i;
    		x=press(i);
    		if(x==1) return i;
		}
	}
	x=press("AB");
	if(x){
		x=press("A");
		if(x) str="A";
		else str="B";
	}else{
		x=press("X");
		if(x) str="X";
		else str="Y";
	}
	for(auto i:ch) if(i[0]!=str[0]) posi.push_back(i);
    for(int i=1;i<n-1;i++){
    	temp="";
    	for(auto i:posi){
    		temp+=str+posi[0]+i;
		}
		temp+=posi[1];
		x=press(temp);
		if(x==i) str+=posi[2];
		else if(x==i+1) str+=posi[1];
		else str+=posi[0];
  	}
	for(auto i:posi){
		if(i==posi[2]){
			str+=i;
			break;
		}
  		x=press(str+i);
  		if(x==n){
  			str+=i;
  			break;
		}
	}
	return str;             	
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:11:9: error: 'press' was not declared in this scope
   11 |       x=press(i);
      |         ^~~~~
combo.cpp:15:4: error: 'press' was not declared in this scope
   15 |  x=press("AB");
      |    ^~~~~
combo.cpp:4:21: warning: unused variable 'y' [-Wunused-variable]
    4 |     long long n=N,x,y;
      |                     ^