Submission #109659

#TimeUsernameProblemLanguageResultExecution timeMemory
109659youssefbou62Combo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include  <bits/stdc++.h>
#include "combo.h" 
using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define pb push_back



string guess_sequence (int n){
		string buttons ,s2,s;  
		int ans ; 
		ans = press("ABABXBY") ; 
		if( ans ){
			if( ans == 1 ) s.pb('A') , buttons = "BXY"; 
			if( ans == 2 ) s.pb('B') , buttons = "AXY" ; 
		}
		else {
			ans = press ( "XYAYBYX" ) ; 
			if( ans == 1 ) s.pb('X') , buttons = "ABY" ;
			if( ans == 2 ) s.pb( 'Y' , buttons = "ABX" ; 
		}
		
		while ( (int)s.length() != n ){
		
			if( (int) s.length() == n-1 ) {
			  s2 = s + buttons[0] + s + buttons[1]; 
				if( press ( s2 ) == (int)s.length()  ){
					s.pb(buttons[2]) ; 
					break ; 
				}
			s2 = s + buttons[1] ; 
			if( press ( s2 ) == (int)s.length() + 1 ){
					s.pb(buttons[1]) ; 
					break ; 
			}
			s += buttons[0] ; 
			break ;  
			}
			else 	
			s2 = s + buttons[0] + s + buttons[1] + buttons[0] + s + buttons[1] + buttons[1] + s + buttons[1] + buttons[2] ; 
			 ans = press ( s2 ) ; 
			if( ans == (int)s.length() ){
				s.pb(buttons[2]) ; 
			}else if( ans == (int)s.length() + 1 ){
				s.pb(buttons[0]) ; 
			}else if( ans == (int)s.length() + 2 ){
				s.pb(buttons[1]); 
			}
		
		}
		
		assert( (int)s.length() == n) ; 
		return s ; 
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:46: error: expected ')' before ';' token
   25 |    if( ans == 2 ) s.pb( 'Y' , buttons = "ABX" ;
      |                       ~                      ^~
      |                                              )