# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
239385 | 2020-06-15T13:08:20 Z | Sorting | Secret Permutation (RMI19_permutation) | C++14 | 5 ms | 256 KB |
#include <bits/stdc++.h> //#include "permutationc.h" using namespace std; int query(int v[]); int query(vector<int> v); void answer(int v[]); void answer(vector<int> v); void recursion(const vector<int> &v, const vector<int> &arr, vector<int> &ans, vector<int> &vis, int pos){ if(pos == v.size() - 1){ if(abs(ans[0] - ans[v.size() - 1]) == arr[pos]){ answer(ans); exit(0); } return; } int choice1 = (ans[pos] + arr[pos] - 1) % v.size() + 1; int choice2 = (ans[pos] - arr[pos - 1] - 1 + v.size()) % v.size() + 1; if(!vis[choice1]){ ans[pos + 1] = choice1; vis[choice1] = true; recursion(v, arr, ans, vis, pos + 1); ans[pos + 1] = 0; vis[choice1] = false; } if(choice2 != choice1 && !vis[choice2]){ ans[pos + 1] = choice2; vis[choice2] = true; recursion(v, arr, ans, vis, pos + 1); ans[pos + 1] = 0; vis[choice2] = false; } } void solve(int n){ vector<int> v; for(int i = 1; i <= n; ++i) v.push_back(i); vector<int> arr(n + 1); for(int i = 0; i < n; ++i){ rotate(v.begin(), v.begin() + 1, v.end()); arr[i] = query(v); } int sum = 0; for(int i = 0; i < n; ++i) sum += arr[i]; sum /= n - 1; for(int i = 0; i < n; ++i) arr[i] = sum - arr[i]; vector<int> ans(n), vis(n + 1, false); for(int i = 1; i <= n; ++i){ ans[0] = i; vis[i] = true; recursion(v, arr, ans, vis, 0); ans[0] = 0; vis[i] = false; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 256 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 256 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 256 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |