# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
206536 | vardan__02 | Combo (IOI18_combo) | C++14 | 138 ms | 2072 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.
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <set>
#include <map>
#include "combo.h"
using namespace std;
string guess_sequence(int N)
{
int n=N;
string ans="";
string ban="";
int x;
if(n==2)
{
ans="XX";
x = press("XYYX");
if(x==0)
{
x = press("ABBA");
if(x==1)
{
x = press("AXBX");
if(x==1)
ans[1]='Y';
else
ans[1]='X';
x = press("A");
if(x==1)
ans[0]='A';
else
ans[0]='B';
}
else
{
x = press("AB");
if(x==2)
ans="AB";
else
ans="BA";
}
}
else
{
if(x==1)
{
x = press("XAYA");
if(x==1)
ans[1]='B';
else
ans[1]='A';
x = press("X");
if(x==1)
ans[0]='X';
else
ans[0]='Y';
}
else
{
x = press("XY");
if(x==2)
ans="XY";
else
ans="YX";
}
}
return ans;
}
x = press("A");
if(x==1)
{
ban="XYB";
ans="A";
}
else
{
x = press("B");
if(x==1)
{
ban="XYA";
ans="B";
}
else
{
x = press("X");
if(x==1)
{
ban="ABY";
ans="X";
}
else
{
ban="ABX";
ans="Y";
}
}
}
if(n==1)
return ans;
if(n%2==0)
{
string s="";
s=ans+ban[0]+ban[1]+ban[0]+ans+ban[1]+ban[0]+ban[1];
x = press(s);
if(x==1)
ans=ans+ban[2];
else
if(x==3)
{
s="";
s=ans+ban[0]+ban[1];
x = press(s);
if(x==3)
ans=ans+ban[0]+ban[1]+ban[2];
else
ans=ans+ban[1]+ban[0]+ban[2];
}
else
{
if(x==4)
{
s=ans+ban[0]+ban[1]+ban[0];
x = press(s);
if(x==4)
ans=ans+ban[0]+ban[1]+ban[0];
else
ans=ans+ban[1]+ban[0]+ban[1];
}
else
{
s="";
s=ans+ban[0]+ban[2]+ban[1]+ans+ban[1]+ban[2]+ban[0];
x = press(s);
if(x==3)
{
s="";
s=ans+ban[0];
x = press(s);
if(x==1)
ans=ans+ban[1];
else
ans=ans+ban[0];
ans=ans+ban[2]+ban[2];
}
else
{
s="";
s=ans+ban[0]+ban[2]+ban[1];
x = press(s);
if(x==4)
ans=ans+ban[0]+ban[2]+ban[1];
else
ans=ans+ban[1]+ban[2]+ban[0];
}
}
}
}
while(ans.size()!=n)
{
string s="";
s=ans+ban[0]+ban[1]+ans+ban[1]+ban[0];
x = press(s);
if(x==ans.size())
{
ans=ans+ban[2];
s=ans+ban[0];
x = press(s);
if(x==ans.size()+1)
ans=ans+ban[0];
else
ans=ans+ban[1];
}
else
{
if(x==ans.size()+1)
{
s=ans+ban[0]+ban[2];
x = press(s);
if(x==ans.size()+2)
ans=ans+ban[0]+ban[2];
else
ans=ans+ban[1]+ban[2];
}
else
{
s=ans+ban[0]+ban[1];
x = press(s);
if(x==ans.size()+2)
ans=ans+ban[0]+ban[1];
else
ans=ans+ban[1]+ban[0];
}
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |