Submission #1297994

#TimeUsernameProblemLanguageResultExecution timeMemory
1297994alexiahCombo (IOI18_combo)C++20
100 / 100
9 ms560 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

string guess_sequence(int n){
  if(n == 1){
    string ans = "";
    int f1 , f2;
    f1 = press("AX"); f2 = press("AB");
    if(f1 >= 1 && f2 >= 1) ans += 'A';
    else if(f1 == 1 && f2 == 0) ans += 'X';
    else if(f1 == 0 && f2 == 1) ans += 'B';
    else ans += 'Y';
    string ns1 = ans , ns2 = ans;
    return ans;
  }
  if(n == 2){
    string ans = "" , opc;
    int f1 , f2;
    f1 = press("AX"); f2 = press("AB");
    if(f1 >= 1 && f2 >= 1) ans += 'A';
    else if(f1 == 1 && f2 == 0) ans += 'X';
    else if(f1 == 0 && f2 == 1) ans += 'B';
    else ans += 'Y';
    if(ans[0] == 'A') opc = "BXY";
    else if(ans[0] == 'B') opc = "AXY";
    else if(ans[0] == 'X') opc = "ABY";
    else opc = "ABX";
    string ns1 = ans , ns2 = ans;
    ns1 += opc[0]; ns2 += opc[1];
    int l1 , l2;
    l1 = press(ns1); l2 = press(ns2);
    if(l1 == n) ans += opc[0];
    else if(l2 == n) ans += opc[1];
    else ans += opc[2];
    return ans;
  }
  if(n == 3){
    string ans = "" , opc;
    int f1 , f2;
    f1 = press("AX"); f2 = press("AB");
    if(f1 >= 1 && f2 >= 1) ans += 'A';
    else if(f1 == 1 && f2 == 0) ans += 'X';
    else if(f1 == 0 && f2 == 1) ans += 'B';
    else ans += 'Y';
    if(ans[0] == 'A') opc = "BXY";
    else if(ans[0] == 'B') opc = "AXY";
    else if(ans[0] == 'X') opc = "ABY";
    else opc = "ABX";
    string aux;
    aux = (ans + opc[0] + opc[0]) + (ans + opc[0] + opc[1]) + (ans + opc[0] + opc[2]) + (ans + opc[1]);
    int act = press(aux);
    if(act == 3) ans += opc[0];
    else if(act == 2) ans += opc[1];
    else ans += opc[2];
    string ns1 = ans , ns2 = ans;
    ns1 += opc[0]; ns2 += opc[1];
    int l1 , l2;
    l1 = press(ns1); l2 = press(ns2);
    if(l1 == n) ans += opc[0];
    else if(l2 == n) ans += opc[1];
    else ans += opc[2];
    return ans;
  }
  else{
    string ans = "" , opc;
    int f1 , f2;
    f1 = press("AX"); f2 = press("AB");
    if(f1 >= 1 && f2 >= 1) ans += 'A';
    else if(f1 == 1 && f2 == 0) ans += 'X';
    else if(f1 == 0 && f2 == 1) ans += 'B';
    else ans += 'Y';
    if(ans[0] == 'A') opc = "BXY";
    else if(ans[0] == 'B') opc = "AXY";
    else if(ans[0] == 'X') opc = "ABY";
    else opc = "ABX";
    for(int i = 1; i < n-1; i++){
      string aux;
      aux = (ans + opc[0] + opc[0]) + (ans + opc[0] + opc[1]) + (ans + opc[0] + opc[2]) + (ans + opc[1]);
      int act = press(aux);
      if(act == i + 2) ans += opc[0];
      else if(act == i + 1) ans += opc[1];
      else ans += opc[2];
    }
    string ns1 = ans , ns2 = ans;
    ns1 += opc[0]; ns2 += opc[1];
    int l1 , l2;
    l1 = press(ns1); l2 = press(ns2);
    if(l1 == n) ans += opc[0];
    else if(l2 == n) ans += opc[1];
    else ans += opc[2];
    return ans;
  }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...