제출 #550477

#제출 시각아이디문제언어결과실행 시간메모리
550477AJ00콤보 (IOI18_combo)C++14
97 / 100
39 ms576 KiB
#include "combo.h"
#include <bits/stdc++.h>
 
using namespace std;
int n;
string guess_sequence(int N){
    n = N;
    string ans;
    char temp;
    if (press("AB")){
        temp = press("A") ? 'A' : 'B';
    }
    else {
        temp = press("X") ? 'X' : 'Y';
    }
    ans.push_back(temp);
  	if (n == 1){
       return ans;
    }
 //   cout << ans << "\n";
    vector<char> pos;
    if (temp != 'A'){
        pos.push_back('A');
    }
    if (temp != 'B'){
        pos.push_back('B');
    }
    if (temp != 'X'){
        pos.push_back('X');
    }
    if (temp != 'Y'){
        pos.push_back('Y');
    }
    for (int i = 1; i < n-1; i++){
        string cur;
        for (int j = 0; j < 3; j++){
            cur += ans+pos[0]+pos[j];
        }
        cur += ans+pos[1];
        int uwu = press(cur);
        //cout << cur << " " << uwu << " ";
        if (uwu == i+2){
            ans.push_back(pos[0]);
        }
        if (uwu == i+1){
            ans.push_back(pos[1]);
        }
        if (uwu == i){
            ans.push_back(pos[2]);
        }
        //cout << ans << "\n";
    }
    for (int i = 0; i < 3; i++){
        if (press(ans+pos[i]) >= n){
            temp = pos[i];
            break;
        }
    }
    ans.push_back(temp);
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...