이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "combo.h"
#define maxn (int)(1e5+51)
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define ll long long
#define pb push_back
#define ull unsigned long long
#define ii pair<int,int>
#define iii tuple<int,int,int>
#define inf 2000000001
#define mod 1000000007 //998244353
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; }
template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; }
char b[4]={'A','B','X','Y'};
string combo = "XBY";
// int press(string s){
// int ans = 0;
// int n = sz(s);
// for(int i=0;i<n;i++){
// for(int j=i;j<n;j++){
// string x="";
// for(int k=i;k<=j;k++)x+=s[k];
// if(sz(x)>sz(combo))continue;
// for(int k=0;k<sz(x);k++){
// if(x[k]!=combo[k])break;
// ckmax(ans,k+1);
// }
// }
// }
// return ans;
// }
string guess_sequence(int n){
string ans = "";
char first;
int q = press("AB");
if(q){
q = press("A");
if(q)first='A';
else first='B';
}else{
q = press("X");
if(q)first='X';
else first='Y';
}
ans+=first;
string um="",dois="",last="",x1,x2,x3;
for(int i=0;i<4;++i){
if(b[i]==first)continue;
if(!sz(um))um += b[i];
else if(!sz(dois))dois += b[i];
else last += b[i];
}
x1+=um+um,x2+=um+dois,x3+=um+last;
for(int i=3;i<=n;++i){
string query = "";
query+=ans+dois;
query+=ans+x1;
query+=ans+x2;
query+=ans+x3;
q = press(query);
if(q==0)ans+=last;
else if(q==i)ans+=um;
else ans+=dois;
}
if(n==1)return ans;
string query="";
query+=ans+um;
query+=ans+dois;
q = press(query);
if(q==n){
if(press(ans+um)==n)ans+=um;
else ans+=dois;
}else ans+=last;
return ans;
}
// int main(){
// string guess = guess_sequence(3);
// if(guess!=combo)cout<<"Wrong Answer"<<endl<<guess<<endl;
// else cout<<"Accepted"<<endl;
// }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |