QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#552976 | #7703. Base Hi-Lo Game | stig# | AC ✓ | 1ms | 3812kb | C++20 | 2.5kb | 2024-09-08 04:50:41 | 2024-09-08 04:50:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
typedef int uci;
#define int long long
#define ld long double
#define sz(x) ((int)x.size())
#define all(a) (a).begin(), (a).end()
uci main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
vector<char> dict;
map<char, int> undict;
for (char x = '0'; x <= '9'; x++) dict.push_back(x);
for (char x = 'A'; x <= 'Z'; x++) dict.push_back(x);
for (char x = 'a'; x <= 'z'; x++) dict.push_back(x);
for (int i = 0; i < sz(dict); i++) undict[dict[i]] = i;
int b, n;
cin >> b >> n;
int tg = log2(b) + 1;
while (n--) {
int d;
cin >> d;
vector<int> l(d, 0), r(d, b - 1);
bool good = 0;
for (int c = 0; c < tg; c++) {
string guess = "";
for (int i = 0; i < d; i++) {
if (r[i] < l[i]) {
guess = "cheater";
good = 1;
break;
}
int mid = (r[i] + l[i]) / 2;
guess += dict[mid];
}
cout << guess << endl;
string resp;
cin >> resp;
if (resp == "correct") {
good = 1;
break;
}
for (int i = 0; i < d; i++) {
int mid = (r[i] + l[i]) / 2;
if (resp[i] == '=') {
l[i] = mid;
}
else if (resp[i] == '-') {
r[i] = mid - 1;
}
else {
l[i] = mid + 1;
}
}
}
if (!good) {
cout << "cheater" << endl;
string resp;
cin >> resp;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3680kb
input:
10 2 5 ---=+ =++-- -=+== correct 6 -=++-+ +--+-+ ==+==+ correct
output:
44444 11167 22245 12345 444444 167717 245808 246809
result:
ok correct (2 test cases)
Test #2:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
38 2 1 + + + + + correct 3 --- +-+ --- =-- -== correct
output:
I S X Z a b III 888 D3D A1A B09 A09
result:
ok correct (2 test cases)
Test #3:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
10 6 3 --+ =++ -++ =+= correct 3 -++ ==+ --+ =-= correct 5 +++++ ++=-- +=-++ ====- correct 4 ---- ==== ++++ correct 4 ++++ ++++ ==== ++++ correct 4 ==== ==== ==== ==== correct
output:
444 117 228 139 cheater 444 177 288 179 cheater 44444 77777 88855 98766 cheater 4444 1111 2222 3333 4444 7777 8888 8888 cheater 4444 6666 7777 8888 cheater
result:
ok correct (6 test cases)
Test #4:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
62 2 4 ==== ==== ==== ==== ==== ==== correct 64 ================================================================ ================================================================ ================================================================ =========================================================...
output:
UUUU jjjj rrrr vvvv xxxx yyyy cheater UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv xx...
result:
ok correct (2 test cases)
Test #5:
score: 0
Accepted
time: 1ms
memory: 3812kb
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 16 24 cheater 44 16 24 cheater 44 16 24 cheater 44 16 24 cheater 44 17 25 cheater 44 11 22 13 cheater 44 11 22 13 cheater 44 11 22 13 cheater 44 11 22 13 cheater 44 11 22 13 cheater
result:
ok correct (10 test cases)
Test #6:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
8 2 2 ++ -- correct 2 ++ -- correct
output:
33 55 44 33 55 44
result:
ok correct (2 test cases)