# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
752554 | vjudge1 | 콤보 (IOI18_combo) | C++17 | 0 ms | 0 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 "combo.h"
#include<bits/stdc++.h>
using namespace std;
/*string ansstr;
int press(string s)
{
int ans = 0;
for(int i = 0; i < s.size(); i++){
int cur = 0;
for(int j = i; j < min(ansstr.size()+i, s.size()); j++){
if(ansstr[j-i] != s[j]) break;
cur++;
}
ans = max(ans, cur);
//cerr<<cur<<endl;
}
//cerr<<s<<" "<<ansstr<<" "<<ans<<endl;
return ans;
}*/
string guess_sequence(int n)
{
string ans;
int x = press("AB");
if(x == 0){
int se = press("X");
if(se == 1) ans += "X";
else ans += "Y";
}
else{
int se = press("A");
if(se == 1) ans += "A";
else ans += "B";
}
vector<string> c;
if(ans != "A") c.push_back("A");
if(ans != "B") c.push_back("B");
if(ans != "X") c.push_back("X");
if(ans != "Y") c.push_back("Y");
int i = 1;
while(i < n){
if(i == n-1){
int fi = press(ans+c[0])-ans.size();
if(fi == 0){
int se = press(ans+c[1])-ans.size();
if(se == 1) ans += c[1];
else ans += c[2];
}
else{
ans += c[0];
}
break;
}
int a = press(ans + c[0] + c[0] + ans + c[0] + c[1] + ans + c[1] + c[0])-ans.size();
if(a == 0){
ans += c[2];
}
else if(a == 1){
int b = press(ans + c[1] + c[1])-i;
if(b == 0) ans += c[0] + c[2];
else if(b == 1) ans += c[1] + c[2];
else ans += c[1] + c[1];
i++;
}
else{
int b = press(ans + c[0] + c[0])-i;
if(b == 0) ans += c[1] + c[0];
else if(b == 1) ans += c[0] + c[1];
else ans += c[0] + c[0];
i++;
}
i++;
}
return ans;
}
string jury(int n)
{
string s = guess_sequence(n);
if(s == ansstr) return "AC";
else return "WA " + s + " " + ansstr;
}
/*int main()
{
vector<string> ch = {"A", "B", "X", "Y"};
int WAcount = 0, test = 1000;
for(int i = 1; i <= test; i++){
int n = rand()%1000;
ansstr = "";
string x = ch[rand()%4];
ansstr += x;
for(int j = 0; j < n-1; j++){
string st = x;
while(st == x) st = ch[rand()%4];
ansstr += st;
}
cerr<<"Test "<<i<<": "<<n<<" "<<ansstr<<endl;
string verdict = jury(n);
cerr<<verdict<<endl;
WAcount += (verdict == "WA");
}
cout<<(test - WAcount)<<"/"<<test;
}
*/