Submission #596939

#TimeUsernameProblemLanguageResultExecution timeMemory
596939BelphegorCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include "combo.h"
using namespace std;
string C = "ABXY";
string guess_sequence(int n){
	string s = "AB";
	if(press(s)){
		s = "A";
		if(!press(s)) s = "B";
	}
	else{
		s = "X";
		if(!press(s)) s = "Y";
	}
	for(int i=0; C[i]; i++){
		if(C[i]==s[0]){
			C.erase(C.begin()+i);
			break;
		}
	}
	string S[4];
	for(int i=0; i<4; i++) S[i] = s;
	n--;
	while(n){
		int len = S[0].length();
		if(n==1){
			if(press(S[0]+"A"+S[0]+"B")>len){
				if(press(S[0]+"A")>len) S[0].push_back('A');
				else S[0].push_back('B');
			}
			else{
				if(press(S[0]+"X")>len) S[0].push_back('X');
				else S[0].push_back('Y');
			}
			n--;
		}
		else{
			for(int i=0; i<3; i++) S[i].push_back(C[0]);
			for(int i=0; i<3; i++) S[i].push_back(C[i]);
			S[3].push_back(C[1]);
			int ret = press(S[0]+S[1]+S[2]+S[3])
			for(int i=0; i<3; i++){
				S[i].pop_back();
				S[i].pop_back();
			}
			S[3].pop_back();
			char ch;
			if(ret==len) ch = C[2];
			else if(ret==len+1) ch = C[1];
			else ch = C[0];
			for(int i=0; i<4; i++) S[i].push_back(ch);
			n-=2;
		}
	}
	return S[0];
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:42:4: error: expected ',' or ';' before 'for'
   42 |    for(int i=0; i<3; i++){
      |    ^~~
combo.cpp:42:17: error: 'i' was not declared in this scope
   42 |    for(int i=0; i<3; i++){
      |                 ^