Submission #835221

#TimeUsernameProblemLanguageResultExecution timeMemory
835221JoksimKaktusCombo (IOI18_combo)C++17
97 / 100
22 ms584 KiB
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <set>
#include <cassert>
#include <cstdio>
#include <string>
#include "combo.h"
 
using namespace std;
 
string guess_sequence(int N){
    string s = "";
    vector <string> s0(4);
    s0[0] = "A";s0[1] = "B";s0[2] = "X";s0[3] = "Y";
    vector <string> v(3);
    for(int i = 0;i < 3;i++){
        if(press(s+s0[i]) == 1){
            s += s0[i];
            int ind = 0;
            for(int j = 0;j < 4;j++){
                if(j == i){
                    continue;
                }
                v[ind] = s0[j];
                ind++;
            }
            break;
        }
    }
    if(s == ""){
        s += s0[3];
        v[0] = "A";
        v[1] = "B";
        v[2] = "X";
    }
    int lenght = 1;
    string p = "";
    while(lenght < N-1){
        p = "";
        p += s + v[0];
        for (int j = 0; j < 3; ++j)
            p += s + v[1] + v[j];
        int k = press(p);
        if(k == lenght){
            s += v[2];
            lenght++;
        }else if(k == lenght + 1){
            s += v[0];
            lenght++;
        }else if(k == lenght + 2){
            s += v[1];
            lenght++;
        }
    }
  if((int)s.size() == N){
    return s;
  }
  bool found = false;
    for(int i = 0;i < 2;i++){
        if(press(s+v[i]) > lenght){
            s += v[i];
          found = true;
            break;
        }
    }
  if(!found){
    s+= v[2];
  }
    return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...