QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#546673 | #7703. Base Hi-Lo Game | truebqccq# | WA | 1ms | 3852kb | C++17 | 4.0kb | 2024-09-04 11:28:34 | 2024-09-04 11:28:41 |
Judging History
answer
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <fstream>
#include <time.h>
#include <unordered_map>
#include <cstdlib>
#include <string.h>
#include <bitset>
#include <unordered_set>
#include <cstdlib>
#include <string.h>
#include <cassert>
#define all(a) (a).begin(), (a).end()
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; ++i)
const int N = 2e5+7;
#ifdef DBGLOCAL
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> bool operator!(const T_container& container) {return !container.size();}
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;} void dbg_check() {cerr << endl;} int dbg_empty_check(int x) {return x;} string dbg_nested_idx;
template<typename T> int dbg_empty_check(const T& item) {if (!item) {return 0;} FOR(i, 0, N) {int out = dbg_empty_check(item[i]); if (out) { dbg_nested_idx += ' ' + to_string(i); return out;}} return 0;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
template<typename Head, typename... Tail> void dbg_check(Head H, Tail... T) { cerr << " ["; int out = dbg_empty_check(H); if(out) {reverse(dbg_nested_idx.begin(), dbg_nested_idx.end()); cerr << dbg_nested_idx << ": " << out; dbg_nested_idx.clear();} cerr << "]"; dbg_check(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#define dbgarr(arr,n) cerr << "(" << #arr << "): "; FOR(_, 0, n) cerr << arr[_] << " \n"[_==n-1];
#define dbgcheck(...) cerr << "Arrays (" << #__VA_ARGS__ << "):", dbg_check(__VA_ARGS__)
#else
#define dbg(...)
#define dbgarr(arr,n)
#define dbgcheck(...)
#endif
string BASE = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
string ask(vector<int> a, int D, int B){
string res;
for(int i = 0; i < D; ++i){
res += BASE[a[i]];
}
cout << res << endl;
cout.flush();
string s;
cin >> s;
return s;
}
void solve(int B, int D){
int quest = int(log2(B));
vector<vector<int> > pars(D, vector<int> (2));
for(int i = 0; i < D; ++i){
pars[i][0] = 0;
pars[i][1] = B;
}
for(int i = 0; i < quest+1; ++i){
vector<int> a(D, 0);
for(int j = 0; j < D; ++j){
a[j] = (pars[j][0] + pars[j][1]) / 2;
}
string res = ask(a, D, B);
if(res == "correct"){
return;
}
for(int j = 0; j < D; ++j){
if(res[j] == '-'){
pars[j][1] = a[j]-1;
}
else if(res[j] == '+'){
pars[j][0] = a[j]+1;
}
else if(res[j] == '='){
pars[j][1] = a[j];
pars[j][0] = a[j];
}
if (pars[j][0] > pars[j][1]) {
cout << "cheater\n";
cout.flush();
string s;
cin >> s;
return;
}
}
dbg(pars);
}
vector<int> a;
for(int i = 0; i < D; ++i){
a.push_back(pars[i][0]);
}
string res1 = ask(a, D, B);
if(res1 == "correct"){
return;
}
cout << "cheater\n";
cout.flush();
string s;
cin >> s;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int B, N;
cin >> B >> N;
while(N--){
int D;
cin >> D;
solve(B, D);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3580kb
input:
10 2 5 ----= -=++= +==+= correct 6 --++-+ =+-=-+ =+==== correct
output:
55555 22225 02335 12345 555555 228828 236809 246809
result:
ok correct (2 test cases)
Test #2:
score: 0
Accepted
time: 1ms
memory: 3852kb
input:
38 2 1 + + + + correct 3 --- +-= --= --= correct
output:
J T Y a b JJJ 999 E49 B19 A09
result:
ok correct (2 test cases)
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3632kb
input:
10 6 3 -++ --+ +-= correct 3 -=+ -++ correct 5 ++++= +=--= ==+=+ correct 4 ---- ==== ++++ correct 4 ++++ ++++ ==== correct 4 ==== ==== ==== ==== ====
output:
555 288 069 cheater 555 258 cheater 55555 88885 98665 cheater 5555 2222 2222 cheater 5555 8888 9999 9999 5555 5555 5555 5555 5555 cheater
result:
wrong answer Didn't get to correct answer in 5 guesses (test case 6)