Submission #1104882

#TimeUsernameProblemLanguageResultExecution timeMemory
1104882monaxiaCombo (IOI18_combo)C++17
30 / 100
47 ms1456 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 = "YB";
// 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 = 0;

    for(int i = 0; i < 3; i ++){
        char x = temp[i];

        ans.pb(x);
        if(press(ans) > cnt){
            cnt ++;
            break;
        }

        ans.ppb();
    }

    if(!cnt) ex = 'Y', cnt ++, ans.pb('Y');
    else ex = ans[0];

    string newtemp = "";

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

    while(cnt != n){
        bool yeye = 0;
        for(int i = 0; i < 2; i ++){
            char x = newtemp[i];

            ans.pb(x);
            if(press(ans) > cnt){
                yeye = 1;
                cnt ++;
                break;
            }

            ans.ppb();
        }

        if(!yeye) ans.pb(newtemp[2]), cnt ++; 
    }

    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...