Submission #1117357

# Submission time Handle Problem Language Result Execution time Memory
1117357 2024-11-23T11:10:16 Z Ciprian Password (RMI18_password) C++14
50 / 100
1057 ms 960 KB
#include <bits/stdc++.h>
using namespace std;
int query(string s);
string guess(int n, int s){
    char a='a';
    vector<char>c;
    
    map<char, int>cnt;
    for(int j=1; j<=s; j++){
        cnt[a]=query(string(n, a));
        if (cnt[a]) c.push_back(a);
        a++;
    }
    string w="";
    for(int i=1; i<=n; i++){
        int r=0;
        
        while(!cnt[c[r]] ){
            r++;
        }char x=c[r];
        
        for(int j=r+1; j<c.size(); j++){
            if (!cnt[c[j]]) continue;
            if(query(w+c[j]+string(cnt[x], x))==w.size()+cnt[x]+1){
                x=c[j];
            }   
        }w+=x;
        cnt[x]--;
    }
    
    return w;
}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:23:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         for(int j=r+1; j<c.size(); j++){
      |                        ~^~~~~~~~~
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 |             if(query(w+c[j]+string(cnt[x], x))==w.size()+cnt[x]+1){
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 336 KB Guessed the password with 120 queries.
2 Correct 5 ms 508 KB Guessed the password with 276 queries.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Guessed the password with 48 queries.
2 Correct 3 ms 336 KB Guessed the password with 132 queries.
3 Correct 3 ms 336 KB Guessed the password with 170 queries.
4 Correct 6 ms 336 KB Guessed the password with 293 queries.
# Verdict Execution time Memory Grader output
1 Correct 193 ms 712 KB Guessed the password with 9608 queries.
2 Correct 337 ms 708 KB Guessed the password with 17344 queries.
3 Correct 447 ms 704 KB Guessed the password with 21757 queries.
4 Correct 760 ms 960 KB Guessed the password with 36499 queries.
# Verdict Execution time Memory Grader output
1 Correct 3 ms 336 KB Guessed the password with 120 queries.
2 Correct 5 ms 508 KB Guessed the password with 276 queries.
3 Correct 1 ms 336 KB Guessed the password with 48 queries.
4 Correct 3 ms 336 KB Guessed the password with 132 queries.
5 Correct 3 ms 336 KB Guessed the password with 170 queries.
6 Correct 6 ms 336 KB Guessed the password with 293 queries.
7 Correct 193 ms 712 KB Guessed the password with 9608 queries.
8 Correct 337 ms 708 KB Guessed the password with 17344 queries.
9 Correct 447 ms 704 KB Guessed the password with 21757 queries.
10 Correct 760 ms 960 KB Guessed the password with 36499 queries.
11 Incorrect 1057 ms 696 KB Could not guess the password with 50000 queries.
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 336 KB Guessed the password with 120 queries.
2 Correct 5 ms 508 KB Guessed the password with 276 queries.
3 Correct 1 ms 336 KB Guessed the password with 48 queries.
4 Correct 3 ms 336 KB Guessed the password with 132 queries.
5 Correct 3 ms 336 KB Guessed the password with 170 queries.
6 Correct 6 ms 336 KB Guessed the password with 293 queries.
7 Correct 193 ms 712 KB Guessed the password with 9608 queries.
8 Correct 337 ms 708 KB Guessed the password with 17344 queries.
9 Correct 447 ms 704 KB Guessed the password with 21757 queries.
10 Correct 760 ms 960 KB Guessed the password with 36499 queries.
11 Incorrect 1057 ms 696 KB Could not guess the password with 50000 queries.
12 Halted 0 ms 0 KB -