답안 #791650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
791650 2023-07-24T08:31:55 Z anton Password (RMI18_password) C++17
50 / 100
434 ms 352 KB
#include <bits/stdc++.h>

using namespace std;

int query(string q);

string uni(char c, int l){
  string r;
  for(int i = 0; i<l; i++){
    r.push_back(c);
  }
  return r;
}

string guess(int n, int s){
  string r;
  vector<int> oc(s);
  for(int i = 0; i<s; i++){
    string a;
    int l =0;
    char c= 'a'+i;


    oc[i] = query(uni(c, n));
    //cout<<c<<" "<<oc[i]<<endl;
  }

  r= uni('a', oc[0]);
  for(int i =1; i<s; i++){
    int p = 0;
    while(p<=r.size() && r.size()<n){
      string r2 = r;
      r2.insert(r2.begin()+ p, 'a'+i);
      if(query(r2) == r2.size()){
        swap(r, r2);
      }
      p++;
    }
  }

  return r;
}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:20:9: warning: unused variable 'l' [-Wunused-variable]
   20 |     int l =0;
      |         ^
password.cpp:31:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     while(p<=r.size() && r.size()<n){
      |           ~^~~~~~~~~~
password.cpp:31:34: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |     while(p<=r.size() && r.size()<n){
      |                          ~~~~~~~~^~
password.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |       if(query(r2) == r2.size()){
      |          ~~~~~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB Guessed the password with 146 queries.
2 Correct 3 ms 208 KB Guessed the password with 315 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 48 queries.
2 Correct 1 ms 208 KB Guessed the password with 120 queries.
3 Correct 1 ms 300 KB Guessed the password with 94 queries.
4 Correct 2 ms 300 KB Guessed the password with 223 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 304 KB Guessed the password with 4817 queries.
2 Correct 101 ms 344 KB Guessed the password with 10678 queries.
3 Correct 116 ms 352 KB Guessed the password with 14341 queries.
4 Correct 162 ms 352 KB Guessed the password with 20813 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB Guessed the password with 146 queries.
2 Correct 3 ms 208 KB Guessed the password with 315 queries.
3 Correct 1 ms 208 KB Guessed the password with 48 queries.
4 Correct 1 ms 208 KB Guessed the password with 120 queries.
5 Correct 1 ms 300 KB Guessed the password with 94 queries.
6 Correct 2 ms 300 KB Guessed the password with 223 queries.
7 Correct 30 ms 304 KB Guessed the password with 4817 queries.
8 Correct 101 ms 344 KB Guessed the password with 10678 queries.
9 Correct 116 ms 352 KB Guessed the password with 14341 queries.
10 Correct 162 ms 352 KB Guessed the password with 20813 queries.
11 Incorrect 434 ms 328 KB Could not guess the password with 50000 queries.
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB Guessed the password with 146 queries.
2 Correct 3 ms 208 KB Guessed the password with 315 queries.
3 Correct 1 ms 208 KB Guessed the password with 48 queries.
4 Correct 1 ms 208 KB Guessed the password with 120 queries.
5 Correct 1 ms 300 KB Guessed the password with 94 queries.
6 Correct 2 ms 300 KB Guessed the password with 223 queries.
7 Correct 30 ms 304 KB Guessed the password with 4817 queries.
8 Correct 101 ms 344 KB Guessed the password with 10678 queries.
9 Correct 116 ms 352 KB Guessed the password with 14341 queries.
10 Correct 162 ms 352 KB Guessed the password with 20813 queries.
11 Incorrect 434 ms 328 KB Could not guess the password with 50000 queries.
12 Halted 0 ms 0 KB -