제출 #78010

#제출 시각아이디문제언어결과실행 시간메모리
78010KLPP콤보 (IOI18_combo)C++14
5 / 100
2 ms256 KiB
#include "combo.h"
#include<iostream>

using namespace std;

std::string guess_sequence(int N) {
	string s="";
	int p=press("AB");
	if(p>0){
		p=press("A");
		if(p>0){
			s+='A';
			while(s.length()<N-1){
				string h=s+"B";
				h+=s+"XB";
				h+=s+"XY";
				h+=s+"XX";
				int x=press(h);
				int y=s.length();
				if(x==y){
					s+='Y';
				}else if(x==y+1){
					s+='B';
				}else{
					s+='X';
				}
			}
			if(press(s+'X')>s.length()){
				s+='X';
			}
			else if(press(s+'B')>s.length()){
				s+='B';
			}else{
				s+='Y';
			}
			
			return s;
		}
		s+='B';
		while(s.length()<N-1){
			string h=s+"A";
			h+=s+"XA";
			h+=s+"XY";
			h+=s+"XX";
			int x=press(h);
			int y=s.length();
			if(x==y){
				s+='Y';
			}else if(x==y+1){
				s+='A';
			}else{
				s+='X';
			}
		}
		if(press(s+'X')>s.length()){
			s+='X';
		}
		else if(press(s+'A')>s.length()){
			s+='A';
		}else{
			s+='Y';
		}
		return s;
	}
	p=press("X");
	if(p>0){
		s+='X';
		while(s.length()<N-1){
			string h=s+"A";
			h+=s+"BA";
			h+=s+"BY";
			h+=s+"BB";
			int x=press(h);
			int y=s.length();
			if(x==y){
				s+='Y';
			}else if(x==y+1){
				s+='A';
			}else{
				s+='B';
			}
		}
		if(press(s+'B')>s.length()){
			s+='B';
		}
		else if(press(s+'A')>s.length()){
			s+='A';
		}else{
			s+='Y';
		}
		return s;
	}
	s+='Y';
	while(s.length()<N-1){
		string h=s+"A";
		h+=s+"BA";
		h+=s+"BX";
		h+=s+"BB";
		int x=press(h);
		int y=s.length();
		if(x==y){
			s+='X';
		}else if(x==y+1){
			s+='A';
		}else{
			s+='B';
		}
	}
	if(press(s+'B')>s.length()){
		s+='B';
	}
	else if(press(s+'A')>s.length()){
		s+='A';
	}else{
		s+='X';
	}
	return s;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |    while(s.length()<N-1){
      |          ~~~~~~~~~~^~~~
combo.cpp:28:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |    if(press(s+'X')>s.length()){
      |       ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:31:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |    else if(press(s+'B')>s.length()){
      |            ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:40:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |   while(s.length()<N-1){
      |         ~~~~~~~~~~^~~~
combo.cpp:55:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   if(press(s+'X')>s.length()){
      |      ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:58:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |   else if(press(s+'A')>s.length()){
      |           ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:68:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   68 |   while(s.length()<N-1){
      |         ~~~~~~~~~~^~~~
combo.cpp:83:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |   if(press(s+'B')>s.length()){
      |      ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:86:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |   else if(press(s+'A')>s.length()){
      |           ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:94:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   94 |  while(s.length()<N-1){
      |        ~~~~~~~~~~^~~~
combo.cpp:109:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  109 |  if(press(s+'B')>s.length()){
      |     ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:112:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  112 |  else if(press(s+'A')>s.length()){
      |          ~~~~~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...