QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#877702#7703. Base Hi-Lo GameWeaRD276AC ✓1ms3584kbC++202.5kb2025-02-01 01:09:312025-02-01 01:09:32

Judging History

This is the latest submission verdict.

  • [2025-02-01 01:09:32]
  • Judged
  • Verdict: AC
  • Time: 1ms
  • Memory: 3584kb
  • [2025-02-01 01:09:31]
  • 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 ful = "";

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

string ask(const string& str)
{
	cout << str << endl;
	string resp;
	cin >> resp;
	return resp;
}

int solve(int b)
{
	string alf = ful.substr(0, b);
	int d;
	cin >> d;
	string bad(d, '=');
	vector<int> L(d, 0), R(d, b - 1);
	while (1)
	{
		string str = "";
		FOR (i, 0, d)
		{
			int mid = (L[i] + R[i]) / 2;
			str += alf[mid];
		}
		string resp = ask(str);
		if (resp == "correct")
			return 0;
		if (resp == bad || sz(resp) != d || L == R)
		{
			str = "cheater";
			resp = ask(str);
			assert(resp == "correct");
			return 0;
		}
		
		FOR (i, 0, d)
		{
			int mid = (L[i] + R[i]) / 2;
			if (resp[i] == '=')
			{
				L[i] = R[i] = mid;
			}
			else if (resp[i] == '+')
			{
				if (mid == b - 1 || L[i] == R[i])
				{
					str = "cheater";
					resp = ask(str);
					assert(resp == "correct");
					return 0;
				}
				L[i] = mid + 1;
			}
			else if (resp[i] == '-')
			{
				if (mid == 0 || L[i] == R[i])
				{
					str = "cheater";
					resp = ask(str);
					assert(resp == "correct");
					return 0;
				}
				R[i] = mid - 1;
			}
			else
			{
				str = "cheater";
				resp = ask(str);
				assert(resp == "correct");
				return 0;
			}
		}
	}
	
	return 0;
}

int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	pre();
	int TET = 1e9;
	int base;
	cin >> base >> TET;
	for (int i = 1; i <= TET; i++)
	{
		if (solve(base))
		{
			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: 100
Accepted
time: 1ms
memory: 3584kb

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: 3584kb

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: 0
Accepted
time: 1ms
memory: 3584kb

input:

10 6
3
--+
=++
=++
=+=
correct
3
-++
==+
=-+
correct
5
+++++
++=--
+==++
====-
correct
4
----
====
correct
4
++++
++++
====
correct
4
====
correct

output:

444
117
128
139
cheater
444
177
178
cheater
44444
77777
88755
98766
cheater
4444
1111
cheater
4444
7777
8888
cheater
4444
cheater

result:

ok correct (6 test cases)

Test #4:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

62 2
4
====
correct
64
================================================================
correct

output:

UUUU
cheater
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
cheater

result:

ok correct (2 test cases)

Test #5:

score: 0
Accepted
time: 0ms
memory: 3456kb

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
14
cheater
44
14
cheater
44
14
cheater
44
14
cheater
44
17
15
14
44
11
12
13
cheater
44
11
12
13
cheater
44
11
12
13
cheater
44
11
12
13
cheater
44
11
12
13
cheater

result:

ok correct (10 test cases)

Test #6:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

8 2
2
++
--
correct
2
++
--
correct

output:

33
55
44
33
55
44

result:

ok correct (2 test cases)