제출 #1159697

#제출 시각아이디문제언어결과실행 시간메모리
1159697fryingducPassword (RMI18_password)C++17
20 / 100
26 ms468 KiB
#include <string> #include <queue> using namespace std; int query(string q); string guess(int n, int c) { priority_queue<pair<int, string>> pq; for (int i = 0; i < c; ++i) { string cur; for (int j = 0; j < n; ++j) { cur += char('a' + i); } int x = query(cur); if (x > 0) { cur.clear(); for (int j = 0; j < x; ++j) { cur += char('a' + i); } pq.push(make_pair(x, cur)); } } while ((int)pq.size() > 1) { string x = pq.top().second; pq.pop(); string y = pq.top().second; pq.pop(); string res; while (!x.empty()) { string g = res + x[0] + y; if (query(g) == (int)g.size()) { res += x[0]; x.erase(x.begin()); } else { res += y[0]; y.erase(y.begin()); } } if (!y.empty()) { res += y; } pq.push(make_pair((int)res.size(), res)); } return pq.top().second; }
#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...