Submission #207515

#TimeUsernameProblemLanguageResultExecution timeMemory
207515nishkarshCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
// string gg;
// int press(string s){
// 	cout << s << "\n";
// 	int co=0;
// 	co++;
// 	string pre;
// 	int ans = 0;
// 	for(int i = 0 ;i<gg.size();i++){
// 		pre += gg[i];
// 		bool poss=false;
// 		for(int j = 0;j<s.size();j++){
// 			if(j + pre.size() - 1 >= s.size()) break;
// 			if(s.substr(j,pre.size()) == pre){
// 				poss=true;
// 			}
// 		}
// 		if(poss) {
// 			ans = max(ans,(int)pre.size());
// 		}
// 	}
// 	return ans;
// }
string guess_first_char(){
	string s="AB";
	int x=press(s);
	if(x){
		s="A";
		x=press(s);
		if(x) return("A");
		else return("B");
	}
	else{
		s="X";
		x=press(s);
		if(x) return("X");
		else return("Y");
	}
}
string st[4];
void setting_strings(string &gg1){
	if(gg1=="A"){
		st[0]="B";st[1]="XB";st[2]="XX";st[3]="XY";
	}
	if(gg1=="B"){
		st[0]="A";st[1]="XA";st[2]="XX";st[3]="XY";
	}
	if(gg1=="X"){
		st[0]="Y";st[1]="AA";st[2]="AB";st[3]="AY";
	}
	if(gg1=="Y"){
		st[0]="X";st[1]="AA";st[2]="AB";st[3]="AX";
	}
}
string guess_sequence(int N){
	string ans=guess_first_char();
	string gg1 = ans;
	setting_strings(gg1);
	int x;
	if(N==1) return ans;
	string temp;
	for(int i = 2; i < N; i++){
		temp = ans;
		for(int j = 0; j < 3; j++){
			temp+=st[j];temp+=ans;
		}
		temp+=st[3];
		x=press(temp);
		if(x==i-1){
			if((gg1=="A")||(gg1=="B")) ans+="Y";
			if((gg1=="X")||(gg1=="Y")) ans+="B";
		}
		else if(x==i){
			if(gg1=="A") ans+="B";
			if(gg1=="B") ans+="A";
			if(gg1=="X") ans+="Y";
			if(gg1=="Y") ans+="X";
		}
		else{
			if((gg1=="A")||(gg1=="B")) ans+="X";
			if((gg1=="X")||(gg1=="Y")) ans+="A";			
		}
	}
	int oper=0;
	if(gg1!="A"){
		temp=ans;temp+="A";
		x=press(temp);oper++;
		if(x==N) return temp;
	}
	if(gg1!="B"){
		temp=ans;temp+="B";
		x=press(temp);oper++;
		if(x==N) return temp;
	}
	if(gg1!="X"){
		temp=ans;temp+="X";
		if(oper==2) return temp;
		x=press(temp);oper++;
		if(x==N) return temp;
	}
	temp=ans;temp+="Y";
	return temp;
}
// int main() {
// 	int n;
// 	cin >> n >> gg;
// 	cout << guess_sequence(n);
// 	return 0;
// }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_first_char()':
combo.cpp:47:8: error: 'press' was not declared in this scope
   47 |  int x=press(s);
      |        ^~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:89:5: error: 'press' was not declared in this scope
   89 |   x=press(temp);
      |     ^~~~~
combo.cpp:108:5: error: 'press' was not declared in this scope
  108 |   x=press(temp);oper++;
      |     ^~~~~
combo.cpp:113:5: error: 'press' was not declared in this scope
  113 |   x=press(temp);oper++;
      |     ^~~~~
combo.cpp:119:5: error: 'press' was not declared in this scope
  119 |   x=press(temp);oper++;
      |     ^~~~~