Submission #926922

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

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

    srand(time(NULL));

    char ignore = 0;

    while (cur.size() < N) {
        for (char c: poss) if (c - ignore) {
            cur += c;
            cur += poss[0];
            int res = press(cur);
            if (res == cur.size() - 1) {
                ignore = poss[0];
                cur.pop_back();
                continue;
            }  else if (res == cur.size()) {
                ignore = 0;
                continue;
            }
            cur.pop_back();
            cur.pop_back();
        }
    }

    // cout << cur << " " << cur.size() << " " << N << endl;
    assert(cur.size() == N);
  return cur;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:21:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |     while (cur.size() < N) {
      |            ~~~~~~~~~~~^~~
combo.cpp:26:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |             if (res == cur.size() - 1) {
      |                 ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:30:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             }  else if (res == cur.size()) {
      |                         ~~~~^~~~~~~~~~~~~
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:40:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |     assert(cur.size() == N);
      |            ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...