Submission #1250972

#TimeUsernameProblemLanguageResultExecution timeMemory
1250972SoMotThanhXuanCombo (IOI18_combo)C++20
0 / 100
0 ms424 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define REP(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define mp make_pair
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define Bit(x, i) ((x >> (i)) & 1)
#define Mask(i) (1 << (i))
#define Cnt(x) __builtin_popcount(x)
#define Cntll(x) __builtin_popcountll(x)
#define Ctz(x) __builtin_ctz(x) // so luong so 0 tinh tu ben phai
#define Ctzll(x) __builtin_ctzll(x)
#define Clz(x) __builtin_clz(x) // so luong so 0 tinh tu ben trai
#define Clzll(x) __builtin_clzll(x)
inline bool maximize(int &u, int v){
    return v > u ? u = v, true : false;
}
inline bool minimize(int &u, int v){
    return v < u ? u = v, true : false;
}
inline bool maximizell(long long &u, long long v){
    return v > u ? u = v, true : false;
}
inline bool minimizell(long long &u, long long v){
    return v < u ? u = v, true : false;
}
const int mod = 1e9 + 7;
inline int fastPow(int a, int n){
    if(n == 0) return 1;
    int t = fastPow(a, n >> 1);
    t = 1ll * t * t % mod;
    if(n & 1) t = 1ll * t * a % mod;
    return t;
}
inline void add(int &u, int v){
    u += v;
    if(u >= mod) u -= mod;
}
inline void sub(int &u, int v){
    u -= v;
    if(u < 0) u += mod;
}
const int maxN = 2e5 + 5;
const int inf = 1e9;
const long long infll = 1e18;
//string ords;
//int N;
//int press(string p){
//    int answer = 0;
//    for(int t = 0; t < p.size(); ++t){
//        int j = t, i = 0;
//        while(j < p.size() && i < N && ords[i] == p[j]){
//            ++i;
//            ++j;
//        }
//        maximize(answer, j - t);
//    }
//    return answer;
//}
char c[] = {'A', 'B', 'X', 'Y'};
string t[] = {"A", "B", "X", "Y"};
string guess_sequence(int n){
    string s = "";
    char ban = 'Z';
    int cnt = 0;
    FOR(i, 0, 2){
//        ++cnt;
        if(press(t[i]) == 1){
            s = t[i];
            ban = c[i];
            break;
        }
    }
    if(ban == 'Z') s = t[3], ban = c[3];
    if(n == 1) return s;
    FOR(i, 1, n - 1) s += 'Z';
    FOR(i, 1, n - 1){
        vector<char> imp;
        FOR(j, 0, 3){
            if(c[j] == s[i - 1] || c[j] == s[0]) continue;
            imp.emplace_back(c[j]);
        }
        ban = 'Z';
        for(int j = 0; j < (int)imp.size() - 1; ++j){
//            ++cnt;
            FOR(t, i, n - 1)s[t] = imp[j];
            int x = press(s);
            assert(x >= i);
            if(x > i){
                FOR(t, i, x - 1)s[i] = imp[j];
                ban = imp[j];
                break;
            }
        }
        if(ban == 'Z'){
//            ++cnt;
            FOR(t, i, n - 1)s[t] = imp.back();
            int x = press(s);
            assert(x > i);
            i = x - 1;
            ban = imp.back();
        }
    }
//    cout << cnt << '\n';
    return s;
}
//void process(){
//    cin >> ords;
//    N = ords.size();
//    string answer = guess_sequence(N);
//    cout << ords << '\n' << answer;
//}
//#define LOVE ""
//int main(){
//    if(fopen(LOVE".inp", "r")){
//        freopen(LOVE".inp", "r", stdin);
//        freopen(LOVE".out", "w", stdout);
//    }
//    ios_base::sync_with_stdio(false);
//    cin.tie(0);
//    cout.tie(0);
//
//    int t = 1;
////    cin >> t;
//    while(t--)
//        process();
////    cerr << '\n' << "Time elapsed: " << (1.0 * clock() / CLOCKS_PER_SEC) << " s\n" ;
//    return 0;
//}




#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...