QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#876331 | #7703. Base Hi-Lo Game | LaVuna47# | RE | 0ms | 3712kb | C++20 | 2.5kb | 2025-01-30 19:59:25 | 2025-01-30 19:59:27 |
Judging History
answer
//A tree without skin will surely die.
//A man without face is invincible.
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, st_, n) for(int i = st_; i < n; ++i)
#define RFOR(i, n, end_) for(int i = (n)-1; i >= end_; --i)
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
string guess(const string& val)
{
cout<<val<<endl;
string resp;
cin>>resp;
return resp;
}
vector<char> V;
char to_dig(int num)
{
return V[num];
}
int solve()
{
FOR(i,0,10)V.pb(char('0'+i));
FOR(i,'A','Z'+1)V.pb(char(i));
FOR(i,'a','z'+1)V.pb(char(i));
int B, T;
cin >> B >> T;
FOR(_,0,T)
{
int D;
cin >> D;
vector<int> L(D,0);
vector<int> R(D,B);
vector<int> M(D,-1);
while(true)
{
FOR(i,0,D)
{
M[i]=(L[i]+R[i])/2;
}
string query;
FOR(i,0,D)query += to_dig(M[i]);
string resp = guess(query);
if(resp=="correct")
{
break;
}
else
{
bool lie=false;
FOR(i,0,D)
{
if(L[i]==R[i] && resp[i]!='=')
{
lie=true;
break;
}
if(resp[i]=='+')
{
L[i]=M[i]+1;
}
else if(resp[i]=='-')
{
R[i]=M[i]-1;
}
else
{
L[i]=R[i]=M[i];
}
if((R[i]>=B+1) || L[i] < 0 || L[i] > R[i])
{
lie=true;
break;
}
}
if(lie)
{
cout<<"cheater"<<endl;
cin>>resp;
assert(resp=="correct");
break;
}
}
}
}
return 1;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int TET = 1e9;
//cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
{
break;
}
#ifdef ONPC
cout << "__________________________" << endl;
#endif
}
#ifdef ONPC
cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3712kb
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: 0ms
memory: 3712kb
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
Runtime Error
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 5555