Submission #549458

#TimeUsernameProblemLanguageResultExecution timeMemory
549458esomerCombo (IOI18_combo)C++17
0 / 100
64 ms208 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

/*string sss = "LOL";

mt19937 gen(time(0));

int presss(string s){
    int mx = 0;
    for(int i = 0; i < s.size(); i++){
        for(int j = 1; j <= s.size() - i; j++){
            if(s.substr(i, j) == sss.substr(0, j)) mx = max(mx, j);
        }
    }
    return mx;
    cout << s << endl;
    int rep; cin >> rep;
    return rep;
}*/

string guess_sequence(int N) {
  string ans = "";
  vector<string> pos;
  int x = press("XY"); //
  if(x == 2) {ans += "XY"; pos = {"Y", "A", "B"};}
  else if(x == 1){
    x = press("X"); //
    if(x) {ans = "X"; pos = {"Y", "A", "B"};}
    else {ans = "Y";  pos = {"X", "A", "B"};}
  }else{
    x = press("A"); //
    if(x) {ans = "A";  pos = {"Y", "X", "B"};}
    else {ans = "B";  pos = {"Y", "A", "X"};}
  }
  while(ans.size() + 2 <= N){
    ans += pos[0];
    ans += pos[1];
    string ss = ans;
    ans.pop_back();
    ans += pos[0];
    ss += ans;
    ans.pop_back();
    ans.pop_back();
    ans += pos[1];
    ans += pos[1];
    ss += ans;
    x = press(ss); //
    ans.pop_back();
    ans.pop_back();
    if(x == ans.size() + 2){
      ans += pos[0];
      ans += pos[0];
      x = press(ans); //
      ans.pop_back();
      ans.pop_back();
      if(x == ans.size() + 1){
        ans += pos[0];
        ans += pos[1];
      }else if(x == ans.size()){
        ans += pos[1];
        ans += pos[1];
      }
    }else if(x == ans.size() + 1){
      ans += pos[1];
      ans += pos[2];
      x = press(ans); //
      ans.pop_back();
      ans.pop_back();
      if(x == ans.size() + 1){
        ans += pos[1];
        ans += pos[0];
      }else if(x == ans.size()){
        ans += pos[0];
        ans += pos[2];
      }else{
        ans += pos[1];
        ans += pos[2];
      }
    }else ans += pos[2];
  }
  if(ans.size() == N) return ans;
  else{
    ans += pos[0];
    x = press(ans); //
    if(x == N) return ans;
    else{
      ans.pop_back();
      ans += pos[1];
      x = press(ans); //
      if(x == N) return ans;
      else{
        ans.pop_back();
        ans += pos[2];
        return ans;
      }
    }
  }
}

/*int main(){
    /*int n = 3;
    while(1){
        int x = gen() % 4;
        int impos = x;
        if(x == 0) sss[0] = 'A';
        else if(x == 1) sss[0] = 'B';
        else if(x == 2) sss[0] = 'X';
        else sss[0] = 'Y';
        for(int i = 1; i < n; i++){
            x = gen() % 4;
            while(x == impos) x = gen() % 4;
            if(x == 0) sss[i] = 'A';
            else if(x == 1) sss[i] = 'B';
            else if(x == 2) sss[i] = 'X';
            else sss[i] = 'Y';
        }
        string ans = guess_sequence(3);
        if(ans != sss){
            cout << "String was: "<< sss << endl;
            cout << "Returned: "<<ans << endl;
        }
    }
    cout << guess_sequence(3) << endl;
}*/

Compilation message (stderr)

combo.cpp:103:5: warning: "/*" within comment [-Wcomment]
  103 |     /*int n = 3;
      |      
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:37:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |   while(ans.size() + 2 <= N){
      |         ~~~~~~~~~~~~~~~^~~~
combo.cpp:52:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     if(x == ans.size() + 2){
      |        ~~^~~~~~~~~~~~~~~~~
combo.cpp:58:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |       if(x == ans.size() + 1){
      |          ~~^~~~~~~~~~~~~~~~~
combo.cpp:61:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |       }else if(x == ans.size()){
      |                ~~^~~~~~~~~~~~~
combo.cpp:65:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     }else if(x == ans.size() + 1){
      |              ~~^~~~~~~~~~~~~~~~~
combo.cpp:71:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |       if(x == ans.size() + 1){
      |          ~~^~~~~~~~~~~~~~~~~
combo.cpp:74:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |       }else if(x == ans.size()){
      |                ~~^~~~~~~~~~~~~
combo.cpp:83:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   83 |   if(ans.size() == N) return ans;
      |      ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...