# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
232488 | 2020-05-17T07:38:48 Z | tjd229 | Secret Permutation (RMI19_permutation) | C++14 | 5 ms | 256 KB |
#include "permutation.h" #include <vector> using namespace std; int Tx[257], x[257]; int use[257]; int _N; bool recon(int ix,vector<int> &P) { int bk = P.back(); // if (ix == _N) { int d = bk - P[0]; if (d < 0) d = -d; return d == x[1]; } int nxt = bk + x[ix+1]; if (nxt <= _N && use[nxt] == 0) { use[nxt] = 1; P.push_back(nxt); if (recon(ix + 1, P)) return 1; P.pop_back(); use[nxt] = 0; } nxt = bk - x[ix+1]; if (nxt > 0 && use[nxt] == 0) { use[nxt] = 1; P.push_back(nxt); if (recon(ix + 1, P)) return 1; P.pop_back(); use[nxt] = 0; } return 0; } void solve(int N) { _N = N; int sum = 0; vector<int> P; for (int i = 1; i <= N; ++i) { vector<int> V; for (int j = 0; j < N; ++j) { int x = i + j; if (x > N) x -= N; V.push_back(x); } Tx[i]=query(V); sum += Tx[i]; use[i] = 0; } int T = sum / (N - 1); for (int i = 1; i <= N; ++i) x[i] = T-Tx[i] ; for (int i = 1; i <= N; ++i) { P.push_back(i); use[i] = 1; if (recon(1, P)) { answer(P); break; } P.pop_back(); use[i] = 0; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Incorrect | 4 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Incorrect | 4 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Incorrect | 4 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |