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"
#define here cerr<<"===========================================\n"
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {for(ll i = l;i<=r;i++) cerr<<a[i]<< " ";cerr<<endl;}
using namespace std;
#define maxn 8005
ll n;
string ans;
string p;
ll a[maxn];
bool b[maxn][5];
vector<char> v = {'.','A','B','X','Y'};
string conv(ll len){
string ans = "";
for(ll i = 1;i<=len;i++) ans.pb(v[a[i]]);
return ans;
}
ll m = 4;
ll cnt,c;
string guess_sequence(int N) {
n = N;
ll pr = -1;
for(ll i = 1;i<=m-1;i++){
a[1] = i;
ll c = press(conv(1));
if(c==1) pr = i;
}
if(pr==-1) pr = m;
a[1] = pr;
ll cnt1 = 0;
ll ls = 0;
for(ll i = 1;i<=m;i++){
if(i==a[1]) continue;
if(cnt1==2){
ls = i;
continue;
}
cnt1++;
}
if(n==1){
ans = conv(1);
goto lol;
}
for(ll i = 2;i<=n-1;i++){
//here;
ll len = i+2+n;
a[len] = a[1];
cnt = 0;
for(ll j = 1;j<=m;j++){
if(j==a[1]) continue;
if(cnt==2) continue;
cnt++;
if(b[i][j]) continue;
for(ll k = i;k<len;k++) a[k] = j;
c = press(conv(len));
//cerr<<conv(i+2)<< " "<<c<<endl;
if(c<i) continue;
a[i] = j;
for(ll k = i+1;k<=c;k++){
a[k] = j;
i++;
}
b[c+1][j] = 1;
goto lol1;
if(c==i+1){
a[i] = j;
a[i+1] = j;
i++;
goto lol1;
}
if(c==i){
a[i] = j;
b[i+1][j] = 1;
goto lol1;
}
}
a[i] = ls;
lol1:;
}
cnt = 0;
for(ll j = 1;j<=m;j++){
if(j==a[1]) continue;
if(cnt==2) continue;
cnt++;
a[n] = j;
ll c = press(conv(n));
if(c==n){
ans = conv(n);
goto lol;
}
}
a[n] = ls;
ans = conv(n);
lol:;
cerr<<ans<<endl;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |