Submission #394237

#TimeUsernameProblemLanguageResultExecution timeMemory
394237jsannemoPassword (RMI18_password)C++14
80 / 100
629 ms864 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; int query(string q); vector<int> seen(26); string alpha; string go(const string& pre, int N, int S) { if (S < 0) return ""; swap(alpha[S], alpha[rand() % (S + 1)]); string q = pre + string(N - sz(pre), alpha[S]); int cnt = query(q) - seen[alpha[S] - 'a'] - sz(pre); //cerr << "pre " << pre << " S " << alpha[S] << " cnt " << cnt << endl; string npre = pre + string(cnt, alpha[S]); vector<string> tres; for (int i = cnt; i >= 0; --i) { tres.push_back(go(npre, N, S - 1)); npre.pop_back(); } seen[alpha[S] - 'a'] += cnt; string res; for (int i = sz(tres) - 1; i >= 0; --i) { res.insert(res.end(), all(tres[i])); if (i) res.push_back(alpha[S]); } return res; } string guess(int N, int S) { srand(time(NULL)); rep(i,0,S) alpha.push_back('a' + i); return go("", N, S - 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...