제출 #196886

#제출 시각아이디문제언어결과실행 시간메모리
196886JuneyCombo (IOI18_combo)C++14
0 / 100
3 ms248 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

char find_first() {
	int ret = press("AB");
	if(ret == 0) {
		if(press("XY") == 2) return 'X';
		return 'Y';
	}
	if(press("A") == 1) return 'A';
	return 'B';
}

string guess_sequence(int N) {
	string ans;
	char A = 'A', B = 'B', X = 'X', Y = 'Y';
	char f = find_first();
	if(f == B) swap(A, B);
	else if(f == X) swap(A, X);
	else if(f == Y) swap(A, Y);
	ans += f;

	for(int i=1; i<N-1; i++) {
		string tmp = ans + X + ans + Y + B + ans + Y + X + ans + Y + Y;
		int cnt = press(tmp);
		if(cnt == ans.size()) ans += B;
		else if(cnt == ans.size() + 1) ans += X;
		else ans += Y;
	}
	int cnt = press(ans + X + ans + Y);
	if(cnt == N) {
		if(press(ans + X) == N) return ans + X;
		return ans + Y;
	}
	return ans + B;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:10: 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(cnt == ans.size()) ans += B;
      |      ~~~~^~~~~~~~~~~~~
combo.cpp:28:15: 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(cnt == ans.size() + 1) ans += X;
      |           ~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...