Submission #595042

#TimeUsernameProblemLanguageResultExecution timeMemory
595042FatihSolakCombo (IOI18_combo)C++17
100 / 100
41 ms584 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int n) {
	vector<char> v = {'A','B','X','Y'};
	string ans = "";
	string p;
	if(press("AB")){
		if(press("A")){
			ans = "A";
		}
		else{
			ans = "B";
		}
	}
	else{
		if(press("X")){
			ans = "X";
		}
		else{
			ans = "Y";
		}
	}
	if(n == 1)
		return ans;
	vector<char> nw;
	for(auto u:v){
		if(u != ans[0])
			nw.push_back(u);
	}
	v = nw;
	for(int i = 1;i<n-1;i++){
		p = "";
		p += ans + v[0] + v[0];
		p += ans + v[0] + v[1];
		p += ans + v[0] + v[2];
		p += ans + v[1];
		int num = press(p);
		if(num == i){
			ans += v[2];
		}
		if(num == i+1){
			ans += v[1];
		}
		if(num == i+2){
			ans += v[0];
		}
	}
	for(int i = 0;i<v.size();i++){
		p = "";
		p = ans + v[i];
		if(i == v.size()-1 || press(p) == n){
			return p;
		}
	}
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:49:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |  for(int i = 0;i<v.size();i++){
      |                ~^~~~~~~~~
combo.cpp:52:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |   if(i == v.size()-1 || press(p) == n){
      |      ~~^~~~~~~~~~~~~
combo.cpp:5:35: warning: control reaches end of non-void function [-Wreturn-type]
    5 |  vector<char> v = {'A','B','X','Y'};
      |                                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...