Submission #557378

# Submission time Handle Problem Language Result Execution time Memory
557378 2022-05-05T08:47:10 Z FatihSolak Password (RMI18_password) C++17
0 / 100
4 ms 208 KB
#include <bits/stdc++.h>
using namespace std;
int query(string str);
string guess(int n, int s){
    vector<int> cnt(s);
    vector<int> used(s);
    for(int i = 0;i<s;i++){
        string tmp = "";
        for(int j = 0;j<n;j++)
            tmp += (char) (j + 'a');
        cnt[i] = query(tmp);
    }
    string res = "";
    for(int i = n-1;i>=0;i--){
        int val = 0;
        while(cnt[val] == 0)
            val++;
        for(int i = val+1;i<s;i++){
            if(cnt[i] == 0)continue;
            string tmp = "";
            for(int j = 0;j<cnt[val];j++)
                tmp += (char) (val + 'a');
            while(tmp.size() < n)
                tmp += (char) (i + 'a');
            if(query(tmp) >= cnt[val] + used[i] + 1){
                val = i;
            }
        }
        res += (char)(val + 'a');
        used[val]++;
        cnt[val]--;
    }
    reverse(res.begin(),res.end());
    return res;
}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:23:30: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |             while(tmp.size() < n)
      |                   ~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 208 KB Returned early from guess() after 222 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 208 KB Returned early from guess() after 222 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 208 KB Returned early from guess() after 222 queries.
2 Halted 0 ms 0 KB -