Submission #484862

#TimeUsernameProblemLanguageResultExecution timeMemory
484862MohamedFaresNebiliCombo (IOI18_combo)C++14
5 / 100
2 ms200 KiB
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#include "combo.h"

        using namespace std;

        using ll  = long long;
        using vi  = vector<int>;

        #define pb push_back
        #define ff first
        #define ss second
        #define lb lower_bound
        #define all(x) (x).begin() , (x).end()

        string p = "", lett = "ABXY"; int n;
        void solve(int i, int first) {
            if(i == n - 1) {
				p+="x";
                for(int l = 0; l < 2; l++) {
                    if(l == first) continue;
                    p[i] = lett[l];
                    if(press(p) == n) return;
                }
                if(first == 2) {
                    p[i] = lett[3];
                    return;
                }
                else if(first == 3) {
                    p[i] = lett[2];
                    return;
                }
                else {
                    p[i] = lett[2];
                    if(press(p) == n) return;
                    p[i] = lett[3]; return;
                }
				return;
            }
            vector<char>ch;
            for(int l = 0; l < 4; l++) {
                if(l == first) continue;
                ch.pb(lett[l]);
            }
			string s = "";
            for(auto u: ch) s+=p+ch[0]+u;
            s += p; s+=ch[1];
			p+="x";
            if(press(s) == i + 1) p[i] = ch[1];
            else if(press(s) >= i + 2) p[i] = ch[0];
            else p[i] = ch[2];
            solve(i+1, first);
        }

		string guess_sequence(int N) {
            int first = -1; n = N;
            for(int l = 0; l < 3; l++) {
              	p = "";
                for (int i = 0; i < N; ++i) p += lett[l];
                int u = press(p);
                if(u) {
                    first = l; p = lett[l];
                    break;
                }
            }
            if(first == -1) { first = 3; p = lett[3]; }
 			solve(1, first);
            return p;
        }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...