답안 #333359

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333359 2020-12-05T17:23:02 Z valerikk Password (RMI18_password) C++17
0 / 100
29 ms 364 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) {
    s.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 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;
      |             ~~~~~~~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Returned early from guess() after 81 queries.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 364 KB Returned early from guess() after 3342 queries.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Returned early from guess() after 81 queries.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Returned early from guess() after 81 queries.
2 Halted 0 ms 0 KB -