Submission #1315625

#TimeUsernameProblemLanguageResultExecution timeMemory
1315625vlomaczkPassword (RMI18_password)C++20
0 / 100
3 ms412 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> typedef long long ll; using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; int query(string str); int N; int getQ(string s) { if(s.size() > N) return N+20; return query(s); } string guess(int n, int S) { S=26; N=n; vector<int> cnt(S); string alph = "abcdefghijklmnopqrstuvwxyz"; vector<int> V; for(int i=0; i<S; ++i) { string s = ""; s.push_back(alph[i]); while(getQ(s)==s.size()) s.push_back(alph[i]); cnt[i] = s.size() - 1; if(cnt[i]) V.push_back(i); } sort(V.begin(), V.end(), [&](int a, int b){ string s(cnt[a], alph[a]); s.push_back(alph[b]); if(getQ(s)==s.size()) return true; return false; }); string res = "", stos=""; res.push_back(alph[V.back()]); for(int i=res.size()-1; i>=0; --i) { for(int lit : V) { string old_res = res; stos = ""; for(int x=res.size()-1; x>=i; --x) { stos.push_back(res[x]); res.pop_back(); } reverse(stos.begin(), stos.end()); res.push_back(alph[lit]); res += stos; if(getQ(res)!=res.size()) { res = old_res; } else i++; } } return res; }
#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...