Submission #926917

#TimeUsernameProblemLanguageResultExecution timeMemory
926917bobbilykingCombo (IOI18_combo)C++17
10 / 100
29 ms1208 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

std::string guess_sequence(int N) {
    set<char> poss{'A', 'B', 'X', 'Y'};
    string cur;
    for (char c: poss) {
        string s; s += c;
        if (press(s)) {
            poss.erase(c); 
            cur = s;
            break;
        } 
    }

    // cout << "YO " << cur << endl;

    for (int i =2 ; i <=N; ++i) {
        // cout << "YA " << cur << endl;
        assert(cur.size() == i-1);
        for (char c: poss) {
            cur += c;
            if (press(cur) == i) break;
            cur.pop_back();
        }
    }
    // cout << cur << " " << cur.size() << " " << N << endl;
    assert(cur.size() == N);
  return cur;
}

Compilation message (stderr)

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:2:
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:21:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |         assert(cur.size() == i-1);
      |                ~~~~~~~~~~~^~~~~~
combo.cpp:29:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |     assert(cur.size() == N);
      |            ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...