QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#688438 | #7703. Base Hi-Lo Game | dbaumg | AC ✓ | 1ms | 3876kb | C++20 | 2.0kb | 2024-10-30 09:13:14 | 2024-10-30 09:13:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
string a = "";
for (int i = 0; i < 10; i++) a += ('0' + i);
for (int i = 0; i < 26; i++) a += ('A' + i);
for (int i = 0; i < 26; i++) a += ('a' + i);
map<char, ll> m;
for (int i = 0; i < a.size(); i++)
m[a[i]] = i;
ll b, n;
cin >> b >> n;
while (n--) {
ll k;
cin >> k;
ll lo[k] = {};
ll hi[k] = {};
fill_n(hi, k, b - 1);
vector<pair<string, string>> v;
string s, t;
bool valid = true;
while (true) {
bool done = true;
for (int i = 0; i < k; i++)
done &= lo[i] == hi[i];
if (done)
break;
for (int i = 0; i < k; i++)
done |= lo[i] > hi[i];
if (done) {
cout << "cheater" << endl;
cin >> s;
goto next;
}
ll mid[k] = {};
t = "";
for (int i = 0; i < k; i++) {
mid[i] = (lo[i] + hi[i]) / 2;
t += a[mid[i]];
}
cout << t << endl;
cin >> s;
if (s == "correct")
goto next;
v.push_back({t, s});
for (int i = 0; i < k; i++) {
if (s[i] == '=') {
lo[i] = mid[i];
hi[i] = mid[i];
} else if (s[i] == '+') {
lo[i] = mid[i] + 1;
} else {
hi[i] = mid[i] - 1;
}
}
}
t = "";
for (int i = 0; i < k; i++)
t += a[lo[i]];
cout << t << endl;
cin >> s;
if (s != "correct") {
cout << "cheater" << endl;
cin >> s;
}
next: continue;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3792kb
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: 3876kb
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: 0
Accepted
time: 1ms
memory: 3864kb
input:
10 6 3 --+ =++ =++ =+= correct 3 -++ ==+ =-+ correct 5 +++++ ++=-- +==++ ====- correct 4 ---- ==== ++++ correct 4 ++++ ++++ ==== ++++ correct 4 ==== ==== correct
output:
444 117 128 139 cheater 444 177 178 cheater 44444 77777 88755 98766 cheater 4444 1111 1111 cheater 4444 7777 8888 8888 cheater 4444 4444 cheater
result:
ok correct (6 test cases)
Test #4:
score: 0
Accepted
time: 1ms
memory: 3568kb
input:
62 2 4 ==== ==== correct 64 ================================================================ ================================================================ correct
output:
UUUU UUUU cheater UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU cheater
result:
ok correct (2 test cases)
Test #5:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
10 10 2 -= =- correct 2 -= =- correct 2 -= =- correct 2 -= =- correct 2 -+ =- =- correct 2 -- =+ =+ =+ correct 2 -- =+ =+ =+ correct 2 -- =+ =+ =+ correct 2 -- =+ =+ =+ correct 2 -- =+ =+ =+ correct
output:
44 14 cheater 44 14 cheater 44 14 cheater 44 14 cheater 44 17 15 cheater 44 11 12 13 cheater 44 11 12 13 cheater 44 11 12 13 cheater 44 11 12 13 cheater 44 11 12 13 cheater
result:
ok correct (10 test cases)
Test #6:
score: 0
Accepted
time: 1ms
memory: 3636kb
input:
8 2 2 ++ -- correct 2 ++ -- correct
output:
33 55 44 33 55 44
result:
ok correct (2 test cases)