제출 #1336743

#제출 시각아이디문제언어결과실행 시간메모리
1336743darkdevilvaqif콤보 (IOI18_combo)C++20
100 / 100
8 ms536 KiB
/*
  _      __        __         __        ____                    ___    _                   __
 | | /| / / ___ _ / /_ ____  / /       / __ \  ___  ___        / _ \  (_) ___  ____ ___   / /
 | |/ |/ / / _ `// __// __/ / _ \     / /_/ / / _ \/ -_)      / ___/ / / / -_)/ __// -_) /_/ 
 |__/|__/  \_,_/ \__/ \__/ /_//_/     \____/ /_//_/\__/      /_/    /_/  \__/ \__/ \__/ (_)  
                                                                                             
*/

#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
// #pragma GCC target("avx2")
#include <bits/stdc++.h>
#include "combo.h"
#define ll long long
#define ull unsigned ll
#define ld long double
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define rsz resize
#define fi first
#define se second
#define LMAX LLONG_MAX
#define LMIN LLONG_MIN
#define IMAX INT_MAX
#define IMIN INT_MIN
// #define endl "\n"
#define newline cout << endl;
using namespace std;
 
// constants

// functions

// structs

// globals

// notes
/*
My favorite anime is One Piece(obviously)
My oshi(Yes, I have an oshi, deal with it) is Kamil_Tsubaki

 -stuff you should look for-
* int overflow, array bounds
* special cases (n=1?)
* do something instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH

continue - skip the rest in the loop
*/
 
string guess_sequence(int N)
{
    int n = N;
    
    auto ask = [&](string s)
    {
        int k = press(s);
        
        return k;
    };
    
    string res;
    if (ask("AB"))
    {
        if (ask("A"))
        {
            res = "A";
        }
        else
        {
            res = "B";   
        }
    }
    else
    {
        if (ask("X"))
        {
            res = "X";
        }
        else
        {
            res = "Y";
        }
    }
    if (n == 1)
    {
        return res;
    }
    
    vector <char> cs = {'A', 'B', 'X', 'Y'};
    cs.erase(find(all(cs), res[0]));
    for (int i = 1; i < n - 1; i++)
    {
        string tmp = res + cs[0];
        for (int j = 0; j < 3; j++)
        {
            tmp += res + cs[1] + cs[j];
        }
        
        int k = ask(tmp);
        if ((int)res.size() == k - 1)
        {
            res += cs[0];
        }
        else if ((int)res.size() == k - 2)
        {
            res += cs[1];
        }
        else
        {
            res += cs[2];
        }
    }
    
    for (int i = 0; i < 2; i++)
    {
        if (ask(res + cs[i]) == n)
        {
            res += cs[i];
            break;
        }
    }
    if ((int)res.size() != n)
    {
        res += cs[2];
    }
    
    return res;
}

/*
$$$$$$$$\ $$$$$$$$\ 
$$  _____|\____$$  |
$$ |          $$  / 
$$$$$\       $$  /  
$$  __|     $$  /   
$$ |       $$  /    
$$$$$$$$\ $$$$$$$$\ 
\________|\________|
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...