Submission #756003

#TimeUsernameProblemLanguageResultExecution timeMemory
756003vjudge1Password (RMI18_password)C++17
0 / 100
63 ms336 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "C:\GCC\debug.h" #else #define debug(...) void(42) #endif int cnt = 0; int query(string s); string guess(int n, int s) { string res = ""; vector<int> freq(s); for (int i = 0; i < s; i++) { string x = ""; for (int it = 0; it < n; it++) { x += (i + 'a'); } freq[i] = query(x); } int ptr = 0; while (freq[ptr] == 0) { ++ptr; } for (int i = 0; i < freq[ptr]; i++) { res += (ptr + 'a'); } int best = query(res); for (int i = ptr + 1; i < s; i++) { if (freq[i] == 0) { continue; } int cur = i + 'a'; auto Build = [&](int pos) { int it = 0; string tmp = ""; while (it < pos) { tmp += res[it]; ++it; } tmp += cur; while (it < (int) res.length()) { tmp += res[it]; it++; } return tmp; }; int pts = 0; for (int j = 0; j < (int) res.length(); j++) { string tmp = Build(j); int cB = query(tmp); if (best < cB) { pts++; best = cB; swap(res, tmp); if (pts == freq[i]) { break; } if (best == n) { return res; } } } int rem = n - (int) res.length(); // debug(res); string nRes = res; nRes.insert((int) nRes.length(), rem, cur); best = query(nRes); if (best == n) { return nRes; } nRes.resize(best); swap(nRes, res); } 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...