Submission #854152

#TimeUsernameProblemLanguageResultExecution timeMemory
854152TimDeePassword (RMI18_password)C++17
30 / 100
50 ms1224 KiB
// Esti <3 //\ šťastia pre nás :) // you're already the best // _ // ^ ^ // // >(O_O)<___// // \ __ __ \ // \\ \\ \\\\ #include <bits/stdc++.h> using namespace std; //#pragma GCC optimize("O3","unroll-loops") //#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #pragma GCC optimize("O3") #pragma GCC target("popcnt") using ll = long long; //#define int long long #define forn(i,n) for(int i=0; i<(n); ++i) #define pb push_back #define pi pair<int,int> #define f first #define s second #define vii(a,n) vector<int> a(n); forn(i,n) cin>>a[i]; #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); const int inf = 1e18; const int mod = 998244353; // \ \ :smiling_face_with_3_hearts: :smiling_face_with_3_hearts: :smiling_face_with_3_hearts: //vidime sa veľmi skoro, moje slnko string pass; int query(string s); int Q=0; void insert(string&s, int i, char c) { s+=c; for (int j=s.size()-1; j>i; --j) { swap(s[j],s[j-1]); } } void erase(string&s, int i) { for (int j=i; j+1 < s.size(); ++j) swap(s[j], s[j+1]); s.pop_back(); } string merge(string f, string s) { int p=f.size(); int n=s.size()-1; int old = query(f); while (n>=0 && p>=0) { insert(f,p,s[n]); int x = query(f); if (x > old) { old = x; --n; } else { erase(f,p); --p; } } while (n>=0) insert(f,0,s[n--]); return f; } string guess(int n, int s) { vector<int> cnt(s,0); for(char c='a'; c<(char)('a'+s); ++c) { string str; forn(i,n) str+=c; int x = query(str); cnt[c-'a']=x; } vector<pi> v; forn(i,s) if (cnt[i]) v.pb({cnt[i],i}); sort(all(v)); vector<string> a; for(auto&x:v) a.pb(string(x.f,(char)('a'+x.s))); while (a.size()>1) { vector<string> b; int n=a.size(); for(int i=0; i+1<n; i+=2) { //cout<<a[i]<<" & "<<a[i+1]<<": "; auto z = merge(a[i],a[i+1]); //cout<<z<<'\n'; b.pb(z); } if (n&1) b.pb(a[n-1]); a=b; } return a[0]; }

Compilation message (stderr)

password.cpp:3:1: warning: multi-line comment [-Wcomment]
    3 | //\
      | ^
password.cpp:9:1: warning: multi-line comment [-Wcomment]
    9 | //   \ __ __  \
      | ^
password.cpp:36:1: warning: multi-line comment [-Wcomment]
   36 | // \
      | ^
password.cpp:33:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   33 | const int inf = 1e18;
      |                 ^~~~
password.cpp: In function 'void erase(std::string&, int)':
password.cpp:54:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for (int j=i; j+1 < s.size(); ++j) swap(s[j], s[j+1]);
      |                   ~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...