제출 #143739

#제출 시각아이디문제언어결과실행 시간메모리
143739yum콤보 (IOI18_combo)C++14
0 / 100
2 ms200 KiB
#include "combo.h"

#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<long long, long long> pl;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double EPS = 1e-6;

string guess_sequence(int N) {
	vector<char> but = {'A', 'B', 'X', 'Y'};
	string ans;
	if (press("AB") >= 1) ans = press("A") ? "A" : "B";
	else ans = press("X") ? "X" : "Y";
	but.erase(find(but.begin(), but.end(), but[0]));
	for (int i = 1; i < N - 1; ++i) {
		int res = press(ans + but[0] + ans + but[1] + but[0] + ans + but[1] + but[1] + ans + but[1] + but[2]);
		if (res == ans.length()) ans += but[2];
		else if (res == ans.length() + 1) ans += but[0];
		else ans += but[1]; 
	}
	if (press(ans + but[0]) == ans.length() + 1) ans += but[0];
	else if (press(ans + but[1]) == ans.length() + 1) ans += but[1];
	else ans += but[2];
	return ans;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   if (res == ans.length()) ans += but[2];
      |       ~~~~^~~~~~~~~~~~~~~
combo.cpp:28:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   else if (res == ans.length() + 1) ans += but[0];
      |            ~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:31:26: 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 (press(ans + but[0]) == ans.length() + 1) ans += but[0];
      |      ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:32:31: 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 (press(ans + but[1]) == ans.length() + 1) ans += but[1];
      |           ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...