QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#697293#7703. Base Hi-Lo GameBackToSquare1AC ✓1ms3800kbC++202.6kb2024-11-01 12:49:042024-11-01 12:49:04

Judging History

你现在查看的是最新测评结果

  • [2024-11-01 12:49:04]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3800kb
  • [2024-11-01 12:49:04]
  • 提交

answer

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> pl;
typedef pair<ld,ld> pd;
typedef vector<ll> vl;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
 
#define G(x) ll x; cin >> x;
#define F(i, l, r) for (ll i = l; i < (r); ++i)
#define all(a) begin(a), end(a)
#define K first
#define V second
#define OK(i,j) i >= 0 && i < n && j >= 0 && j < m
 
#define NN 2000005
#define MM 5005
#define MOD 1000000007

ll B;
map<char,ll> m;
map<ll,char> mm;

void solve() {

    ll n;
    cin >> n;
    ll minVal[n], maxVal[n], my_guess[n];
    bool solved[n];
    for(ll i = 0;i<n;i++){
        minVal[i] = 0;
        maxVal[i] = B-1;
        solved[i] = 0;
    }

    ll numGuess = (ll)(log2(B)) + 2;
    for(ll i=0;i<numGuess;i++) {
        string guess = "", response;
        for(ll j=0;j<n;j++) {
            my_guess[j] = (maxVal[j] + minVal[j])/2;
            guess += mm[my_guess[j]];
        }
        cout << guess << '\n';
        cout.flush();
        cin >> response;

        if(response == "correct") {
            break;
        }

        bool ok = 1;
        ll solvedCount = 0;

        for(ll j=0;j<n;j++) {
            if(response[j] == '-') {
                maxVal[j] = my_guess[j] - 1;
                if(solved[j]) ok = 0;
            }
            else if(response[j] == '+') {
                minVal[j] = my_guess[j] + 1;
                if(solved[j]) ok = 0;
            }
            else {
                solved[j] = 1;
                minVal[j] = my_guess[j];
                maxVal[j] = my_guess[j];
                solvedCount++;
            }

            if(maxVal[j] < minVal[j]) ok = 0;
        }

        if(solvedCount == n) ok = 0;

        if(!ok) {
            cout << "cheater\n";
            cout.flush();
            cin >> response;
            break;
        }
    }

}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cout << fixed << setprecision(10);

    ll t;
    cin >> B >> t;

    for(ll i=0;i<min(10ll,B);i++) {
        mm[i] = (char)(i + '0');
    }

    for(ll i=10;i<min(36ll,B);i++) {
        mm[i] = (char)(i-10 + 'A');
    }

    for(ll i=36;i<min(62ll,B);i++) {
        mm[i] = (char)(i-36 + 'a');
    }

    for(auto x : mm) {
        m[x.V] = x.K;
    }

    while(t--)
        solve();

    return 0;

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3800kb

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

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

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

input:

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

output:

UUUU
cheater
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
cheater

result:

ok correct (2 test cases)

Test #5:

score: 0
Accepted
time: 1ms
memory: 3612kb

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
cheater
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: 3656kb

input:

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

output:

33
55
44
33
55
44

result:

ok correct (2 test cases)