Submission #441387

# Submission time Handle Problem Language Result Execution time Memory
441387 2021-07-05T06:35:40 Z kym Combo (IOI18_combo) C++14
5 / 100
1 ms 200 KB
#include <bits/stdc++.h>
using namespace std;
//#define int ll 
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
#define reach cerr << "LINE: " << __LINE__ << "\n";
#else
#define db(x)
#define db2(x,y)
#define db3(a,b,c)
#define dbv(v)
#define dbvp(v)
#define dba(a,ss,ee)
#define reach 
#endif
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define g0(x) get<0>(x)
#define g1(x) get<1>(x)
#define g2(x) get<2>(x)
#define g3(x) get<3>(x)
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
typedef tuple<ll,ll,ll,ll> ti4;
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> bool chmax(T& a, const T b) { return a<b ? a = b, 1 : 0; }
template <typename T> bool chmin(T& a, const T b) { return a>b ? a = b, 1 : 0; }
const int MAXN = -1;

int press(std::string p);
string guess_sequence(int N) {
	int x= press("AB");
	char start;
	if(x==0){
		int y=press("X");
		if(y==1)start='X';
		else start='Y';
	} else {
		int y=press("A");
		if(y==1)start='A';
		else start='B';
	}
	string choices;
	if(start!='A')choices.pb('A');
	if(start!='B')choices.pb('B');
	if(start!='X')choices.pb('X');
	if(start!='Y')choices.pb('Y');
	//db(choices);
	string ans;
	ans += start;
	FOR(i,2,N-1) {
		//db(ans);
		string now = ans;
		string s1=now+choices[0]+choices[0];
		string s2=now+choices[0]+choices[1];
		string s3=now+choices[0]+choices[2];
		string s4=now+choices[1];
		//db(s1+s2+s3+s4);
		int res = press(s1+s2+s3+s4);
		//db(res);
		if(res==(int)now.size()+2){
			now+=choices[0];
		} else if(res==(int)now.size()+1){
			now+=choices[1];
		} else {
			now+=choices[2];
		}
		ans=now;
	}
	int r1=press(ans+choices[0]+ans+choices[1]);
	if(r1==(int)ans.size()+1) {
		r1=press(ans+choices[0]);
		if(r1==(int)ans.size()+1)ans+=choices[0];
		else ans+=choices[1];
	} else{
		ans+=choices[2];
	}
	return ans;
}
#ifdef LOCAL
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;
}

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;
}
#endif
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 0 ms 200 KB Output is correct
12 Correct 1 ms 200 KB Output is correct
13 Correct 1 ms 200 KB Output is correct
14 Correct 1 ms 200 KB Output is correct
15 Correct 0 ms 200 KB Output is correct
16 Correct 0 ms 200 KB Output is correct
17 Correct 0 ms 200 KB Output is correct
18 Correct 0 ms 200 KB Output is correct
19 Correct 0 ms 200 KB Output is correct
20 Correct 0 ms 200 KB Output is correct
21 Correct 1 ms 200 KB Output is correct
22 Correct 0 ms 200 KB Output is correct
23 Correct 1 ms 200 KB Output is correct
24 Correct 0 ms 200 KB Output is correct
25 Correct 1 ms 200 KB Output is correct
26 Correct 1 ms 200 KB Output is correct
27 Correct 1 ms 200 KB Output is correct
28 Correct 1 ms 200 KB Output is correct
29 Correct 0 ms 200 KB Output is correct
30 Correct 1 ms 200 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 1 ms 200 KB Output is correct
33 Correct 1 ms 200 KB Output is correct
34 Correct 0 ms 200 KB Output is correct
35 Correct 1 ms 200 KB Output is correct
36 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Wrong Answer: wrong guess.
2 Halted 0 ms 0 KB -