#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int N = 5003;
int tab[N];
bool odp[N];
const char plays[N] = {'P', 'K', 'N'};
unordered_map<char, int> M;
void equalize(char mine, char his){
char ans = 'P';
if((mine == 'P' && his == 'K') || (mine == 'K' && his == 'N') || (mine == 'N' && his == 'P')) ans = 'K';
cout << ans << endl;
cin >> ans;
}
int main(){
cin.tie(0);
ios_base::sync_with_stdio(0);
M['P'] = 0;
M['K'] = 1;
M['N'] = 2;
string s, role;
int n, t;
cin >> role >> n >> t;
while(t--){
cin >> s;
s.push_back('0');
for(int i = 0 ; i < n ; i += 3){
int mask = (s[i] - '0') + 2 * (s[i + 1] - '0') + 4 * (s[i + 2] - '0');
pii myPlay = {mask / 3, mask % 3};
int hisMask = 0;
char a;
cout << plays[myPlay.first] << endl;
cin >> a;
hisMask = M[a] * 3;
if(a != plays[myPlay.first]) equalize(plays[myPlay.first], a);
cout << plays[myPlay.second] << endl;
cin >> a;
hisMask += M[a];
if(a != plays[myPlay.second]) equalize(plays[myPlay.second], a);
odp[i] = ((hisMask & 1) > 0);
odp[i + 1] = ((hisMask & 2) > 0);
odp[i + 2] = ((hisMask & 4) > 0);
}
cout << "! ";
for(int i = 0 ; i < n ; i++){
//cerr << odp[i];
cout << odp[i];
}
//cerr << endl;
cout << endl;
}
}
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 45 46 47 48 49 50 51 52 53 54 55 | #include<bits/stdc++.h> using namespace std; typedef pair<int, int> pii; const int N = 5003; int tab[N]; bool odp[N]; const char plays[N] = {'P', 'K', 'N'}; unordered_map<char, int> M; void equalize(char mine, char his){ char ans = 'P'; if((mine == 'P' && his == 'K') || (mine == 'K' && his == 'N') || (mine == 'N' && his == 'P')) ans = 'K'; cout << ans << endl; cin >> ans; } int main(){ cin.tie(0); ios_base::sync_with_stdio(0); M['P'] = 0; M['K'] = 1; M['N'] = 2; string s, role; int n, t; cin >> role >> n >> t; while(t--){ cin >> s; s.push_back('0'); for(int i = 0 ; i < n ; i += 3){ int mask = (s[i] - '0') + 2 * (s[i + 1] - '0') + 4 * (s[i + 2] - '0'); pii myPlay = {mask / 3, mask % 3}; int hisMask = 0; char a; cout << plays[myPlay.first] << endl; cin >> a; hisMask = M[a] * 3; if(a != plays[myPlay.first]) equalize(plays[myPlay.first], a); cout << plays[myPlay.second] << endl; cin >> a; hisMask += M[a]; if(a != plays[myPlay.second]) equalize(plays[myPlay.second], a); odp[i] = ((hisMask & 1) > 0); odp[i + 1] = ((hisMask & 2) > 0); odp[i + 2] = ((hisMask & 4) > 0); } cout << "! "; for(int i = 0 ; i < n ; i++){ //cerr << odp[i]; cout << odp[i]; } //cerr << endl; cout << endl; } } |
English