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<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
double p;
cin >> p;
int t;
cin >> t;
char x;
if(t == 1){
while(t--){
int pos[n];
for(int i = 0; i < n; i++){
cout << "Q" << " ";
for(int j = 0; j < n; j++){
if(j != i){
cout << "0";
}else{
cout <<"1";
}
}
cout << endl<<flush;
cin >> x;
if(x == 'P'){
pos[i] = 1;
}else{
pos[i] = 0;
}
}
cout << "A" <<" ";
for(int i = 0; i < n; i++){
cout<<pos[i];
}
cout << endl<<flush;
cin >> x;
}
}else{
int ans[n];
for(int i = 0; i < n; i++){
ans[i] = 0;
}
double p1 = 0.10;
if (p < p1){
while(t--){
int t1 = 0;
while(t1 == 0){
cout << "Q" <<" ";
for(int i = 0; i < n; i++){
if(ans[i] == 1){
cout << "0";
}else{
cout << "1";}
}
cout << endl << flush;
cin >> x;
if(x == 'N'){
t1++;
break;
}else{
int l = 0;
int r = n - 1;
while(l < r){
int mid = (l + r)/2;
cout << "Q" << " ";
for(int i = 0; i < l; i++){
cout << "0";
}
for(int i = l; i <= mid; i++){
if(ans[i] == 1){
cout <<"0";
}else{
cout <<"1";}
}
for(int i = mid + 1; i < n; i++){
cout <<"0";
}
cout << endl << flush;
cin >> x;
if(x == 'P'){
r = mid;
}else{
l = mid + 1;}
}
ans[l] = 1;
}
}
cout << "A" <<" ";
for(int i = 0; i < n; i++){
cout << ans[i];
}
cout << endl << flush;
cin >> x;
}
}else{
for(int i = 0; i < n; i = i + 2){
cout << "Q" << " ";
for(int j = 0; j < n; j++){
if(j == i or j == (i + 1)){
cout << "1";
}else{
cout << "0";
}
}
cout << endl << flush;
cin >> x;
if(x == 'P'){
cout << "Q" << " ";
for(int j = 0; j < n; j++){
if(j == i){
cout << "1";
}else{
cout << "0";
}
}
cout << endl << flush;
cin >> x;
if(x == 'P'){
ans[i] = 1;
}
cout << "Q" << " ";
for(int j = 0; j < n; j++){
if(j == (i +1)){
cout << "1";
}else{
cout << "0";
}
}
cout << endl << flush;
cin >> x;
if(x == 'P'){
ans[i + 1] = 1;
}
}
}
cout << "A" << " ";
for(int i = 0; i < n; i++){
cout << ans[i];
}
cout << endl << flush;
cin >> x;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |