Submission #1104900

#TimeUsernameProblemLanguageResultExecution timeMemory
1104900monaxiaCombo (IOI18_combo)C++17
100 / 100
31 ms1800 KiB
#include <bits/stdc++.h>
#include "combo.h"
#define pb push_back
#define ppb pop_back
#define fr first
#define sc second
#define all(v) v.begin(), v.end()
#define eps (long long)(1e-9)

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;

const ll Mod = 1e9 + 7;

// string S = "Y";
// int N = S.size();

// int press(string p) {
//   int coins = 0;
//   int len = p.length();

//   for (int i = 0, j = 0; i < len; ++i) {
//     if (j < N && S[j] == p[i]) {
//       ++j;
//     } else if (S[0] == p[i]) {
//       j = 1;
//     } else {
//       j = 0;
//     }
//     coins = max(coins, j);
//   }
//   return coins;
// }

string guess_sequence(int n){
    string ans = "", temp = "ABXY";
    char ex = 'S';
    int cnt = 1;

    if(press("AB")){
        if(press("A")) ex = 'A';
        else ex = 'B';
    }

    else if(press("X")) ex = 'X';
    else ex = 'Y';

    ans.pb(ex);

    string newtemp = "";

    for(auto& x : temp) if(x != ex) newtemp.pb(x);

    while(cnt < n - 1){
        string uhh = ans;
        uhh.pb(newtemp[0]);
        uhh += ans;
        uhh.pb(newtemp[1]);
        uhh.pb(newtemp[0]);
        uhh += ans;
        uhh.pb(newtemp[1]);
        uhh.pb(newtemp[1]);
        uhh += ans;
        uhh.pb(newtemp[1]);
        uhh.pb(newtemp[2]);

        int val = press(uhh);

        if(val == cnt) ans.pb(newtemp[2]);
        if(val == cnt + 2) ans.pb(newtemp[1]);
        if(val == cnt + 1) ans.pb(newtemp[0]);

        cnt ++;
    }

    if(cnt == n) return ans;

    string uhh = ans;                      
    uhh.pb(newtemp[0]);
    uhh += ans;
    uhh.pb(newtemp[1]);

    if(press(uhh) - cnt >= 1){
        uhh = ans;
        uhh.pb(newtemp[0]);
        if(press(uhh) - cnt == 1) ans.pb(newtemp[0]);
        else ans.pb(newtemp[1]);
    }

    else ans.pb(newtemp[2]);

    return ans;
}   

// void solve(){
//     cout << guess_sequence(S.size());
// }

// signed main()
// {
//     cin.tie(0)->sync_with_stdio(0);
 
//     if(fopen("blank.inp", "r")){
//         freopen("blank.inp", "r", stdin);
//         freopen("blank.out", "w", stdout);
//     }
    
//     // cout << 1; return 0;

//     ll n = 1;

//     // cin >> n;

//     while(n) {
//         solve();
//         n --;
//         cout << "\n";
//     }
 
//     // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
// }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...