Submission #109539

#TimeUsernameProblemLanguageResultExecution timeMemory
109539youssefbou62Combo (IOI18_combo)C++17
5 / 100
32 ms292 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 ,s;  
		if( press("A")==1 ) s.pb('A') , buttons = "BXY" ;
		else if( press("B")==1 ) s.pb('B') , buttons = "AXY" ;
		else if( press("X")==1 ) s.pb('X') , buttons = "ABY" ;
		else  s.pb('Y' ) , buttons = "ABX" ; 
		
		for(int i = 1 ; i < n ; i++ ){
			//cout<<i<<" "<<s<<endl; 
			if( i == 1 ) {
				for( char b : buttons ){
					int ans = press ( s + b + buttons[0] ) ; 
					if( ans == i+1 ){
						s+=b ;  break ;
					} 
					if( ans == i+2 ) {
						s+= b ; 
						s+= buttons[0] ;  
						 i ++ ; 
						  break ;
					} 
				}
				
				continue ; 	 
			}
			string s2 = s ; 
			s2  += buttons [1] ; 
			s2 += buttons [0] ; 
				int ans = press ( s2 ) ; 
				if( ans == i + 2 ){
					 s += buttons[1]  ;  
					 if( i != n-1 ) s+= buttons[0] ; 
					 i++ ; 
				}
				else if( ans == i + 1 ) s += buttons[1] ; 
				else s += buttons[2] ; 
			
		}
		assert( s.length() == n) ; 
		return s ; 
}

Compilation message (stderr)

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:1:
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:50:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |   assert( s.length() == n) ;
      |           ~~~~~~~~~~~^~~~
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...