Submission #1012643

#TimeUsernameProblemLanguageResultExecution timeMemory
1012643j_vdd16Combo (IOI18_combo)C++17
5 / 100
1 ms344 KiB
#include <algorithm>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#include "combo.h"

//#define int long long
#define loop(X, N) for(int X = 0; X < (N); X++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;

typedef uint64_t u64;
typedef int64_t i64;

int press(string p);

string guess_sequence(int n)
{
	vector<char> others = { 'A', 'B', 'X', 'Y' };
	
	string guess;
	if (press("A"))
	{
		guess = "A";
		others.erase(others.begin() + 0);
	}
	else if (press("B"))
	{
		guess = "B";
		others.erase(others.begin() + 1);
	}
	else if (press("X"))
	{
		guess = "X";
		others.erase(others.begin() + 2);
	}
	else if (press("Y"))
	{
		guess = "Y";
		others.erase(others.begin() + 3);
	}

	while (guess.size() < n - 1)
	{
		int result = press((guess + others[0]) + (guess + others[1] + others[0]) + (guess + others[1] + others[1]) + (guess + others[1] + others[2]));
		if (result == guess.size())
		{
			guess += others[2];
		}
		else if (result == guess.size() + 1)
		{
			guess += others[0];
		}
		else if (result == guess.size() + 2)
		{
			guess += others[1];
		}
	}

	if (press(guess + others[0]) == n)
		return guess + others[0];

	if (press(guess + others[1]) == n)
		return guess + others[1];

	if (press(guess + others[2]) == n)
		return guess + others[2];

	return guess + '.';
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:64:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   64 |  while (guess.size() < n - 1)
      |         ~~~~~~~~~~~~~^~~~~~~
combo.cpp:67:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |   if (result == guess.size())
      |       ~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:71:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |   else if (result == guess.size() + 1)
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:75:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |   else if (result == guess.size() + 2)
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...