제출 #109663

#제출 시각아이디문제언어결과실행 시간메모리
109663youssefbou62Combo (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include  <bits/stdc++.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
int press (string s ){cout<<"query "<<s<<endl; 
	int x ; cin>> x ; return x ; 
}



string guess_sequence (int n){
		string buttons ,s2,s;  
		int ans ; 
		
		if( n == 1 ){
			if( press("A") ) return "A" ; 
			if( press("B") ) return "B" ;
			if( press("X"))return "X" ;
			return "Y" ; 
		}
		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 ; 
}


int main(){int n ; cin>> n ; 
	cout<<"answer is "<<guess_sequence(n)<<endl; 
}

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccUosA1Q.o: in function `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
grader.cpp:(.text+0x0): multiple definition of `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'; /tmp/ccJuHiVQ.o:combo.cpp:(.text+0xc0): first defined here
/usr/bin/ld: /tmp/ccUosA1Q.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccJuHiVQ.o:combo.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status