# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
443727 | 2021-07-11T18:55:39 Z | valerikk | Secret Permutation (RMI19_permutation) | C++17 | 1 ms | 200 KB |
#include <bits/stdc++.h> #ifdef EVAL #include "permutation.h" #endif typedef long long ll; using namespace std; mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); #ifndef EVAL int N; int P[256 + 10]; #endif int query_(vector<int> v) { #ifdef EVAL for (int &i : v) { i++; } return query(v); #else int sum = 0; for (int i = 1; i < v.size(); i++) sum += abs(P[v[i]] - P[v[i - 1]]); return sum; #endif } void answer_(vector<int> p) { for (int &i : p) { i++; } #ifdef EVAL answer(p); #else for (int i = 0; i < p.size(); i++) cout << p[i] << " "; exit(0); #endif } void solve(int n) { if (n <= 7) { vector<int> p(n); iota(p.begin(), p.end(), 0); shuffle(p.begin(), p.end(), rnd); vector<int> d(n); for (int i = 0; i < n; i++) { d[p[n - 1]] = query_(p); rotate(p.begin(), p.begin() + 1, p.end()); } int sum = 0; for (int i = 0; i < n; i++) sum += d[i]; sum /= n - 1; for (int i = 0; i < n; i++) d[i] = sum - d[i]; vector<int> q(n); iota(q.begin(), q.end(), 0); do { bool ok = true; for (int i = 0; i < n; i++) ok &= d[p[i]] == abs(q[p[i]] - q[p[(i + 1) % n]]); if (ok) answer_(q); } while (next_permutation(q.begin(), q.end())); } } #ifndef EVAL int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> P[i]; P[i]--; } solve(N); } #endif
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 200 KB | Output is correct |
2 | Correct | 0 ms | 200 KB | Output is correct |
3 | Correct | 1 ms | 200 KB | Output is correct |
4 | Correct | 1 ms | 200 KB | Output is correct |
5 | Correct | 1 ms | 200 KB | Output is correct |
6 | Correct | 1 ms | 200 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 200 KB | Output is correct |
2 | Correct | 0 ms | 200 KB | Output is correct |
3 | Correct | 1 ms | 200 KB | Output is correct |
4 | Correct | 1 ms | 200 KB | Output is correct |
5 | Correct | 1 ms | 200 KB | Output is correct |
6 | Correct | 1 ms | 200 KB | Output is correct |
7 | Incorrect | 0 ms | 200 KB | Unexpected end of file - int32 expected |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 200 KB | Output is correct |
2 | Correct | 0 ms | 200 KB | Output is correct |
3 | Correct | 1 ms | 200 KB | Output is correct |
4 | Correct | 1 ms | 200 KB | Output is correct |
5 | Correct | 1 ms | 200 KB | Output is correct |
6 | Correct | 1 ms | 200 KB | Output is correct |
7 | Incorrect | 0 ms | 200 KB | Unexpected end of file - int32 expected |
8 | Halted | 0 ms | 0 KB | - |