제출 #171057

#제출 시각아이디문제언어결과실행 시간메모리
171057Nodir_Bobiev콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
# include "combo.h"
# include <bits/stdc++.h>
# define FILE
using namespace std;


string S;
int N, counter;

int prress( string p ){
	int coins = 0;
	counter ++;
	cout << counter << ' ' << p << endl;
	int len = p.size();
	for (int i = 0, j = 0; i < len; ++i) {
	    if (j < N && S[j] == p[i]) {
	    	++j;
	    }else if (S[0] == p[i]) {
	    	j = 1;
	    }else {
	    	j = 0;
	    }
	    coins = max(coins, j);
	}
	return coins;
}


string guess_sequence( int N ){
	string S;
	if( press("AB") ){
		if( press("A") ){
			S = "A";
		}
		else{
			S = "B";
		}
	}else{
		if( press( "X" ) ){
			S = "X";
		}
		else{
			S = "Y";
		}
	}
	set < char > st = { 'A', 'B', 'X', 'Y' };
	st.erase( S[0] );
	vector < char > vc;
	for( auto c: st ) vc.push_back( c );

	for( int i = 1; i < N-1; i ++ ){
		string p = S + vc[0] + S + vc[1] + vc[2] + S + vc[1] + vc[0]+ S + vc[1] + vc[1] ;
		int x = press( p );
		if( x == (int)S.size() ){
			S += vc[2];
		}
		else if( x == (int)S.size()+1 ){
			S += vc[0];
		}
		else{
			S += vc[1];
		}
	}
	if( press( S+vc[0] ) == N ){
		s += vc[0];
	}
	else if( press( S+vc[1] ) == N ){
		S += vc[1];
	}
	else{
		S += vc[2];
	}
	return S;
}

int mmain(){

    # ifdef FILE
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif
    ios_base::sync_with_stdio( false );
    cin >> S;
    N = S.size();
    cout << guess_sequence( S.size() );
    cout << endl << counter << endl;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:65:3: error: 's' was not declared in this scope; did you mean 'st'?
   65 |   s += vc[0];
      |   ^
      |   st
combo.cpp: In function 'int mmain()':
combo.cpp:87:1: warning: no return statement in function returning non-void [-Wreturn-type]
   87 | }
      | ^
combo.cpp:79:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |         freopen( "input.txt", "r", stdin );
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
combo.cpp:80:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |         freopen( "output.txt", "w", stdout );
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~