//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include <bits/stdc++.h>
using namespace std;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(int i = 0; i < n; i++)
#define FORAB(i, a, b) for(int i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C) ((B) <= (A) && (A) <= (C))
#define AIN(A, B, C) assert(IN(A, B, C))
#define LowerBound(c, x) distance((c).begin(), lower_bound(ALL(c), (x)))
#define UpperBound(c, x) distance((c).begin(), upper_bound(ALL(c), (x)))
#define UNIQUE(V) sort(ALL(V)), V.erase(unique(ALL(V)), V.end()), V.shrink_to_fit()
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) {
bool first = true;
string res = "{";
for (const auto& x : v) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(x);
}
res += "}";
return res;
}
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) { cerr << ' ' << to_string(H); dbg_out(T...); }
#ifdef LOCAL
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
template<class... T>
void input(T&... a) {
(cin >> ... >> a);
}
void printsuc(int suc){
if (suc == 1) cout << "\n";
if (suc == 2) cout << " ";
}
template<class t>
void print_single(t x, int suc = 1){
cout << x;
printsuc(suc);
}
template<class t, class u>
void print_single(const pair<t, u>& p, int suc = 1) {
print_single(p.first, 2);
print_single(p.second, suc);
}
template<class T>
void print_single(const vector<T>& V, int suc = 1) {
FORN(i, V.size()) print_single(V[i], i == int(V.size()) -1 ? 3 : 2);
printsuc(suc);
}
template<class T, size_t N>
void print_single(const array<T, N>& V, int suc = 1) {
FORN(i, N) print_single(V[i], i == int(N) - 1 ? 3 : 2);
printsuc(suc);
}
template<class T>
void print(const T& t) {
print_single(t);
}
template<class T, class ...Args>
void print(const T& t ,const Args&... args) {
print_single(t, 2);
print(args...);
}
// Alias function that calls print
template<class ...Args>
void output(const Args&... args) {
print(args...);
}
typedef long long int LL;
typedef long long i64;
typedef unsigned long long u64;
typedef __int128 i128;
typedef unsigned __int128 u128;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LL, int> PLI;
typedef pair<long double, long double> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PLL> VPL;
typedef vector<PII> VP;
typedef vector<long double> VD;
typedef vector<vector<int>> VVI;
typedef vector<vector<LL>> VVL;
typedef vector<string> VS;
// typedef long long double ld;
typedef unsigned long long ULL;
typedef unsigned long long u64;
//#define MAXN 1000
//#define MAXN2 MAXN*MAXN
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(10);
// shuffle(V.begin(), V.end(), rng);
// int u = rng();
// int u = uniform_int_distribution<long long>(L, R)(rng);
// long double u = uniform_real_distribution<float>(L, R)(rng);
// U R D L UR DR DL UL
int dr[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dc[] = { 0, 1, 0, -1, 1, 1, -1, -1};
// stable argument sort
template <typename T>
vector<int> argsort(const vector<T> &A) {
vector<int> ids(A.size());
iota(ids.begin(), ids.end(), 0);
sort(ids.begin(), ids.end(), [&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });
return ids;
}
// Usage:
// Example: Sort by size
// auto idx = argsort(words, [](const string& a, const string& b) { return a.size() < b.size(); });
template <typename T, typename Compare>
vector<int> argsort(const vector<T>& A, Compare comp) {
vector<int> ids(A.size());
iota(ids.begin(), ids.end(), 0);
sort(ids.begin(), ids.end(), [&](int i, int j) {
return comp(A[i], A[j]) || (!comp(A[j], A[i]) && i < j);
});
return ids;
}
// Usage:
// binary_search(check, l, r) - returns the last index i in [l, r) where check(i) is true
// If none, returns l - 1.
template <typename F>
LL binary_search(F check, LL ok, LL ng) {
if (!check(ok)) return ok - 1;
while (ng - ok > 1) {
auto x = (ng + ok) / 2;
(check(x) ? ok : ng) = x;
}
return ok;
}
// Usage:
// binary_search_real(check, l, r) - returns the last long double d in [l, r] where check(d) is true
template <typename F>
long double binary_search_real(F check, long double ok, long double ng, int iter = 100) {
FORN(_, iter) {
long double x = (ok + ng) / 2;
(check(x) ? ok : ng) = x;
}
return (ok + ng) / 2;
}
// MSB: (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(unsigned int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(i64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// LSB: (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(unsigned int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(i64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
const LL MOD = 1000000007;
// const LL MOD = 998244353;
// const LL INF = 2000000000000000001LL; //2e18 + 1
string my_name;
int player;
int n, t;
string my_string;
VI Arand, Brand;
int my_score = 0, his_score = 0;
VI me;
VI him;
int my_id;
// P = Paper. K = rock. N = scissorN.
// A: P=00, K=01, N=1
// B: P=1, K=01, N=00
char get_my_move() {
if (my_id == n) return 'P';
if (my_id == n - 1) {
if (player == 0) {
if (me[my_id] == 0) {
my_id = n;
return 'P';
}
else {
my_id = n;
return 'N';
}
} else {
if (me[my_id] == 0) {
my_id = n;
return 'N';
}
else {
my_id = n;
return 'P';
}
}
assert(0);
}
if (player == 0) {
if (me[my_id] == 0) {
if (me[my_id + 1] == 0) {
my_id += 2;
return 'P';
} else {
my_id += 2;
return 'K';
}
} else {
my_id++;
return 'N';
}
} else {
if (me[my_id] == 1) {
my_id++;
return 'P';
}
else {
if (me[my_id + 1] == 0) {
my_id += 2;
return 'N';
} else {
my_id += 2;
return 'K';
}
}
}
assert(0);
}
void PrintAnswer() {
VI& ans = him;
VI& rnd = (my_name == "Algosia" ? Brand : Arand);
string ans_str;
FORN(i, n) {
ans_str.push_back('0' + (rnd[i] ^ ans[i]));
}
output("! ", ans_str);
cout.flush();
}
// P = Paper. K = rock. N = scissorN.
void UpdateScore(char me, char he) {
if (me == he) return;
if (me == 'P' && he == 'K') my_score++;
if (he == 'P' && me == 'K') his_score++;
if (me == 'P' && he == 'N') his_score++;
if (he == 'P' && me == 'N') my_score++;
if (me == 'K' && he == 'N') my_score++;
if (he == 'K' && me == 'N') his_score++;
}
void insert_he(int a, int b) {
if (him.size() < n) him.push_back(a);
if (him.size() < n && b != -1) him.push_back(b);
}
int Move() {
if (him.size() == n && my_id == n) {
PrintAnswer();
return 0;
}
if (my_score == his_score) {
char my_move = get_my_move();
output(my_move);
cout.flush();
string his_move;
input(his_move);
if (player == 0) {
if (his_move[0] == 'P') insert_he(1, -1);
else if (his_move[0] == 'K') insert_he(0, 1);
else insert_he(0, 0);
} else {
if (his_move[0] == 'P') insert_he(0, 0);
else if (his_move[0] == 'K') insert_he(0, 1);
else insert_he(1, -1);
}
UpdateScore(my_move, his_move[0]);
return 1;
}
if (my_score < his_score) {
char my_move = '-';
int update = 0;
if (him.size() > my_id || (him.size() == my_id && player == 0)) {
// He will always play P.
if (my_id == n) {
my_move = 'N';
} else if (me[my_id] == 0) {
my_move = 'P';
} else {
my_move = 'N';
}
if (my_id < n) my_id++;
} else {
my_move = 'P';
update = 1;
}
output(my_move);
cout.flush();
string his_move;
input(his_move);
if (update && him.size() < n) {
if (my_move == his_move[0]) him.push_back(0);
else him.push_back(1);
}
UpdateScore(my_move, his_move[0]);
return 1;
}
if (my_score > his_score) {
char my_move = '-';
int update = 0;
if (my_id > him.size() || (my_id == him.size() && player == 1)) {
update = 1;
my_move = 'P';
} else {
// He will always play P.
if (my_id == n) my_move = 'K';
else if (me[my_id] == 0) my_move = 'P';
else my_move = 'K';
if (my_id < n) my_id++;
}
output(my_move);
cout.flush();
string his_move;
input(his_move);
if (update) {
if (my_move == his_move[0]) {
if (him.size() < n) him.push_back(0);
} else {
if (him.size() < n) him.push_back(1);
}
}
UpdateScore(my_move, his_move[0]);
return 1;
}
assert(0);
}
void generate_rand(VI& A, int player, int t) {
mt19937 rng(101 + 103 * t + player);
A.resize(n);
uniform_int_distribution<int> distrib(0, 1);
FORN(i, n) {
A[i] = distrib(rng);
// A[i] = rng() % 2;
// A[i] = 0;
}
}
void solve(int ks) {
input(my_name);
player = my_name == "Bajtek";
input(n, t);
FORN(_, t) {
input(my_string);
generate_rand(Arand, 0, _);
generate_rand(Brand, 1, _);
my_score = his_score = 0;
him.clear();
me.clear();
my_id = 0;
VI& rnd = (my_name == "Algosia" ? Arand : Brand);
for (int i = 0; i < n; i++) {
me.push_back((my_string[i] - '0') ^ rnd[i]);
}
while (Move());
}
}
void gen() {
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
std::cout << fixed << std::setprecision(10);
long double start_time = clock();
#ifdef LOCAL
// freopen("C:\\Home\\Contest\\sample.in", "r", stdin);
// freopen("C:\\Home\\Contest\\0.out", "w", stdout);
#endif
gen();
if (0) {
int T;
input(T);
for (int ks = 1; ks <= T; ks++) {
solve(ks);
if (ks % 1 == 0) dbg(ks, " done");
long double time_elapsed = (clock() - start_time) / CLOCKS_PER_SEC;
dbg(ks, ":", time_elapsed);
}
}
else {
solve(1);
}
long double TimeElapsed = (clock() - start_time) / CLOCKS_PER_SEC;
dbg(TimeElapsed);
return 0;
}
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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | //#pragma GCC optimize("Ofast") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma warning(disable:4786) #pragma warning(disable:4996) #include <bits/stdc++.h> using namespace std; #define MEM(a, b) memset(a, (b), sizeof(a)) #define CLR(a) memset(a, 0, sizeof(a)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) ) #define S(X) ( (X) * (X) ) #define SZ(V) (int )V.size() #define FORN(i, n) for(int i = 0; i < n; i++) #define FORAB(i, a, b) for(int i = a; i <= b; i++) #define ALL(V) V.begin(), V.end() #define IN(A, B, C) ((B) <= (A) && (A) <= (C)) #define AIN(A, B, C) assert(IN(A, B, C)) #define LowerBound(c, x) distance((c).begin(), lower_bound(ALL(c), (x))) #define UpperBound(c, x) distance((c).begin(), upper_bound(ALL(c), (x))) #define UNIQUE(V) sort(ALL(V)), V.erase(unique(ALL(V)), V.end()), V.shrink_to_fit() string to_string(string s) { return '"' + s + '"'; } string to_string(const char* s) { return to_string((string)s); } string to_string(bool b) { return (b ? "true" : "false"); } template <typename A, typename B> string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template <typename A> string to_string(A v) { bool first = true; string res = "{"; for (const auto& x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; } void dbg_out() { cerr << endl; } template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << to_string(H); dbg_out(T...); } #ifdef LOCAL #define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__) #else #define dbg(...) 0 #endif template<class... T> void input(T&... a) { (cin >> ... >> a); } void printsuc(int suc){ if (suc == 1) cout << "\n"; if (suc == 2) cout << " "; } template<class t> void print_single(t x, int suc = 1){ cout << x; printsuc(suc); } template<class t, class u> void print_single(const pair<t, u>& p, int suc = 1) { print_single(p.first, 2); print_single(p.second, suc); } template<class T> void print_single(const vector<T>& V, int suc = 1) { FORN(i, V.size()) print_single(V[i], i == int(V.size()) -1 ? 3 : 2); printsuc(suc); } template<class T, size_t N> void print_single(const array<T, N>& V, int suc = 1) { FORN(i, N) print_single(V[i], i == int(N) - 1 ? 3 : 2); printsuc(suc); } template<class T> void print(const T& t) { print_single(t); } template<class T, class ...Args> void print(const T& t ,const Args&... args) { print_single(t, 2); print(args...); } // Alias function that calls print template<class ...Args> void output(const Args&... args) { print(args...); } typedef long long int LL; typedef long long i64; typedef unsigned long long u64; typedef __int128 i128; typedef unsigned __int128 u128; typedef pair<int, int> PII; typedef pair<LL, LL> PLL; typedef pair<LL, int> PLI; typedef pair<long double, long double> PDD; typedef vector<int> VI; typedef vector<LL> VL; typedef vector<PLL> VPL; typedef vector<PII> VP; typedef vector<long double> VD; typedef vector<vector<int>> VVI; typedef vector<vector<LL>> VVL; typedef vector<string> VS; // typedef long long double ld; typedef unsigned long long ULL; typedef unsigned long long u64; //#define MAXN 1000 //#define MAXN2 MAXN*MAXN // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // mt19937 rng(10); // shuffle(V.begin(), V.end(), rng); // int u = rng(); // int u = uniform_int_distribution<long long>(L, R)(rng); // long double u = uniform_real_distribution<float>(L, R)(rng); // U R D L UR DR DL UL int dr[] = {-1, 0, 1, 0, -1, 1, 1, -1}; int dc[] = { 0, 1, 0, -1, 1, 1, -1, -1}; // stable argument sort template <typename T> vector<int> argsort(const vector<T> &A) { vector<int> ids(A.size()); iota(ids.begin(), ids.end(), 0); sort(ids.begin(), ids.end(), [&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); }); return ids; } // Usage: // Example: Sort by size // auto idx = argsort(words, [](const string& a, const string& b) { return a.size() < b.size(); }); template <typename T, typename Compare> vector<int> argsort(const vector<T>& A, Compare comp) { vector<int> ids(A.size()); iota(ids.begin(), ids.end(), 0); sort(ids.begin(), ids.end(), [&](int i, int j) { return comp(A[i], A[j]) || (!comp(A[j], A[i]) && i < j); }); return ids; } // Usage: // binary_search(check, l, r) - returns the last index i in [l, r) where check(i) is true // If none, returns l - 1. template <typename F> LL binary_search(F check, LL ok, LL ng) { if (!check(ok)) return ok - 1; while (ng - ok > 1) { auto x = (ng + ok) / 2; (check(x) ? ok : ng) = x; } return ok; } // Usage: // binary_search_real(check, l, r) - returns the last long double d in [l, r] where check(d) is true template <typename F> long double binary_search_real(F check, long double ok, long double ng, int iter = 100) { FORN(_, iter) { long double x = (ok + ng) / 2; (check(x) ? ok : ng) = x; } return (ok + ng) / 2; } // MSB: (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2) int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); } int topbit(unsigned int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); } int topbit(i64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); } int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); } // LSB: (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2) int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); } int lowbit(unsigned int x) { return (x == 0 ? -1 : __builtin_ctz(x)); } int lowbit(i64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); } int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); } const LL MOD = 1000000007; // const LL MOD = 998244353; // const LL INF = 2000000000000000001LL; //2e18 + 1 string my_name; int player; int n, t; string my_string; VI Arand, Brand; int my_score = 0, his_score = 0; VI me; VI him; int my_id; // P = Paper. K = rock. N = scissorN. // A: P=00, K=01, N=1 // B: P=1, K=01, N=00 char get_my_move() { if (my_id == n) return 'P'; if (my_id == n - 1) { if (player == 0) { if (me[my_id] == 0) { my_id = n; return 'P'; } else { my_id = n; return 'N'; } } else { if (me[my_id] == 0) { my_id = n; return 'N'; } else { my_id = n; return 'P'; } } assert(0); } if (player == 0) { if (me[my_id] == 0) { if (me[my_id + 1] == 0) { my_id += 2; return 'P'; } else { my_id += 2; return 'K'; } } else { my_id++; return 'N'; } } else { if (me[my_id] == 1) { my_id++; return 'P'; } else { if (me[my_id + 1] == 0) { my_id += 2; return 'N'; } else { my_id += 2; return 'K'; } } } assert(0); } void PrintAnswer() { VI& ans = him; VI& rnd = (my_name == "Algosia" ? Brand : Arand); string ans_str; FORN(i, n) { ans_str.push_back('0' + (rnd[i] ^ ans[i])); } output("! ", ans_str); cout.flush(); } // P = Paper. K = rock. N = scissorN. void UpdateScore(char me, char he) { if (me == he) return; if (me == 'P' && he == 'K') my_score++; if (he == 'P' && me == 'K') his_score++; if (me == 'P' && he == 'N') his_score++; if (he == 'P' && me == 'N') my_score++; if (me == 'K' && he == 'N') my_score++; if (he == 'K' && me == 'N') his_score++; } void insert_he(int a, int b) { if (him.size() < n) him.push_back(a); if (him.size() < n && b != -1) him.push_back(b); } int Move() { if (him.size() == n && my_id == n) { PrintAnswer(); return 0; } if (my_score == his_score) { char my_move = get_my_move(); output(my_move); cout.flush(); string his_move; input(his_move); if (player == 0) { if (his_move[0] == 'P') insert_he(1, -1); else if (his_move[0] == 'K') insert_he(0, 1); else insert_he(0, 0); } else { if (his_move[0] == 'P') insert_he(0, 0); else if (his_move[0] == 'K') insert_he(0, 1); else insert_he(1, -1); } UpdateScore(my_move, his_move[0]); return 1; } if (my_score < his_score) { char my_move = '-'; int update = 0; if (him.size() > my_id || (him.size() == my_id && player == 0)) { // He will always play P. if (my_id == n) { my_move = 'N'; } else if (me[my_id] == 0) { my_move = 'P'; } else { my_move = 'N'; } if (my_id < n) my_id++; } else { my_move = 'P'; update = 1; } output(my_move); cout.flush(); string his_move; input(his_move); if (update && him.size() < n) { if (my_move == his_move[0]) him.push_back(0); else him.push_back(1); } UpdateScore(my_move, his_move[0]); return 1; } if (my_score > his_score) { char my_move = '-'; int update = 0; if (my_id > him.size() || (my_id == him.size() && player == 1)) { update = 1; my_move = 'P'; } else { // He will always play P. if (my_id == n) my_move = 'K'; else if (me[my_id] == 0) my_move = 'P'; else my_move = 'K'; if (my_id < n) my_id++; } output(my_move); cout.flush(); string his_move; input(his_move); if (update) { if (my_move == his_move[0]) { if (him.size() < n) him.push_back(0); } else { if (him.size() < n) him.push_back(1); } } UpdateScore(my_move, his_move[0]); return 1; } assert(0); } void generate_rand(VI& A, int player, int t) { mt19937 rng(101 + 103 * t + player); A.resize(n); uniform_int_distribution<int> distrib(0, 1); FORN(i, n) { A[i] = distrib(rng); // A[i] = rng() % 2; // A[i] = 0; } } void solve(int ks) { input(my_name); player = my_name == "Bajtek"; input(n, t); FORN(_, t) { input(my_string); generate_rand(Arand, 0, _); generate_rand(Brand, 1, _); my_score = his_score = 0; him.clear(); me.clear(); my_id = 0; VI& rnd = (my_name == "Algosia" ? Arand : Brand); for (int i = 0; i < n; i++) { me.push_back((my_string[i] - '0') ^ rnd[i]); } while (Move()); } } void gen() { } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); std::cout << fixed << std::setprecision(10); long double start_time = clock(); #ifdef LOCAL // freopen("C:\\Home\\Contest\\sample.in", "r", stdin); // freopen("C:\\Home\\Contest\\0.out", "w", stdout); #endif gen(); if (0) { int T; input(T); for (int ks = 1; ks <= T; ks++) { solve(ks); if (ks % 1 == 0) dbg(ks, " done"); long double time_elapsed = (clock() - start_time) / CLOCKS_PER_SEC; dbg(ks, ":", time_elapsed); } } else { solve(1); } long double TimeElapsed = (clock() - start_time) / CLOCKS_PER_SEC; dbg(TimeElapsed); return 0; } |
English