Submission #486438

#TimeUsernameProblemLanguageResultExecution timeMemory
486438ssenseCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
//#include "combo.h"
#define startt ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long  ll;
using namespace std;
#define vint vector<int>
#define all(v) v.begin(), v.end()
#define MOD 1000000007
#define MOD2 998244353
#define MX 1000000000
#define MXL 1000000000000000000
#define PI (ld)2*acos(0.0)
#define nax 200005
#define pb push_back
#define sc second
#define fr first
//#define int long long
#define endl '\n'
#define ld long double
#define NO cout << "NO" << endl
#define YES cout << "YES" << endl
/*
namespace {

constexpr int MAX_N = 2000;
constexpr int MAX_NUM_MOVES = 8000;

int N;
std::string S;

int num_moves;

void wrong_answer(const char *MSG) {
  printf("Wrong Answer: %s\n", MSG);
  exit(0);
}

}  // namespace

int press(std::string p) {
  if (++num_moves > MAX_NUM_MOVES) {
	wrong_answer("too many moves");
  }
  int len = p.length();
  if (len > 4 * N) {
	wrong_answer("invalid press");
  }
  for (int i = 0; i < len; ++i) {
	if (p[i] != 'A' && p[i] != 'B' && p[i] != 'X' && p[i] != 'Y') {
	  wrong_answer("invalid press");
	}
  }
  int coins = 0;
  for (int i = 0, j = 0; i < len; ++i) {
	if (j < N && S[j] == p[i]) {
	  ++j;
	} else if (S[0] == p[i]) {
	  j = 1;
	} else {
	  j = 0;
	}
	coins = std::max(coins, j);
  }
  return coins;
}

 */
string guess_sequence(int n)
{
	string s;
	vector<char> a(4);
	a[0] = 'A'; a[1] = 'B'; a[2] = 'X'; a[3] = 'Y';
	s.pb(a[0]); s.pb(a[1]);
	int exclude = 0;
	int k = press(s);
	if(k >= 1)
	{
		s.pop_back();
		k = press(s);
		if(k == 0)
		{
			s.pop_back();
			s.pb(a[1]);
			exclude = 1;
		}
	}
	else
	{
		s.pop_back();s.pop_back();
		s.pb(a[2]);
		k = press(s);
		exclude = 2;
		if(k == 0)
		{
			s.pop_back();
			s.pb(a[3]);
			exclude = 3;
		}
	}
	int one = 0, two = 0, three = 0;
	if(exclude == one)
	{
		one++;
	}
	two = one+1;
	if(two == exclude)
	{
		two++;
	}
	three = two+1;
	if(three == exclude)
	{
		three++;
	}
	for(int i = 0; i < n-2; i++)
	{
		string now = s+a[one]+a[one]+s+a[one]+a[two]+s+a[one]+a[three]+s+a[two];
		k = press(now);
		if(k == s.size()+2)
		{
			s.pb(a[one]);
			continue;
		}
		if(k == s.size()+1)
		{
			s.pb(a[two]);
			continue;
		}
		if(k == s.size())
		{
			s.pb(a[three]);
		}
	}
	string now = s+a[0]+s+a[1];
	k = press(now);
	if(k >= s.size()+1)
	{
		now = s+a[0];
		k = press(s);
		s.pb(a[0]);
		if(k == s.size()-1)
		{
			s.pop_back();
			s.pb(a[1]);
		}
	}
	else
	{
		now = s+a[2];
		k = press(s);
		s.pb(a[2]);
		if(k == s.size()-1)
		{
			s.pop_back();
			s.pb(a[3]);
		}
	}
	return s;
}

/*
int main() {
  char buffer[MAX_N + 1];
  if (scanf("%s", buffer) != 1) {
	fprintf(stderr, "Error while reading input\n");
	exit(1);
  }
  S = buffer;
  N = S.length();

  num_moves = 0;
  std::string answer = guess_sequence(N);
  if (answer != S) {
	wrong_answer("wrong guess");
	exit(0);
  }
  printf("Accepted: %d\n", num_moves);
  return 0;
}
*/

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:75:10: error: 'press' was not declared in this scope
   75 |  int k = press(s);
      |          ^~~~~
combo.cpp:119:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  119 |   if(k == s.size()+2)
      |      ~~^~~~~~~~~~~~~
combo.cpp:124:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  124 |   if(k == s.size()+1)
      |      ~~^~~~~~~~~~~~~
combo.cpp:129:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  129 |   if(k == s.size())
      |      ~~^~~~~~~~~~~
combo.cpp:136:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  136 |  if(k >= s.size()+1)
      |     ~~^~~~~~~~~~~~~
combo.cpp:141:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  141 |   if(k == s.size()-1)
      |      ~~^~~~~~~~~~~~~
combo.cpp:152:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  152 |   if(k == s.size()-1)
      |      ~~^~~~~~~~~~~~~