Submission #1092764

#TimeUsernameProblemLanguageResultExecution timeMemory
1092764TrinhKhanhDungCombo (IOI18_combo)C++14
5 / 100
1 ms348 KiB
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(x) (int)x.size()
#define ALL(v) v.begin(),v.end()
#define MASK(k) (1LL << (k))
#define BIT(x, i) (((x) >> (i)) & 1)
#define oo (ll)1e18
#define INF (ll)1e9
#define MOD (ll)(998244353)
#include "combo.h"

using namespace std;

template<class T1, class T2>
    bool maximize(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}

template<class T1, class T2>
    bool minimize(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}

template<class T1, class T2>
    void add(T1 &a, T2 b){a += b; if(a >= MOD) a -= MOD;}

template<class T1, class T2>
    void sub(T1 &a, T2 b){a -= b; if(a < 0) a += MOD;}

template<class T>
    void cps(T &v){sort(ALL(v)); v.resize(unique(ALL(v)) - v.begin());}

//int press(string p){
//    cout << p << endl;
//    int n; cin >> n;
//    return n;
//}

string guess_sequence(int N){
    const char buttons[] = {'A', 'B', 'X', 'Y'};
    string cur = "";

    int p = press("AB");
    if(p){
        if(press("A")) cur.push_back('A');
        else cur.push_back('B');
    }
    else{
        if(press("X")) cur.push_back('X');
        else cur.push_back('Y');
    }

    vector<char> buttonsLeft;
    for(int i = 0; i < 4; i++) if(cur[0] != buttons[i]){
        buttonsLeft.push_back(buttons[i]);
    }

    for(int i = 2; i < N; i++){
        string s = cur + buttonsLeft[0] + buttonsLeft[0] + cur + buttonsLeft[0] + buttonsLeft[1] + cur + buttonsLeft[0] + buttonsLeft[2] + cur + buttonsLeft[1];
        int coins = press(s);
        if(coins == i + 1) cur.push_back(buttonsLeft[0]);
        else if(coins == i) cur.push_back(buttonsLeft[1]);
        else cur.push_back(buttonsLeft[2]);
    }

    if(press(cur + buttonsLeft[0]) == N) cur.push_back(buttonsLeft[0]);
    else if(press(cur + buttonsLeft[1]) == N) cur.push_back(buttonsLeft[1]);
    else cur.push_back(buttonsLeft[2]);

    return cur;
}

//int main(){
//    ios_base::sync_with_stdio(0); cin.tie(0);
////     freopen("durian.inp","r",stdin);
////     freopen("durian.out","w",stdout);
//
//    cout << guess_sequence(5);
//
//    return 0;
//}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...