Submission #1031483

#TimeUsernameProblemLanguageResultExecution timeMemory
1031483ArthuroWichCombo (IOI18_combo)C++17
30 / 100
31 ms976 KiB
#include "combo.h"
#include<bits/stdc++.h>
using namespace std;
string guess_sequence(int n) {
    string s;
    int v;
    v = press("AB");
    if (v == 2) {
        s = "AB";
    } else if (v == 1) {
        v = press("A");
        if (v == 1) {
            s = "A";
        } else {
            s = "B";
        }
    } else {
        v = press("XY");
        if (v == 2) {
            s = "XY";
        } else {
            v = press("X");
            if (v == 1) {
                s = "X";
            } else {
                s = "Y";
            }
        }
    }
    if (n == 1) {
        return s;
    } else if (s.length() == n) {
        return s;
    }
    while(s.length() != n) {
        string s1 = s+"A"+s+"B";
        v = press(s1);
        if (v == s.length()+1) {
            if (s[0] == 'A') {
                s.push_back('B');
            } else if (s[0] == 'B') {
                s.push_back('A');
            } else {
                s1 = s+"A";
                v = press(s1);
                if (v == s.length()+1) {
                    s.push_back('A');
                } else {
                    s.push_back('B');
                }
            }
        } else {
            if (s[0] == 'X') {
                s.push_back('Y');
            } else if (s[0] == 'Y') {
                s.push_back('X');
            } else {
                s1 = s+"X";
                v = press(s1);
                if (v == s.length()+1) {
                    s.push_back('X');
                } else {
                    s.push_back('Y');
                }
            }
        }
    }
    return s;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:32:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |     } else if (s.length() == n) {
      |                ~~~~~~~~~~~^~~~
combo.cpp:35:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |     while(s.length() != n) {
      |           ~~~~~~~~~~~^~~~
combo.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         if (v == s.length()+1) {
      |             ~~^~~~~~~~~~~~~~~
combo.cpp:46:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |                 if (v == s.length()+1) {
      |                     ~~^~~~~~~~~~~~~~~
combo.cpp:60:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |                 if (v == s.length()+1) {
      |                     ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...