# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
642612 | 2022-09-20T09:12:05 Z | SlavicG | Password (RMI18_password) | C++17 | 0 ms | 0 KB |
#include "bits/stdc++.h" using namespace std; //int query(string q); string guess(int n, int s) { vector<pair<int, char>> v; for(char c = 'a'; c < (char)('a' + s); ++c) { string paiu = string(n, c); int x = query(paiu); if(x > 0) { v.push_back({x, c}); } } sort(v.begin(), v.end()); string ans = string(v[0].first, v[0].second); v.erase(v.begin()); for(auto x: v) { char c = x.second; int cnt = x.first; vector<int> add((int)ans.size() + 1, 0); for(int i = 0; i <= (int)ans.size() && cnt; ++i) { string bruh = ""; for(int j = 0; j < i; ++j) bruh += ans[j]; for(int j = 0; j < cnt; ++j) bruh += c; for(int j = i; j < (int)ans.size(); ++j) bruh += ans[j]; int qr = query(bruh); add[i] = qr - (int)ans.size(); cnt -= add[i]; } string newans = ""; for(int i = 0; i <= (int)ans.size(); ++i) { for(int j = 0; j < add[i]; ++j) newans += c; if(i < (int)ans.size()) newans += ans[i]; } ans = newans; } return ans; }