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
#include<bits/stdc++.h>
using namespace std;

int main(){
    string s, bi, res="";
    cin >> s;

    int n,t, c=0;
    cin >> n >> t >> bi;

    while(c != t){
        for(int i = 0; i < bi.length(); i++){
            char o, r;
            if(bi[i]=='1'){
                cout << 'P' << endl;
                r='P';
            }
            else{
                cout << 'K' << endl;
                r='K';
            }

            cin >> o;

            if(o == 'P'){
                res+='1';
            }
            else{
                res+='0';
            }

            if(o != r){
                if(o == 'P'){
                    cout << 'N' << endl;
                }
                else{
                    cout << r << endl;
                }
                cin >> o;
            }
        }
        cout << "! " << res;
        cout.flush();

        c++;
    }
}