제출 #982416

#제출 시각아이디문제언어결과실행 시간메모리
982416batsukh2006Combo (IOI18_combo)C++17
100 / 100
18 ms1752 KiB
#include "combo.h"
#include<bits/stdc++.h>
using namespace std;
string guess_sequence(int N){
	string t="ABXY",ans="";
	if(press("AB")){
		if(press("A")) ans+="A";
		else ans+="B";
	}else{
		if(press("X")) ans+="X";
		else ans+="Y";
	}
	string s="";
	for(int i=0; i<4; i++){
		string r="";
		r+=t[i];
		if(r!=ans) s+=t[i];
	}
	for(int i=1; i<N-1; i++){
		string tmp="";
		tmp+=ans+s[0];
		tmp+=ans+s[1]+s[0];
		tmp+=ans+s[1]+s[1];
		tmp+=ans+s[1]+s[2];
		int lst=ans.size();
		int find=press(tmp);
		if(find==lst) ans+=s[2];
		else if(find==lst+1) ans+=s[0];
		else ans+=s[1];
	}
	bool ok=0;
	if(ans.size()==N){
		ok=1;
	}else{
		for(int i=0; i<2; i++){
			string r=ans;
			r+=s[i];
			if(press(r)>ans.size()) ans+=s[i],ok=1;
		}
	}
	if(!ok) ans+=s[2];
	return ans;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:32:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |  if(ans.size()==N){
      |     ~~~~~~~~~~^~~
combo.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |    if(press(r)>ans.size()) ans+=s[i],ok=1;
      |       ~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...