#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long ll;
const ll M = 1000LL*1000LL*1000LL+7LL;
void guess_word(string player, int n){
string word; char m_p;
string guessed_word = "";
cin >> word;
for(int i = 0; i < n; i++){
if( word[i] == '1' ) cout << "P\n";
else cout << "K\n";
cout.flush();
cin >> m_p;
if( m_p == 'P') guessed_word.push_back('1');
if( m_p == 'K') guessed_word.push_back('0');
if( word[i] == '0' and guessed_word[i] == '1' ){
cout << "P\n";
cout.flush();
cin >> m_p;
}
if( word[i] == '1' and guessed_word[i] == '0' ){
cout << "K\n";
cout.flush();
cin >> m_p;
}
}
cout << "! " << guessed_word;
cout.flush();
}
void solve(){
int n, t;
string player;
cin >> player;
cin >> n >> t;
for(int i = 1; i <= t; i++) guess_word(player, n);
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
solve();
}
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 | #include <bits/stdc++.h> using namespace std; #define f first #define s second typedef long long ll; const ll M = 1000LL*1000LL*1000LL+7LL; void guess_word(string player, int n){ string word; char m_p; string guessed_word = ""; cin >> word; for(int i = 0; i < n; i++){ if( word[i] == '1' ) cout << "P\n"; else cout << "K\n"; cout.flush(); cin >> m_p; if( m_p == 'P') guessed_word.push_back('1'); if( m_p == 'K') guessed_word.push_back('0'); if( word[i] == '0' and guessed_word[i] == '1' ){ cout << "P\n"; cout.flush(); cin >> m_p; } if( word[i] == '1' and guessed_word[i] == '0' ){ cout << "K\n"; cout.flush(); cin >> m_p; } } cout << "! " << guessed_word; cout.flush(); } void solve(){ int n, t; string player; cin >> player; cin >> n >> t; for(int i = 1; i <= t; i++) guess_word(player, n); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); } |
English