Submission #1117359

# Submission time Handle Problem Language Result Execution time Memory
1117359 2024-11-23T11:14:37 Z somefolk Password (RMI18_password) C++14
0 / 100
63 ms 608 KB
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <complex>
#include <list>
#include <chrono>
#include <random>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;

#define endl "\n"
// #define int long long

const int INF = 2 * 1e5 + 5;
const int MOD = 1e9 + 7;

int query(string s);

string guess(int n, int s){
    map<char, int> a;
    for(char i = 0; i < s; i++){
        string s = string(n, i+'a');
        a[i+'a'] = query(s);
    }

    string sol;
    for(int i = 0; i < n; i++){
        char prev;
        for(auto &j : a){
            if(j.second != 0){
                prev = j.first;
                break;
            }
        }
        for(auto &j : a){
            if(prev == j.first || j.second == 0) continue;
            if(query(sol + prev + string(j.second, j.first)) == sol.size() + j.second + 1){
                prev = j.first;
            }
        }
        a[prev]--;
        sol+=prev;
    }

    return sol;
}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:46:62: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |             if(query(sol + prev + string(j.second, j.first)) == sol.size() + j.second + 1){
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
password.cpp:46:28: warning: 'prev' may be used uninitialized in this function [-Wmaybe-uninitialized]
   46 |             if(query(sol + prev + string(j.second, j.first)) == sol.size() + j.second + 1){
      |                            ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 336 KB Returned early from guess() after 121 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Returned early from guess() after 27 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 63 ms 608 KB Returned early from guess() after 3818 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 336 KB Returned early from guess() after 121 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 336 KB Returned early from guess() after 121 queries.
2 Halted 0 ms 0 KB -