#include <bits/stdc++.h>
using namespace std;
void query(char c){
cout<<c<<"\n";
cout.flush();
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
string s;
cin>>s;
int N,T;
cin>>N>>T;
while (T--){
string s;
cin>>s;
string ans;
for (char c:s){
if (c=='1'){
query('K');
} else{
query('P');
}
char drugi;
cin>>drugi;
cout.flush();
if (drugi=='K') ans+='1';
else ans+='0';
if ((c=='1' and drugi=='P')){
query('P');
cin>>drugi;
cout.flush();
} else if ((c=='0' and drugi=='K')){
query('K');
cin>>drugi;
cout.flush();
}
}
cout<<"! "<<ans<<"\n";
cout.flush();
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #include <bits/stdc++.h> using namespace std; void query(char c){ cout<<c<<"\n"; cout.flush(); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); string s; cin>>s; int N,T; cin>>N>>T; while (T--){ string s; cin>>s; string ans; for (char c:s){ if (c=='1'){ query('K'); } else{ query('P'); } char drugi; cin>>drugi; cout.flush(); if (drugi=='K') ans+='1'; else ans+='0'; if ((c=='1' and drugi=='P')){ query('P'); cin>>drugi; cout.flush(); } else if ((c=='0' and drugi=='K')){ query('K'); cin>>drugi; cout.flush(); } } cout<<"! "<<ans<<"\n"; cout.flush(); } } |
English