QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#723931 | #7703. Base Hi-Lo Game | MattTheNub# | TL | 1ms | 3652kb | C++23 | 3.8kb | 2024-11-08 04:04:51 | 2024-11-08 04:04:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T> using v = vector<T>;
using ll = long long;
using dd = long double;
using int2 = pair<int, int>;
using ll2 = pair<ll, ll>;
using dd2 = pair<dd, dd>;
#define f first
#define s second
#define all(x) begin(x), end(x)
istream &__cin = cin;
#ifdef DEV_MODE
#include "debug.h"
__cinwrapper __cin_wrapper;
#define cin __cin_wrapper
#else
#define dbg(...)
#define dbg2d(...)
#endif
template <class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
in >> p.first >> p.second;
return in;
}
template <class T> istream &operator>>(istream &in, v<T> &v) {
for (auto &x : v)
in >> x;
return in;
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/*
_______________________________________
( If you don't fail at least 90% of the )
( time, you're not aiming high enough. )
( )
( - Alan Kay )
---------------------------------------
o ^__^
o (oo)\_______
(__)\ )\/\
||----w |
|| ||
*/
const bool INTERACTIVE = true;
const bool MULTITEST = false;
/******************************************************************************/
#pragma region templates
#pragma endregion templates
void solve() {
int b, n;
cin >> b >> n;
const string digits =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
while (n--) {
int d;
cin >> d;
v<bool> eq(d);
v<bool> last(d);
v<int> pmid, plo(d), phi(d, b - 1);
v<int> lo(d), hi(d, b - 1), mid(d);
bool cheated = 0;
string R;
while (true) {
pmid = mid;
bool cnt = 0;
for (int i = 0; i < d; i++) {
mid[i] = (lo[i] + hi[i]) >> 1;
if (!cheated && hi[i] < lo[i]) {
string r;
cout << "cheater" << endl;
cin >> r;
cheated = 1;
for (int i = 0; i < d; i++) {
cout << digits[pmid[i]];
}
cout << endl;
cin >> r;
if (R == r) {
if (last[i]) {
lo[i] = plo[i];
} else {
hi[i] = phi[i];
}
} else if (last[i]) {
hi[i] = phi[i];
} else {
lo[i] = plo[i];
}
cnt = 1;
}
}
if (cnt)
continue;
dbg(lo, hi);
for (int i = 0; i < d; i++) {
cout << digits[mid[i]];
}
cout << endl;
cin >> R;
if (R == "correct")
break;
for (int i = 0; i < d; i++) {
if (R[i] == '+') {
last[i] = 0;
plo[i] = lo[i];
lo[i] = mid[i] + 1;
if (eq[i]) {
string r;
cout << "cheater" << endl;
cin >> r;
cheated = 1;
hi[i] = phi[i];
eq[i] = 0;
}
} else if (R[i] == '-') {
last[i] = 1;
phi[i] = hi[i];
hi[i] = mid[i] - 1;
if (eq[i]) {
string r;
cout << "cheater" << endl;
cin >> r;
cheated = 1;
lo[i] = plo[i];
eq[i] = 0;
}
} else {
plo[i] = lo[i];
phi[i] = hi[i];
lo[i] = hi[i] = mid[i];
eq[i] = 1;
}
}
}
}
}
int main() {
#ifdef DEV_MODE
debug_start(INTERACTIVE, "j.txt");
#else
ios::sync_with_stdio(false);
cin.tie(nullptr);
#endif
int t;
if (MULTITEST)
cin >> t;
else
t = 1;
while (t--)
solve();
#ifdef DEV_MODE
debug_exit(INTERACTIVE);
#endif
}
#ifdef DEV_MODE
#include "debug.cpp"
#endif
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3596kb
input:
10 2 5 ---=+ =++=- ==+== correct 6 -=++-+ +=-+-+ ==+==+ correct
output:
44444 11147 12245 12345 444444 147717 245808 246809
result:
ok correct (2 test cases)
Test #2:
score: 0
Accepted
time: 1ms
memory: 3652kb
input:
38 2 1 + + + + + correct 3 --- +-+ --- =-- correct
output:
I S X Z a b III 888 D3D A1A A09
result:
ok correct (2 test cases)
Test #3:
score: -100
Time Limit Exceeded
input:
10 6 3 --+ =++ =++ =+= correct 3 =+= =-= =+= =+= =+=
output:
444 117 128 139 cheater 139 139 139 139 139 139 139