제출 #123070

#제출 시각아이디문제언어결과실행 시간메모리
123070khulegub콤보 (IOI18_combo)C++14
100 / 100
64 ms640 KiB
#include "combo.h"
#include<bits/stdc++.h>

using namespace std;


string butt[] = {"A", "B", "X", "Y"};

string guess_sequence(int n) {
	int f;
	string s = "";

	if(press("AB")){
		if(press("A")) f = 0;
		else f = 1;
	}
	else if(press("X")) f = 2;
	else f = 3;
	s += butt[f];

	// cout << "################\n";
	for (int i = 1; i < n - 1; i++){
		string asky = s + butt[(f + 1) % 4];
		asky += s + butt[(f + 2) % 4] + butt[(f + 1) % 4];
		asky += s + butt[(f + 2) % 4] + butt[(f + 2) % 4];
		asky += s + butt[(f + 2) % 4] + butt[(f + 3) % 4];
		// cout << asky << '\n';
		int x = press(asky);
		int nxt;
		// cout << x << ':' << s << '\n';
		if (x == s.length() + 1) nxt = (f + 1) % 4;
		else if (x == s.length() + 2) nxt = (f + 2) % 4;
		else nxt = (f + 3) % 4;
		s += butt[nxt];
	}
	if(n == 1) return s;
	// return s;
	// cout << "\n################\n";
	if(press(s + butt[(f + 1) % 4]) == s.length() + 1 ) s += butt[(f + 1) % 4];
	else if(press(s + butt[(f + 2) % 4]) == s.length() + 1 ) s += butt[(f + 2) % 4];
	else s += butt[(f + 3) % 4];
	return s;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:31:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   if (x == s.length() + 1) nxt = (f + 1) % 4;
      |       ~~^~~~~~~~~~~~~~~~~
combo.cpp:32:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   else if (x == s.length() + 2) nxt = (f + 2) % 4;
      |            ~~^~~~~~~~~~~~~~~~~
combo.cpp:39:34: 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(press(s + butt[(f + 1) % 4]) == s.length() + 1 ) s += butt[(f + 1) % 4];
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:40:39: 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(press(s + butt[(f + 2) % 4]) == s.length() + 1 ) s += butt[(f + 2) % 4];
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...