QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#688428 | #7703. Base Hi-Lo Game | dbaumg | WA | 1ms | 3856kb | C++20 | 2.3kb | 2024-10-30 08:59:46 | 2024-10-30 08:59:47 |
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];
for (int i = 0; i < k; i++)
done |= lo[i] > hi[i];
if (done)
break;
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")
goto next;
v.push_back({t, s});
for (auto p : v) {
for (int i = 0; i < p.first.size(); i++) {
if (p.first[i] == '=') valid &= m[t[i]] == m[p.first[i]];
if (p.first[i] == '+') valid &= m[t[i]] > m[p.first[i]];
if (p.first[i] == '-') valid &= m[t[i]] < m[p.first[i]];
}
}
if (valid)
cout << t << endl;
else
cout << "cheater" << endl;
next: continue;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3664kb
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: 0ms
memory: 3856kb
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
Wrong Answer
time: 1ms
memory: 3636kb
input:
10 6 3 --+ =++ =++ =+= =+=
output:
444 117 128 139 139
result:
wrong answer Didn't get to correct answer in 5 guesses (test case 1)