#include <cstdio>
#include <string>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define PB push_back
#define INT(x) int x; scanf("%d", &x)
#define STR(n,x) char x[n]; scanf("%s", x)
int main() {
STR(10, player);
INT(n);
INT(t);
REP(tt,t) {
STR(5050, a);
string b;
int r = 0;
int n2 = n << 1;
REP(i,n2) {
bool send = (i & 1) ^ (player[0] == 'A');
if (send && a[i >> 1] == '1') {
if (r == 1) {
printf("K\n");
--r;
} else {
printf("N\n");
++r;
}
} else printf("P\n");
fflush(stdout);
STR(10, res);
if (!send) {
b.PB(res[0] != 'P' ? '1' : '0');
if (res[0] == 'K') ++r;
else if (res[0] == 'N') --r;
}
}
printf("! %s\n", b.c_str());
fflush(stdout);
}
}
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 | #include <cstdio> #include <string> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define PB push_back #define INT(x) int x; scanf("%d", &x) #define STR(n,x) char x[n]; scanf("%s", x) int main() { STR(10, player); INT(n); INT(t); REP(tt,t) { STR(5050, a); string b; int r = 0; int n2 = n << 1; REP(i,n2) { bool send = (i & 1) ^ (player[0] == 'A'); if (send && a[i >> 1] == '1') { if (r == 1) { printf("K\n"); --r; } else { printf("N\n"); ++r; } } else printf("P\n"); fflush(stdout); STR(10, res); if (!send) { b.PB(res[0] != 'P' ? '1' : '0'); if (res[0] == 'K') ++r; else if (res[0] == 'N') --r; } } printf("! %s\n", b.c_str()); fflush(stdout); } } |
English