# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
646323 | 2022-09-29T14:21:48 Z | Matteo_Verz | Password (RMI18_password) | C++17 | 83 ms | 480 KB |
#include <bits/stdc++.h> #ifdef BLAT #include "debug/debug.hpp" #else #define debug(x...) #endif using namespace std; int query(string s); string mergeStrings(string &a, string &b) { string mergedSoFar, queryString; while (a.size() || b.size()) { if (!a.size()) { mergedSoFar += b; return mergedSoFar; } queryString = mergedSoFar + a[0] + b; int len = query(queryString); if (len == queryString.size()) { mergedSoFar.push_back(a[0]); a.erase(0, 1); } else { mergedSoFar.push_back(b[0]); b.erase(0, 1); } } return mergedSoFar; } struct Compare { bool operator()(const string &a, const string &b) { return a.size() > b.size(); } }; string guess(int n, int s) { string ask; priority_queue <string, vector <string>, Compare> pq; for (char ch = 'a'; ch - 'a' < s; ch++) { ask.clear(); for (int i = 0; i < n; i++) ask += ch; int len = query(ask); ask = ""; for (int i = 0; i < len; i++) ask += ch; pq.push(ask); } while (pq.size() > 1) { string a = pq.top(); pq.pop(); string b = pq.top(); pq.pop(); string c = mergeStrings(a, b); pq.push(c); } return pq.top(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 208 KB | Guessed the password with 67 queries. |
2 | Correct | 1 ms | 208 KB | Guessed the password with 114 queries. |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Guessed the password with 52 queries. |
2 | Runtime error | 1 ms | 296 KB | Execution killed with signal 13 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 308 KB | Guessed the password with 2763 queries. |
2 | Correct | 35 ms | 480 KB | Guessed the password with 5078 queries. |
3 | Correct | 44 ms | 364 KB | Guessed the password with 4595 queries. |
4 | Correct | 83 ms | 312 KB | Guessed the password with 8147 queries. |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 208 KB | Guessed the password with 67 queries. |
2 | Correct | 1 ms | 208 KB | Guessed the password with 114 queries. |
3 | Correct | 1 ms | 208 KB | Guessed the password with 52 queries. |
4 | Runtime error | 1 ms | 296 KB | Execution killed with signal 13 |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 208 KB | Guessed the password with 67 queries. |
2 | Correct | 1 ms | 208 KB | Guessed the password with 114 queries. |
3 | Correct | 1 ms | 208 KB | Guessed the password with 52 queries. |
4 | Runtime error | 1 ms | 296 KB | Execution killed with signal 13 |
5 | Halted | 0 ms | 0 KB | - |