Submission #143557

#TimeUsernameProblemLanguageResultExecution timeMemory
143557mat_vCombo (IOI18_combo)C++14
97 / 100
57 ms692 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

string guess_sequence(int N) {
    string a = "A";
    string b = "B";
    string x = "X";
    int prvi = press(a);
    int drug = press(b);
    int trec = press(x);
    string tren;
    if(prvi)tren = "A";
    else if(drug)tren = "B";
    else if(trec)tren = "X";
    else tren = "Y";
    string d,t,c;
    if(tren == "A"){
        d = "X";
        t = "Y";
        c = "B";
    }
    else if(tren == "B"){
        d = 'X';
        t = 'Y';
        c = 'A';
    }
    else if(tren == "X"){
        d = 'A';
        t = 'Y';
        c = 'B';
    }
    else if(tren == "Y"){
        d = 'X';
        t = 'A';
        c = 'B';
    }

    for(int i=1; i<N; i++){
        if(i == N-1){
            string frs = tren;
            frs += d;
            string frs2 = tren;
            frs2 += t;
            int sta = press(frs);
            int sta2 = press(frs2);
            if(sta > sta2)tren += d;
            else if(sta2 > sta)tren += t;
            else tren += c;
            continue;
        }
        string frs = tren;
        frs += d;
        string sek1 = tren,sek2 = tren,sek3 = tren;
        string pom1 = t;
        pom1 += t;
        string pom2 = t;
        pom2 += d;
        string pom3 = t;
        pom3 += c;
        sek1 += pom1;
        sek2 += pom2;
        sek3 += pom3;
        frs += sek1;
        frs += sek2;
        frs += sek3;
        int sta = press(frs);
        if(sta == tren.size())tren += c;
        else if(sta == tren.size() + 1)tren += d;
        else tren += t;

    }
    //cout << tren << endl;
    return tren;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:68:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |         if(sta == tren.size())tren += c;
      |            ~~~~^~~~~~~~~~~~~~
combo.cpp:69:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |         else if(sta == tren.size() + 1)tren += d;
      |                 ~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...