답안 #855660

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
855660 2023-10-01T16:07:29 Z uomoproteina Password (RMI18_password) C++14
0 / 100
0 ms 440 KB
#include <bits/stdc++.h>

using namespace std;

string str = "";
string ans = "";

int query(string s);

bool add(string s)
{
    int ret = query(s);
    return ret == str.size() + ans.size() + 1; 
}

void solve(int N, int S)
{
    cout << str + ans << "\n";
    if (ans.size() + str.size() == N) return;
    bool found = false;
    for (int i = 0; i < S && !found; i++)
    {   
        if (add(str + char(i + (int)('a')) + ans)) 
        {
            str += char(i + (int)('a'));
            found = true;
        }
    }
    if (!found && str.size())
    {
        reverse(ans.begin(), ans.end());
        ans += str.back();
        reverse(ans.begin(), ans.end());
        str.pop_back();
    }
}

string guess(int n, int s)
{
    while (ans.size() + str.size() < n)
    {
        solve(n, s);
    }
    return str + ans;
}

Compilation message

password.cpp: In function 'bool add(std::string)':
password.cpp:13:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     return ret == str.size() + ans.size() + 1;
      |            ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
password.cpp: In function 'void solve(int, int)':
password.cpp:19:33: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |     if (ans.size() + str.size() == N) return;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
password.cpp: In function 'std::string guess(int, int)':
password.cpp:40:36: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |     while (ans.size() + str.size() < n)
      |            ~~~~~~~~~~~~~~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 432 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 432 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 432 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 432 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -