# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
534380 | MrDeboo | Combo (IOI18_combo) | C++17 | 36 ms | 312 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>
// #define int long long
using namespace std;
std::string guess_sequence(int n) {
srand(time(NULL));
char f[]={'A','B','X','Y'};
string s;
bool bl=0;
for(auto &i:f){
string g;
g+=i;
if(press(g)!=0){bl=1;s+=i;break;}
if(i=='X')break;
}
if(!bl)s+='Y';
vector<char>ve;
for(auto &i:f)if(i!=s[0])ve.push_back(i);
vector<char>v=ve;
int cnt=0;
while(s.size()!=n){
bool bl=0;
vector<bool>pick(3);
map<char,bool>mp;
for(int w=0;w<2;w++){
int f=rand()%3;
while(pick[f])f=rand()%3;
pick[f]=1;
int k=press(s+v[w]+v[f]);
cnt++;
if(k==s.size()+1){
s+=v[w];
mp[v[f]]=1;
bl=1;
break;
}else if(k==s.size()+2){
s+=v[w];
s+=v[f];
bl=1;
break;
}
}
if(!bl)s+=v.back();
vector<char>V;
for(auto i:ve)if(!mp[i])V.push_back(i);
ve=V;
}
if(cnt>n+10)return "ballsinturjawz";
return s;
// std::string p = "";
// for (int i = 0; i < 4 * N; ++i) {
// p += 'A';
// }
// int coins = press(p);
// std::string S = "";
// for (int i = 0; i < N; ++i) {
// S += 'A';
// }
// return S;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |