# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
685411 | 2023-01-24T10:19:39 Z | annie2018 | Secret Permutation (RMI19_permutation) | C++17 | 5000 ms | 208 KB |
#include <bits/stdc++.h> #include "permutation.h" using namespace std; vector <int> ans, v; void get(vector<int> &q, int n) { vector <int> a(n); for (int i = 1; i <= n; i++) a[i - 1] = i; bool f = 1; do { f = 1; for (int i = 0; i < n - 1; i++) if (abs(a[v[i] - 1] - a[v[i + 1] - 1]) != q[i]) f = 0; if (abs(a[v[0] - 1] - a[v[n - 1] - 1]) != q[n - 1]) f = 0; if (f) { ans = a; return; } } while (next_permutation(a.begin(), a.end())); } void solve(int n) { 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()); vector <int> q(n); for(int i = 0; i < n; i++) { q[i] = query(v); rotate(v.begin(),v.begin()+1,v.end()); } int sum = 0; for(int i = 0; i < n; i++) sum += q[i]; sum /= (n - 1); for(int i = 0; i < n; i++) q[i] = (sum - q[i]); rotate(q.begin(), q.begin() + 1, q.end()); /*for (int i = 0; i < n; i++) cout << q[i] << ' '; cout << "\n";*/ //ans.assign(n, 0); get(q, n); 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 | 1 ms | 208 KB | Output is correct |
4 | Correct | 1 ms | 208 KB | Output is correct |
5 | Correct | 1 ms | 208 KB | Output is correct |
6 | Correct | 0 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 | 1 ms | 208 KB | Output is correct |
4 | Correct | 1 ms | 208 KB | Output is correct |
5 | Correct | 1 ms | 208 KB | Output is correct |
6 | Correct | 0 ms | 208 KB | Output is correct |
7 | Execution timed out | 5062 ms | 208 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |
# | 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 | 1 ms | 208 KB | Output is correct |
4 | Correct | 1 ms | 208 KB | Output is correct |
5 | Correct | 1 ms | 208 KB | Output is correct |
6 | Correct | 0 ms | 208 KB | Output is correct |
7 | Execution timed out | 5062 ms | 208 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |