Submission #918811

# Submission time Handle Problem Language Result Execution time Memory
918811 2024-01-30T13:14:37 Z nasir_bashirov Password (RMI18_password) C++17
Compilation error
0 ms 0 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 cmp(pci a, pci b){
  return cnt[a.first] > cnt[b.first];
}
bool comp(pair<char, int> a, pair<char, int> b){
    if(a.first == b.first){
        return a.second < b.second;
    }
    if(memo.count({a, b}))    return memo[{a, b}];  
    string s = "";
    for(int i = 1; i <= a.second; i++){
        s += a.first;
    }
    for(int i = 1; i <= cnt[b.first] - b.second + 1; i++){
        s += b.first;
    }
    return memo[{a, b}] = (query(s) == (int)s.size());
}
 
string guess(int n, int s){
    vector<pci> v;
    for(char c = 'a'; c <= char('a'+s-1); c++){
        string s1 = "";
        for(int j = 1; j <= n; j++){
            s1 += c;
        }
        cnt[c] = query(s1);
        for(int j = 1; j <= cnt[c]; j++){
            v.push_back({c, j});
        }
        // cout << c << " : " << cnt[c] << endl;
    }
    sort(all(v),cmp);
    sort(all(v), comp);
    string res = "";
    for(auto i : v){
        res += i.first;
    }
    return res;
}

Compilation message

password.cpp:29:2: error: extended character   is not valid in an identifier
   29 |   return cnt[a.first] > cnt[b.first];
      |  ^
password.cpp:59:2: error: extended character   is not valid in an identifier
   59 |     sort(all(v),cmp);
      |  ^
password.cpp:59:5: error: extended character   is not valid in an identifier
   59 |     sort(all(v),cmp);
      |    ^
password.cpp:60:2: error: extended character   is not valid in an identifier
   60 |     sort(all(v), comp);
      |  ^
password.cpp:60:5: error: extended character   is not valid in an identifier
   60 |     sort(all(v), comp);
      |    ^
password.cpp: In function 'bool cmp(std::pair<char, int>, std::pair<char, int>)':
password.cpp:29:2: error: '\U000000a0return' was not declared in this scope; did you mean 'sigreturn'?
   29 |   return cnt[a.first] > cnt[b.first];
      |  ^~~~~~~
      |  sigreturn
password.cpp:30:1: warning: no return statement in function returning non-void [-Wreturn-type]
   30 | }
      | ^
password.cpp: In function 'std::string guess(int, int)':
password.cpp:59:2: error: '\U000000a0' was not declared in this scope
   59 |     sort(all(v),cmp);
      |  ^
password.cpp:60:4: error: expected ';' before '\U000000a0sort'
   60 |     sort(all(v), comp);
      |   ^~~~~~
      |   ;