제출 #750904

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

string guess_sequence(int N) {
	string A = "AB";
	string ans;
	if(press(A)) {
		A = "A";
		if(press(A)) ans = A;
		else ans = "B";
	} else {
		A = "X";
		if(press(A)) ans = A;
		else ans = "Y";
	}
	
	vector<string> p;
	p.clear();
	if(ans != "A") p.push_back("A");
	if(ans != "B") p.push_back("B");
	if(ans != "X") p.push_back("X");
	if(ans != "Y") p.push_back("Y");
	
//	cout<<ans<<endl;
//	for(int d=0;d<p.size();d++) cout<<p[d]<<endl;
	
	for(int i=1;i<=N-2;i++) {
		string cek;
		cek = ans;
		cek += p[0];
		for(int d=0;d<p.size();d++) {
			cek += ans;
			cek += p[1];
			cek += p[d];
		}
		int V = press(cek);
	//	cout<<V<<endl;
		if(V == ans.length()) ans += p[2];
		else if(V == ans.length() + 1) ans += p[0];
		else ans += p[1];
		
	//	cout<<ans<<endl;
	}
	string cek = ans;
	cek += "A";
	cek += ans;
	cek += "B";
//	cout<<press(cek)<<endl;
	if(press(cek) == N) {
		cek = ans;
		cek += "A";
		if(press(cek) == N) ans += "A";
		else ans += "B";
	} else {
		cek =  ans;
		cek += "X";
		if(press(cek) == N) ans += "X";
		else ans += "Y";
	}
	return ans;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:32:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   for(int d=0;d<p.size();d++) {
      |               ~^~~~~~~~~
combo.cpp:39:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   if(V == ans.length()) ans += p[2];
      |      ~~^~~~~~~~~~~~~~~
combo.cpp:40:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   else if(V == ans.length() + 1) ans += p[0];
      |           ~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...