# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
685441 | 2023-01-24T11:08:15 Z | annie2018 | Secret Permutation (RMI19_permutation) | C++17 | 2029 ms | 416 KB |
#include <bits/stdc++.h> #include "permutation.h" using namespace std; int n; vector <int> fin(257), v, a(257), q(257); bitset <257> used; void get (int x) { used[a[x]] = 1; if (x == n && abs(a[1] - a[x]) == q[n]) { vector <int> ret; for(int i = 1;i <= n; i++) { fin[v[i - 1]] = a[i]; } for(int i = 1; i <= n; i++) { ret.push_back(fin[i]); } /*for (int i = 0; i < ret.size(); i++) cout << ret[i] << ' '; cout << "\n";*/ answer(ret); exit(0); } else { int one = a[x] - q[x], two = a[x] + q[x]; if (one > 0 && one <= n && !used[one] && abs(one - a[x]) == q[x]) { a[x + 1] = one; get(x + 1); } if (two > 0 && two <= n && !used[two] && abs(two - a[x]) == q[x]) { a[x + 1] = two; get(x + 1); } } used[a[x]] = 0; a[x] = 0; } void solve(int nn) { n = nn; srand(chrono::steady_clock::now().time_since_epoch().count()); for (int i = 1; i <= n; i++) v.push_back(i); random_shuffle(v.begin(), v.end()); for(int i = 1; i <= n; i++) { rotate(v.begin(), v.begin() + 1, v.end()); q[i] = query(v); } rotate(v.begin(), v.begin() + 1, v.end()); int sum = 0; for(int i = 1; i <= n; i++) sum += q[i]; sum /= (n - 1); for(int i = 1; i <= n; i++) q[i] = (sum - q[i]); q[n + 1] = q[1]; for(int i = 1; i <= n; i++) q[i] = q[i + 1]; /*for (int i = 0; i < v.size(); i++) cout << v[i] << ' '; cout << "\n"; for (int i = 0; i < n + 2; i++) cout << q[i] << ' '; cout << "\n";*/ //get(q, n); for (int i = 1; i <= n; i++) { for (int i2 = 1; i2 <= n; i2++) a[i2] = 0; a[1] = i; used.reset(); get(1); } //answer(ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Correct | 0 ms | 208 KB | Output is correct |
4 | Correct | 1 ms | 208 KB | Output is correct |
5 | Correct | 0 ms | 208 KB | Output is correct |
6 | Correct | 1 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Correct | 0 ms | 208 KB | Output is correct |
4 | Correct | 1 ms | 208 KB | Output is correct |
5 | Correct | 0 ms | 208 KB | Output is correct |
6 | Correct | 1 ms | 208 KB | Output is correct |
7 | Correct | 1 ms | 208 KB | Output is correct |
8 | Correct | 1 ms | 208 KB | Output is correct |
9 | Correct | 1 ms | 208 KB | Output is correct |
10 | Correct | 1 ms | 208 KB | Output is correct |
11 | Correct | 1 ms | 208 KB | Output is correct |
12 | Correct | 1 ms | 208 KB | Output is correct |
13 | Correct | 1 ms | 208 KB | Output is correct |
14 | Correct | 1 ms | 208 KB | Output is correct |
15 | Correct | 1 ms | 208 KB | Output is correct |
16 | Correct | 2 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Correct | 0 ms | 208 KB | Output is correct |
4 | Correct | 1 ms | 208 KB | Output is correct |
5 | Correct | 0 ms | 208 KB | Output is correct |
6 | Correct | 1 ms | 208 KB | Output is correct |
7 | Correct | 1 ms | 208 KB | Output is correct |
8 | Correct | 1 ms | 208 KB | Output is correct |
9 | Correct | 1 ms | 208 KB | Output is correct |
10 | Correct | 1 ms | 208 KB | Output is correct |
11 | Correct | 1 ms | 208 KB | Output is correct |
12 | Correct | 1 ms | 208 KB | Output is correct |
13 | Correct | 1 ms | 208 KB | Output is correct |
14 | Correct | 1 ms | 208 KB | Output is correct |
15 | Correct | 1 ms | 208 KB | Output is correct |
16 | Correct | 2 ms | 208 KB | Output is correct |
17 | Correct | 134 ms | 300 KB | Output is correct |
18 | Correct | 13 ms | 208 KB | Output is correct |
19 | Correct | 17 ms | 308 KB | Output is correct |
20 | Correct | 307 ms | 416 KB | Output is correct |
21 | Correct | 58 ms | 300 KB | Output is correct |
22 | Correct | 18 ms | 296 KB | Output is correct |
23 | Correct | 18 ms | 296 KB | Output is correct |
24 | Correct | 2029 ms | 292 KB | Output is correct |
25 | Correct | 194 ms | 300 KB | Output is correct |
26 | Correct | 61 ms | 292 KB | Output is correct |