Submission #333358

# Submission time Handle Problem Language Result Execution time Memory
333358 2020-12-05T17:22:36 Z valerikk Password (RMI18_password) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

int query(string str);

string pushs(string s, char x) {
    s.push_back(x);
    return s;
}

string inserts(string s, int pos, char x) {
    insert(s.begin() + pos, x);
    return s;
}

string go(int l, int r) {
    if (r - l == 1) {
        string s = "";
        char x = 'a' + l;
        while (query(pushs(s, x)) == s.size() + 1) s.push_back(x);
        return s;
    }
    int mid = (l + r) / 2;
    auto s = go(l, mid), t = go(mid, r);
    for (int i = 0, j = 0; i <= s.size() && j < t.size(); ++i) {
        string kek = inserts(s, i, t[j]);
        if (query(kek) == kek.size()) s = kek;
    }
    return s;
}

string guess(int n, int s) {
    return go(0, s);
}

Compilation message

password.cpp: In function 'std::string inserts(std::string, int, char)':
password.cpp:12:5: error: 'insert' was not declared in this scope; did you mean 'inserts'?
   12 |     insert(s.begin() + pos, x);
      |     ^~~~~~
      |     inserts
password.cpp: In function 'std::string go(int, int)':
password.cpp:20:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         while (query(pushs(s, x)) == s.size() + 1) s.push_back(x);
      |                ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
password.cpp:25:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int i = 0, j = 0; i <= s.size() && j < t.size(); ++i) {
      |                            ~~^~~~~~~~~~~
password.cpp:25:47: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int i = 0, j = 0; i <= s.size() && j < t.size(); ++i) {
      |                                             ~~^~~~~~~~~~
password.cpp:27:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         if (query(kek) == kek.size()) s = kek;
      |             ~~~~~~~~~~~^~~~~~~~~~~~~