# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
207712 | Sho10 | Combo (IOI18_combo) | C++14 | 41 ms | 660 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
ID: Sho10
LANG: C++
*/
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#include <combo.h>
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
/*
ll n=5;
string S="ABXYY";
int press(std::string p) {
int coins = 0;
for (int i = 0, j = 0; i < n; ++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){
ll n=N;
string s="",ver="",x="";
ll a;
a=press("AB");
if(a==2){
s=s+'A';
x=x+'A';
ver=ver+'B';
ver=ver+'X';
ver=ver+'Y';
}else if(a==1){
a=press("A");
if(a==1){
s=s+'A';
x=x+'A';
ver=ver+'B';
ver=ver+'X';
ver=ver+'Y';
}else{
s=s+'B';
x=x+'B';
ver=ver+'A';
ver=ver+'X';
ver=ver+'Y';
}
}else {
a=press("X");
if(a==1){
s=s+'X';
x=x+'X';
ver=ver+'A';
ver=ver+'B';
ver=ver+'Y';
}else {
s=s+'Y';
x=x+'Y';
ver=ver+'A';
ver=ver+'B';
ver=ver+'X';
}
}
for(ll i=1;i<n;i++)
{
a=-1;
if(i==n-1){
if(s[0]=='A'){
a=-1;
}else {
a=press((x+"A"));
}
if(a==n){
s=s+'A';
}else {
if(s[0]=='B'){
a=-1;
}else {
a=press((x+"B"));
}
if(a==n){
s=s+'B';
}else {
if(s[0]=='X'){
s=s+'Y';
}else if(s[0]=='Y'){
s=s+'X';
}else {
a=press((x+"X"));
if(a==n){
s=s+'X';
}else {
s=s+'Y';
}
}
}
}
}else {
a=press((x+ver[0]+x+ver[1]+ver[0]+x+ver[1]+ver[1]+x+ver[1]+ver[2]));
if(a==x.size()){
s=s+ver[2];
x=x+ver[2];
}else if(a==x.size()+1){
s=s+ver[0];
x=x+ver[0];
}else {
s=s+ver[1];
x=x+ver[1];
}
}
}
return s;
}
/*
int32_t main(){
CODE_START;
cout<<guess_sequence(5)<<endl;
}
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |