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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <unordered_map>
using namespace std;


char zm01(char zer){
  if (zer == '1') return 'P';
  if (zer == '0') return 'K';
  return 'B';
}

char zmKP(char zer){
  if (zer == 'P') return '1';
  if (zer == 'K') return '0';
  return 'B';
}

int main() 
{
  //cout<<zm('1');
  int D=0;
  //std::ios_base::sync_with_stdio(false);
  //std::cin.tie(nullptr);
   string A="Algosia";
   string B="Bajtek";
   
   long long sumd = 0;
   string kto;
   cin>>kto;
   int n,t;
   cin>>n>>t;

    if(D) cout<<"Wczytalem start "<<" "<<n<<" "<<t<<endl;

   string wynik;
   while(t>0){
     t--;
     
     string co;
     string odp;
     cin>>co;
     //getline(std::cin, co);
     if(D) cout<<"Wczytalem '"<<co<<"' "<<n<<" "<<t<<endl;
     wynik = "";
     for(int i=0;i<n;i++){
        cout<<zm01(co[i])<<"\n";
        cout.flush();
        cin>>odp;
        //getline(std::cin, odp);
        if (D) cout<<"Wysłąłam "<<zm01(co[i])<<" Otrzymalam "<<odp<<"\n";
        wynik.push_back(zmKP(odp[0]));
        if (zm01(co[i]) != odp[0]){
          if (D) cout<<"Oddaje "<<odp<<"\n";
          cout<<odp<<"\n";
          cout.flush();
          cin>>odp;
          //getline(std::cin, odp);
        }
     }
     cout<<"! "<<wynik<<"\n";
     cout.flush();
     //getline(std::cin, odp);
     cin>>odp; //wczytanie !
     cin>>odp; //wczytanie odpowiedzi
   }

  
   /*
  Algosia P - 0, K - 1, N - koniec;
  Bajtek  P - Koniec, K - 0 , P - 1;
  */
  
  
   return 0;
}