QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#546700#7703. Base Hi-Lo GameOlegpresnyakov#AC ✓1ms3916kbC++172.2kb2024-09-04 11:50:362024-09-04 11:50:39

Judging History

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

  • [2024-09-04 11:50:39]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3916kb
  • [2024-09-04 11:50:36]
  • 提交

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;

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));
    vector<int> fixed(D, 0);
    string help = "";
    for(int i = 0; i < D; ++i){
        help += '=';
    }

    for(int i = 0; i < D; ++i){
        pars[i][0] = 0;
        pars[i][1] = B-1;
    }

    for(int i = 0; i < quest+2; ++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;
        }

        if(res == help){
            cout << "cheater\n";
            cout.flush();
            string s;
            cin >> s;
            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;
            }
        }
    }
}


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

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: 1ms
memory: 3604kb

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

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: 1ms
memory: 3916kb

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

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

input:

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

output:

33
55
44
33
55
44

result:

ok correct (2 test cases)