Submission #309003

#TimeUsernameProblemLanguageResultExecution timeMemory
309003bigDuckPassword (RMI18_password)C++14
80 / 100
502 ms716 KiB
#include<bits/stdc++.h> using namespace std; #define INIT ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define mp make_pair #define pb push_back #define ft first #define sc second #define ll long long #define pii pair<int, int> #define count_bits __builtin_popcount int query(string str); /*int query(string str){ cout<<str<<"\n"<<flush; int res; cin>>res; return res; }*/ string guess(int n, int s){ set<pair<int, char>> ord; for(char c='a'; c<=('a'+s-1); c++){ string st=""; for(int i=0; i<n; i++){st.pb(c);} int ln=query(st); if(ln==0){continue;} ord.insert(mp(ln, c)); } string res=""; for(int i=0; i<((ord.begin())->ft); i++){ res.pb((ord.begin())->sc); } ord.erase(ord.begin()); while(!ord.empty()){ auto it=ord.begin(); vector<int> sum; sum.assign(n+5, 0); string s1=res; s1+="a"; string s2=""; for(int i=s1.length(); i<(n-1); i++){ s2.pb(it->sc); } for(;!s1.empty();){ s1.erase(s1.end()-1, s1.end()); s2.pb(it->sc); int ln=query(s1+s2); sum[s1.length()]=(ln-((int)s1.length()) ); } int cnt=0; for(int i=res.length(); i>=0; i--){ if(i<(res.length())){ s1="a"+s1; s1[0]=res[i]; } while(cnt<sum[i]){ string st="a"; st[0]=(it->sc); s1=st+s1; cnt++; } } res=s1; ord.erase(it); } return res; } /*int main(){ cout<<guess(6, 26); }*/

Compilation message (stderr)

password.cpp: In function 'std::string guess(int, int)':
password.cpp:57:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         if(i<(res.length())){
      |            ~^~~~~~~~~~~~~~~
#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...