QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#546636#7703. Base Hi-Lo GameOlegpresnyakov#TL 0ms0kbC++171.8kb2024-09-04 10:50:102024-09-04 10:50:11

Judging History

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

  • [2024-09-04 10:50:11]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-09-04 10:50:10]
  • 提交

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 ask(vector<int> a, int D, int B){
    string res;
    for(int i = 0; i < D; ++i){
        res += char(a[i] + '0');
    }

    cout << res << endl;
    cout.flush();

    string s;
    cin >> s;
    return s;
}

void solve(int B){
    int D;
    int quest = int(log(B));
    vector<vector<int> > pars(D, vector<int> (2));

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

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

        for(int j = 0; j < D; ++j){
            if(res[j] == '-'){
                pars[j][1] = a[j];
            }

            else if(res[j] == '+'){
                pars[j][0] = a[j];
            }

            else if(res[j] == '='){
                pars[j][1] = a[j];
                pars[j][0] = a[j];
            }
        }
    }

    vector<int> a;
    for(int i = 0; i < D; ++i){
        a.push_back(pars[i][0]);
    }

    string res1 = ask(a, D, B);
    string res2 = ask(a, D, B);

    if(res1 != res2){
        cout << "cheater\n";
    }
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int B, N;
    cin >> B >> N;
    while(N--){
        solve(B);
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

10 2
5

output:




result: