답안 #773223

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
773223 2023-07-04T17:03:06 Z aykhn Password (RMI18_password) C++14
50 / 100
267 ms 356 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;

    for (int i = 0; i < s; i++)
    {
        for (int j = 0; j <= ans.length(); j++)
        {
            string bfr = ans;
            ans.insert(ans.begin() + j, 'a' + i);

            int x = query(ans);

            if (x <= prev) ans = bfr;
            else prev = x;
            if (ans.length() == n) break;
        }
        if (ans.length() == n) break;
    }

    return ans;
}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:18:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         for (int j = 0; j <= ans.length(); j++)
      |                         ~~^~~~~~~~~~~~~~~
password.cpp:27:30: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |             if (ans.length() == n) break;
      |                 ~~~~~~~~~~~~~^~~~
password.cpp:29:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |         if (ans.length() == n) break;
      |             ~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 208 KB Guessed the password with 133 queries.
2 Correct 3 ms 208 KB Guessed the password with 294 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 71 queries.
2 Correct 2 ms 208 KB Guessed the password with 166 queries.
3 Correct 1 ms 208 KB Guessed the password with 102 queries.
4 Correct 2 ms 208 KB Guessed the password with 228 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 304 KB Guessed the password with 4807 queries.
2 Correct 80 ms 348 KB Guessed the password with 10754 queries.
3 Correct 125 ms 344 KB Guessed the password with 14365 queries.
4 Correct 126 ms 356 KB Guessed the password with 20878 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 208 KB Guessed the password with 133 queries.
2 Correct 3 ms 208 KB Guessed the password with 294 queries.
3 Correct 1 ms 208 KB Guessed the password with 71 queries.
4 Correct 2 ms 208 KB Guessed the password with 166 queries.
5 Correct 1 ms 208 KB Guessed the password with 102 queries.
6 Correct 2 ms 208 KB Guessed the password with 228 queries.
7 Correct 28 ms 304 KB Guessed the password with 4807 queries.
8 Correct 80 ms 348 KB Guessed the password with 10754 queries.
9 Correct 125 ms 344 KB Guessed the password with 14365 queries.
10 Correct 126 ms 356 KB Guessed the password with 20878 queries.
11 Incorrect 267 ms 336 KB Could not guess the password with 50000 queries.
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 208 KB Guessed the password with 133 queries.
2 Correct 3 ms 208 KB Guessed the password with 294 queries.
3 Correct 1 ms 208 KB Guessed the password with 71 queries.
4 Correct 2 ms 208 KB Guessed the password with 166 queries.
5 Correct 1 ms 208 KB Guessed the password with 102 queries.
6 Correct 2 ms 208 KB Guessed the password with 228 queries.
7 Correct 28 ms 304 KB Guessed the password with 4807 queries.
8 Correct 80 ms 348 KB Guessed the password with 10754 queries.
9 Correct 125 ms 344 KB Guessed the password with 14365 queries.
10 Correct 126 ms 356 KB Guessed the password with 20878 queries.
11 Incorrect 267 ms 336 KB Could not guess the password with 50000 queries.
12 Halted 0 ms 0 KB -