제출 #140268

#제출 시각아이디문제언어결과실행 시간메모리
140268Runtime_error_콤보 (IOI18_combo)C++14
100 / 100
43 ms592 KiB

#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string guess_sequence(int N) {

    vector<char>v;
    string ans = "";
    if( press("AB") )
        ans += ( press("A") ? 'A' : 'B' );
    else
        ans += ( press("X") ? 'X' : 'Y');

    if(ans[0] != 'A')
        v.push_back('A');
    if(ans[0] != 'B')
        v.push_back('B');
    if(ans[0] != 'X')
        v.push_back('X');
    if(ans[0] != 'Y')
        v.push_back('Y');

    if(N == 1)
        return ans;
    for(int i=2;i<N;i++){
        string tmp = ans+v[0] + ans+v[1]+v[0] + ans+v[1]+v[1] + ans+v[1]+v[2];
        int res = press(tmp);
        if( res == i-1 )
            ans += v[2];
        else if( res == i+1 )
            ans += v[1];
        else
            ans += v[0];
    }
    if( press( ans+v[0] ) == N )
        ans += v[0];
    else if( press( ans+v[1] ) == N)
        ans += v[1];
    else
        ans += v[2];
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...