Submission #1029611

#TimeUsernameProblemLanguageResultExecution timeMemory
1029611parsadox2Combo (IOI18_combo)C++17
0 / 100
0 ms344 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

char c[4];
string res;

void Add()
{
	string s = "";
	for(int i = 0 ; i < 3 ; i++)
	{
		s += res;
		s.push_back(c[0]);
		s.push_back(c[i]);
	}
	s += res;
	s.push_back(c[1]);
	s.push_back(c[1]);
	int tmp = press(s);
	if(tmp == res.size() + 2)
		res.push_back(c[0]);
	else if(tmp == res.size() + 1)
		res.push_back(c[1]);
	else
		res.push_back(c[2]);
}

string guess_sequence(int n)
{
	int a1 = press("AB") , a2 = press("AX");
	if(a1 > 0 && a2 > 0)
	{
		c[0] = 'B';
		c[1] = 'X';
		c[2] = 'Y';
		res.push_back('A');
	}
	else if(a1 > 0)
	{
		c[0] = 'A';
		c[1] = 'X';
		c[2] = 'Y';
		res.push_back('B');
	}
	else if(a2 > 0)
	{
		c[0] = 'A';
		c[1] = 'B';
		c[2] = 'Y';
		res.push_back('X');
	}
	else
	{
		c[0] = 'A';
		c[1] = 'B';
		c[2] = 'X';
		res.push_back('Y');
	}
	for(int i = 1 ; i + 2 <= n ; i++)
		Add();
	string s1 = res + c[0] , s2 = res + c[1];
	a1 = press(s1);  a2 = press(s2);
	if(a1 == n)
		return s1;
	else if(a2 == n)
		return s2;
	res.push_back(c[2]);
	return res;
}

Compilation message (stderr)

combo.cpp: In function 'void Add()':
combo.cpp:22:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  if(tmp == res.size() + 2)
      |     ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:24:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  else if(tmp == res.size() + 1)
      |          ~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...