Submission #722076

#TimeUsernameProblemLanguageResultExecution timeMemory
722076nguyentunglamPassword (RMI18_password)C++17
80 / 100
1180 ms588 KiB
#include<bits/stdc++.h> using namespace std; const int N = 5010; int cnt[N]; char a[N], b[N]; int query(string q); string guess(int n, int s) { vector<pair<int, char> > lst; for(int j = 0; j < s; j++) { char c = j + 'a'; string ask; for(int i = 1; i <= n; i++) ask.push_back(c); int tmp = query(ask); if (tmp) lst.emplace_back(tmp, c); } sort(lst.begin(), lst.end()); int m; char c; tie(m, c) = lst[0]; for(int i = 1; i <= m; i++) a[i] = c; lst.erase(lst.begin()); for(auto &it : lst) { int num; char c; tie(num, c) = it; for(int i = 1; i <= m; i++) { string ask; for(int j = 1; j <= i; j++) ask.push_back(a[j]); cnt[i] = 0; while (num > 0) { ask.push_back(c); string tmp; for(int j = i + 1; j <= m; j++) tmp.push_back(a[j]); if (query(ask + tmp) > m + cnt[i]) cnt[i]++, num--; else break; } } cnt[0] = num; int m2 = 0; for(int i = 0; i <= m; i++) { if (i) b[++m2] = a[i]; while (cnt[i]--) b[++m2] = c; } for(int i = 1; i <= m2; i++) a[i] = b[i]; m = m2; } string ret; for(int i = 1; i <= m; i++) ret.push_back(a[i]); return ret; }
#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...