#include <bits/stdc++.h>
using namespace std;
vector<bool> res(5005, 0);
string pass;
inline void play(int n){
for (int i = 0; i < n; i++){
if (pass[i] == '1')
cout << 'K' << '\n' << flush;
else
cout << 'P' << '\n' << flush;
char x; cin >> x;
res[i] = (x == 'K' ? 1 : 0);
if ((x == 'K' && pass[i] == '1') || (x == 'P' && pass[i] == '0')){
continue;
}
if (x == 'P'){
cout << 'P' << '\n' << flush;
cin >> x;
}else{
cout << 'K' << '\n' << flush;
cin >> x;
}
}
}
int main(){
string ply; cin >> ply;
int n, t; cin >> n >> t;
while (t--){
cin >> pass;
play(n);
cout << '!' << ' ';
for (int i = 0; i < n; i++)
cout << res[i];
cout << '\n' << flush;
}
return 0;
}
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 | #include <bits/stdc++.h> using namespace std; vector<bool> res(5005, 0); string pass; inline void play(int n){ for (int i = 0; i < n; i++){ if (pass[i] == '1') cout << 'K' << '\n' << flush; else cout << 'P' << '\n' << flush; char x; cin >> x; res[i] = (x == 'K' ? 1 : 0); if ((x == 'K' && pass[i] == '1') || (x == 'P' && pass[i] == '0')){ continue; } if (x == 'P'){ cout << 'P' << '\n' << flush; cin >> x; }else{ cout << 'K' << '\n' << flush; cin >> x; } } } int main(){ string ply; cin >> ply; int n, t; cin >> n >> t; while (t--){ cin >> pass; play(n); cout << '!' << ' '; for (int i = 0; i < n; i++) cout << res[i]; cout << '\n' << flush; } return 0; } |
English