Submission #918674

# Submission time Handle Problem Language Result Execution time Memory
918674 2024-01-30T08:38:07 Z nasir_bashirov Password (RMI18_password) C++17
0 / 100
1 ms 448 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#include <bits/stdc++.h>
using namespace std;

#define db long double
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
// #define endl '\n'
#define all(x) x.begin(), x.end()
#define fastio\
    ios_base::sync_with_stdio(0);\
    cin.tie(0);\
    cout.tie(0)\

int query(string str);

#define pci pair<char, int>

map<pair<pci, pci>, bool> memo;
map<char, int> cnt;

bool comp(pair<char, int> a, pair<char, int> b){
    if(a.first == b.first){
        return a.second < b.second;
    }
    if(memo[{a, b}])    return memo[{a, b}];
    string s = "";
    for(int i = 1; i <= cnt[b.first] - b.second + 1; i++){
        s += b.first;
    }
    for(int i = 1; i <= a.second; i++){
        s += a.first;
    }
    return memo[{a, b}] = (query(s) != s.size());
}

string guess(int n, int s){
    vector<pci> v;
    for(char c = 'a'; c <= 'z'; c++){
        string s = "";
        for(int j = 1; j <= n; j++){
            s += c;
        }
        cnt[c] = query(s);
        for(int j = 1; j <= cnt[c]; j++){
            v.push_back({c, j});
        }
        // cout << c << " : " << cnt[c] << endl;
    }
    sort(all(v), comp);
    string res = "";
    for(auto i : v){
        res += i.first;
    }
    return res;
}

Compilation message

password.cpp: In function 'bool comp(std::pair<char, int>, std::pair<char, int>)':
password.cpp:41:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     return memo[{a, b}] = (query(s) != s.size());
      |                            ~~~~~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 436 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 448 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -