이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ff first
#define ss second
ll ttt;
const ll INF=1e18;
const ll MOD=1e9+7;
const ll N=5007;
ll n,m,k;
double p;
map<string, int>d;
int DIV=100;
bool query(string s){
if(d[s]){
if(d[s]==1){
return false;
}
return true;
}
cout<<"Q "<<s<<endl;
char res;
cin>>res;
bool ress=false;
if(res=='P'){
ress=true;
}
d[s]=ress+1;
return ress;
}
bool queryRange(int l, int r){
string s="";
for(int i=0;i<l;i++){
s+='0';
}
for(int i=l;i<=r;i++){
s+='1';
}
for(int i=r+1;i<n;i++){
s+='0';
}
return query(s);
}
int findNextPositive(int from, int to){
if(!queryRange(from, to)){
return to+1;
}
int l=from;
int r=to;
while(l<r){
int mid=(l+r)/2;
if(queryRange(l, mid)){
r=mid;
}
else{
l=mid+1;
}
}
return l;
}
void clear(){
d.clear();
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("Binput.txt","r",stdin);
// freopen("Boutput.txt","w",stdout);
cin>>n>>p>>ttt;
if(p<0.005){
DIV=1;
}
else if(p<0.02){
DIV=10;
}
else if(p<0.03){
DIV=33;
}
else if(p<0.05){
DIV=50;
}
else if(p<0.1){
DIV=80;
}
else if(p<0.15){
DIV=150;
}
else if(p<0.18){
DIV=250;
}
else{
DIV=400;
}
while(ttt--){
clear();
string ans="";
for(int i=0;i<n;i++){
ans+='0';
}
for(int fromm=0;fromm<n;fromm+=n/DIV){
int from=fromm;
int to=min(from+n/DIV-1,n-1);
while(true){
int ind=findNextPositive(from,to);
if(ind==to+1){
break;
}
from=ind+1;
ans[ind]='1';
if(from>=to+1)break;
}
}
cout<<"A "<<ans<<endl;
char c;
cin>>c;
if(c=='W'){
return 0;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |