답안 #773171

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
773171 2023-07-04T16:02:24 Z aykhn Password (RMI18_password) C++14
0 / 100
7 ms 300 KB
#include <bits/stdc++.h>

// author: aykhn

using namespace std;

typedef long long ll;

int query(string str);

string guess(int n, int s)
{
    string ans = "";
    int prev = 0;

    string x = "a";
    for (int i = 0; i < s; i++)
    {
        ans = x + ans;
        int X = query(ans);
        prev = max(X, prev);
        int sz = ans.length();
        if (!X) ans = ans.substr(1, sz - 1);

        for (int j = 1; j <= ans.length(); j++)
        {
            string asdasdasd = ans;
            string asd = ans.substr(0, j);
            string assd = "";
            int sz = ans.length();
            if (j != sz) assd = ans.substr(j, sz - j);
            ans = asd;
            ans += x;
            ans += assd;
            int y = query(ans);
            if (y <= prev)
            {
                ans = asdasdasd;
            }
            else prev = y;
            if (ans.length() == n) break;
        }
        if (ans.length() == n) break;

        x[0]++;
    }

    return ans;
}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:25:27: 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 j = 1; j <= ans.length(); j++)
      |                         ~~^~~~~~~~~~~~~~~
password.cpp:41:30: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |             if (ans.length() == n) break;
      |                 ~~~~~~~~~~~~~^~~~
password.cpp:43:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |         if (ans.length() == n) break;
      |             ~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 71 queries.
2 Incorrect 2 ms 208 KB Returned early from guess() after 151 queries.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 300 KB Returned early from guess() after 749 queries.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -