Submission #1141977

#TimeUsernameProblemLanguageResultExecution timeMemory
1141977zaki98Combo (IOI18_combo)C++20
0 / 100
0 ms408 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
// i think the N + 2 sol uses 2 for finding out the first char.
//int press(string s) {
//    int a;
//    cout << s << ": ";
//    cin >> a;
//    cout << endl;
//    return a;
//}
string guess_sequence(int N) {
    // ill find it using 2 preses
    string first;
    int resul;
    vector<string> chars(N, "?");
    string finalist_string;
    int first_press = press("XY");
    if (first_press == 2) {
    chars[0] = "X";
    }
    else if (first_press == 1) {
    if (press("X") == 1) {
    chars[0] = "X";
    }
    else {
    chars[0] = "Y";
    }
    }
    else {
    if (press("A") == 1) {
    chars[0] = "A";
    }
    else {
    chars[0] = "B";
    }
    }
    string first_char = chars[0];
    finalist_string += first_char;
    // cout << finalist_string << " is the first char !" << endl;
    vector<string> possible = {"A", "B", "X", "Y"};
    auto it = find(possible.begin(), possible.end(), first_char);
    if(it != possible.end())
        possible.erase(it);
    // no need lolo i think.
    for (int j = 0; j < N - 1; j++) {
    string send = "";
    for (int i = 0; i < 3; i++) {
    send += finalist_string + possible[0] + possible[i]; // returns j + 3 if its possible 0
    }
    send += finalist_string + possible[1]; // returns j + 2 if its possible 1
    resul = press(send);
    if (resul == j + 3) {finalist_string += possible[0];}
    else if (resul == j + 2) {finalist_string += possible[1];}
    else {finalist_string += possible[2];}
    }
    return finalist_string;
    // we cannot use this goofy ahh approach with the last one, so we will do it just like the first one.
//    resul = press(finalist_string + possible[0]);
//    if (resul == N) {
//    return finalist_string + possible[0];
//    }
//    resul = press(finalist_string + possible[1]);
//    if (resul == N) {return finalist_string + possible[1];}
//    return finalist_string + possible[2];
}


#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...