제출 #546126

#제출 시각아이디문제언어결과실행 시간메모리
546126jamezzz콤보 (IOI18_combo)C++17
0 / 100
1 ms208 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

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";
	}
	
	vector<string> v;
	if(S!="A")v.push_back("A");
	if(S!="B")v.push_back("B");
	if(S!="X")v.push_back("X");
	if(S!="Y")v.push_back("Y");
	
	for(int i=1;i<N-1;++i){
		int res=press(S+v[0]+v[0]+S+v[0]+v[1]+S+v[0]+v[2]+S+v[1]);
		if(res==S.length())S+=v[2];
		else if(res==S.length()+1)S+=v[1];
		else S+=v[0];
	}
	
	if(press(S+"A"+S+"B")==S.length()+1){
		if(press(S+"A")==S.length()+1)S+="A";
		else S+="B";
	}
	else{
		if(press(S+"X")==S.length()+1)S+="X";
		else S+="Y";
	}
	
	cout<<S<<endl;
	
	return S;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   if(res==S.length())S+=v[2];
      |      ~~~^~~~~~~~~~~~
combo.cpp:25:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   else if(res==S.length()+1)S+=v[1];
      |           ~~~^~~~~~~~~~~~~~
combo.cpp:29:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  if(press(S+"A"+S+"B")==S.length()+1){
      |     ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
combo.cpp:30:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   if(press(S+"A")==S.length()+1)S+="A";
      |      ~~~~~~~~~~~~^~~~~~~~~~~~~~
combo.cpp:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   if(press(S+"X")==S.length()+1)S+="X";
      |      ~~~~~~~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...