Submission #990140

#TimeUsernameProblemLanguageResultExecution timeMemory
990140hasan2006Combo (IOI18_combo)C++17
0 / 100
1 ms344 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

#define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define rall(s) s.rbegin(),s.rend()
#define all(s) s.begin(),s.end()
#define pb push_back
#define se second
#define fi first
#define ll long long
#define ld long double
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define yes cout<<"yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
#define no cout<<"no\n"


//const int N = 5e5 + 9 , mod = 1e9 + 7;
//ll a[N] , b[N] , dp[N] , c[N] , d[N];

//int press(string a){}

std::string guess_sequence(int n){
    using namespace std;
    string v[4] = {"A" , "B" , "X" , "Y"};
    if(n == 1){
        for(auto to : v)
            if(to == "Y" || press(to))
                return to;
    }
    string b;
    if(press("AB")){
        b = (press("A") ? "A" : "B");
    }else{
        b = (press("X") ? "X" : "Y");
    }
    vector<string>vc;
    for(auto to : v)
        if(to != b)
           vc.pb(to);
    for(int i = 1; i < n - 1; i++){
        string a = b+ vc[0] + vc[0] + b + vc[0] + vc[1] + b + vc[0] +  vc[2] + b + vc[1];
        if(press(a) == i + 2)
            b += vc[0];
        else if(press(a) == i + 1)
            b += vc[1];
        else
            b += vc[2];
    }
    if(press(b + vc[0] + vc[1]) != n)
        b = ((press(b + vc[0]) == n)  ? vc[0] : vc[1]);
    else
        b += vc[2];
}

/*
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    guess_sequence(2);
}*/
// Author : حسن

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:58:1: warning: control reaches end of non-void function [-Wreturn-type]
   58 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...