# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
854172 | 2023-09-26T09:51:32 Z | allin27x | Password (RMI18_password) | C++17 | 275 ms | 596 KB |
#include <bits/stdc++.h> using namespace std; int query(string str); string guess(int n, int s){ for (int i=0; i<50001; i++){ query("a"); } mt19937 rng(time(nullptr)); string res; vector<int> nc(s, 0); vector<int> to(s, -1); for (int i=0; i<s; i++) nc[i] = query(string(n,'a'+i)); int last = -1; while (res.size()<n){ string rev = res; reverse(rev.begin(), rev.end()); vector<int> rel; for (int i=0; i<s; i++) if (nc[i] && (i==last || to[i] == last)) rel.push_back(i); random_shuffle(rel.begin(), rel.end()); int mx = rel[0]; for (int i: rel){ if (i== rel[0]) continue; if (!nc[i] || (i!=last && to[i]!=last)) continue; if (query(string(nc[i], 'a'+i) + string(1,'a'+mx) + rev) != nc[i] + 1 + res.size()) { to[mx] = i; mx = i; } else { to[i] = mx; } } nc[mx] --; res += 'a' + mx; last = mx; } reverse(res.begin(), res.end()); return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 266 ms | 344 KB | Could not guess the password with 50000 queries. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 275 ms | 596 KB | Could not guess the password with 50000 queries. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 260 ms | 500 KB | Could not guess the password with 50000 queries. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 266 ms | 344 KB | Could not guess the password with 50000 queries. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 266 ms | 344 KB | Could not guess the password with 50000 queries. |
2 | Halted | 0 ms | 0 KB | - |