Submission #714275

#TimeUsernameProblemLanguageResultExecution timeMemory
714275AstraytCombo (IOI18_combo)C++17
100 / 100
69 ms8552 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back

string guess_sequence(int N) {
	string S = "";
	int tmp = press("AB");
	if(tmp == 2) S += "AB";
	else if(tmp == 1){
		tmp = press("A");
		if(tmp) S += "A";
		else S += "B";
	}else{
		tmp = press("X");
		if(tmp) S += "X";
		else S += "Y";
	}
	vector<string> C;
	for(auto c:{"A", "B", "X", "Y"}){
		if(c[0] != S[0]) C.pb(c), cerr << c << '\n';
	}
	cerr << S << '\n';
	while(S.size() < N - 1){
		string Q = "";
		for(string s : C){
			Q += S + C[0] + s;
		}
		Q += S + C[1];
		cerr << Q << '\n';
		tmp = press(Q);
		if(tmp == S.size() + 2) S += C[0];
		else if(tmp == S.size() + 1) S += C[1];
		else S += C[2];
	}
	if(S.size() == N) return S;
	tmp = press(S + C[0]);
	cerr << S + C[0] << '\n';
	if(tmp == N) S += C[0];
	else {
		tmp = press(S + C[1]);
		if(tmp == N) S += C[1];
		else S += C[2];
	}
	cerr << S << '\n';
  	return S;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |  while(S.size() < N - 1){
      |        ~~~~~~~~~^~~~~~~
combo.cpp:32:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   if(tmp == S.size() + 2) S += C[0];
      |      ~~~~^~~~~~~~~~~~~~~
combo.cpp:33:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   else if(tmp == S.size() + 1) S += C[1];
      |           ~~~~^~~~~~~~~~~~~~~
combo.cpp:36:14: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |  if(S.size() == N) return S;
      |     ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...