QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#876415#7703. Base Hi-Lo GameWeaRD276#WA 0ms3840kbC++203.4kb2025-01-30 21:04:152025-01-30 21:04:23

Judging History

This is the latest submission verdict.

  • [2025-01-30 21:04:23]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3840kb
  • [2025-01-30 21:04:15]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;

#include  <ext/pb_ds/assoc_container.hpp>
#include  <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef double db;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;

string alf = "";

void pre()
{
	for (char ch = '0'; ch <= '9'; ch++)
		alf += ch;
	for (char ch = 'A'; ch <= 'Z'; ch++)
		alf += ch;
	for (char ch = 'a'; ch <= 'z'; ch++)
		alf += ch;
}

string ask(string num)
{
	cout << num << endl;
	string resp;
	cin >> resp;
	return resp;
}

int solve(int b)
{	
	string al = alf.substr(0, b);
	//int m = sz(al);
	int d;
	cin >> d;
	vector<int> mxs(d, b);
	vector<int> mns(d, -1);
	vector<int> know(d, -1);
	int lg = log2(b);
	while (lg--)
	{
		string str = "";
		FOR (i, 0, d)
		{
			int mid = (mxs[i] + mns[i]) / 2;
			str += al[mid];
		}
		string resp = ask(str);
		if (resp == "correct")
		{
			return 0;
		}
		if (sz(resp) != d)
		{
			cout << "cheater" << endl;
			return 0;
		}
		//assert(sz(resp) == d);
		FOR (i, 0, d)
		{
			int mn = mns[i], mx = mxs[i];
			int mid = (mn + mx) / 2;
			
			if (resp[i] == '=')
			{
				if (know[i] != -1 && know[i] != mid)
				{
					cout << "cheater" << endl;
					return 0;
				}
				know[i] = mid;
				mns[i] = mxs[i] = mid;
			}
			else if (resp[i] == '+')
			{	
				if (know[i] != -1)
				{
					cout << "cheater" << endl;
					return 0;
				}
				mns[i] = mid;
			}
			else if (resp[i] == '-')
			{
				if (know[i] != -1)
				{
					cout << "cheater" << endl;
					return 0;
				}
				mxs[i] = mid;
			}
			else
			{
				cout << "cheater" << endl;
				return 0;
			}
			//assert(false);
		}
	}
	
	string str = "";
	FOR (i, 0, d)
	{
		if (know[i])
			str += al[know[i]];
		else
		{
			int mid = (mxs[i] + mns[i]) / 2;
			str += al[mid];
		}
	}
	string resp = ask(str);
	FOR (i, 0, d)
	{
		int mid = (mxs[i] + mns[i]) / 2;
		if (resp[i] == '=')
		{
			if (know[i] != -1 && know[i] != mid)
			{
				cout << "cheater" << endl;
				return 0;
			}
			know[i] = mid;
			mns[i] = mxs[i] = mid;
		}
		else if (resp[i] == '+')
		{	
			if (know[i] != -1)
			{
				cout << "cheater" << endl;
				return 0;
			}
			know[i] = mxs[i];
		}
		else if (resp[i] == '-')
		{
			if (mxs[i] - mns[i] == 1)
			{
				cout << "cheater" << endl;
				return 0;
			}
			if (know[i] != -1)
			{
				cout << "cheater" << endl;
				return 0;
			}
			know[i] = mns[i];
		}
		else
		{
			cout << "cheater" << endl;
			return 0;
		}
	}
	str = "";
	FOR (i, 0, d)
		str += al[know[i]];
	
	resp = ask(str);
	
	return 0;
}

int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	pre();
	int TET = 1e9;
	int b;
	cin >> b >> TET;
	for (int i = 1; i <= TET; i++)
	{
		if (solve(b))
		{
			break;
		}
		#ifdef ONPC
			cerr << "_____________________________\n";
		#endif
	}
	#ifdef ONPC
		cerr << "\nfinished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
	#endif
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3840kb

input:

10 2
5
---=+
=++=-
==+==

output:

44444
11147
12245
12

result:

wrong answer Invalid digit (test case 1)