# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1054082 | 2024-08-12T06:02:53 Z | huutuan | Secret Permutation (RMI19_permutation) | C++14 | 15 ms | 596 KB |
#include "permutation.h" #include <bits/stdc++.h> using namespace std; mt19937 rng(69420); int rand(int l, int r){ return uniform_int_distribution<int>(l, r)(rng); } void solve(int n) { vector<int> ans(n+1); vector<int> v(n); iota(v.begin(), v.end(), 1); vector<int> d1(n+1); for (int i=0; i<n; ++i){ d1[v[0]]=query(v); rotate(v.begin(), v.begin()+1, v.end()); } int sum=accumulate(d1.begin(), d1.end(), 0)/(n-1); for (int &i:d1) i=sum-i; vector<int> d2(n+1); sort(v.begin(), v.end(), [&](int x, int y){ if ((x&1)!=(y&1)) return (x&1)<(y&1); return x<y; }); for (int i=0; i<n; ++i){ d2[v[0]]=query(v); rotate(v.begin(), v.begin()+1, v.end()); } sum=accumulate(d2.begin(), d2.end(), 0)/(n-1); for (int &i:d2) i=sum-i; if (d1[2]+d1[3]==d2[3]){ ans[2]=ans[1]+d1[2]; ans[3]=ans[2]+d1[3]; }else if (d1[2]+d2[3]==d1[3]){ ans[1]=ans[2]+d1[2]; ans[3]=ans[1]+d2[3]; }else{ ans[3]=ans[1]+d2[3]; ans[2]=ans[3]+d1[3]; } for (int i=4; i<=n; ++i){ int t1=ans[i-1]+d1[i]; int t2=ans[i-1]-d1[i]; if (abs(t1-ans[i-2])==d2[i]) ans[i]=t1; else ans[i]=t2; } ans.erase(ans.begin()); int mn=*min_element(ans.begin(), ans.end()); for (int &i:ans) i-=mn-1; answer(ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 1 ms | 344 KB | Partially correct |
2 | Partially correct | 0 ms | 344 KB | Partially correct |
3 | Partially correct | 0 ms | 344 KB | Partially correct |
4 | Partially correct | 0 ms | 344 KB | Partially correct |
5 | Partially correct | 0 ms | 344 KB | Partially correct |
6 | Partially correct | 0 ms | 344 KB | Partially correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 1 ms | 344 KB | Partially correct |
2 | Partially correct | 0 ms | 344 KB | Partially correct |
3 | Partially correct | 0 ms | 344 KB | Partially correct |
4 | Partially correct | 0 ms | 344 KB | Partially correct |
5 | Partially correct | 0 ms | 344 KB | Partially correct |
6 | Partially correct | 0 ms | 344 KB | Partially correct |
7 | Partially correct | 1 ms | 344 KB | Partially correct |
8 | Partially correct | 1 ms | 344 KB | Partially correct |
9 | Partially correct | 1 ms | 344 KB | Partially correct |
10 | Partially correct | 1 ms | 344 KB | Partially correct |
11 | Partially correct | 1 ms | 596 KB | Partially correct |
12 | Partially correct | 1 ms | 344 KB | Partially correct |
13 | Partially correct | 1 ms | 344 KB | Partially correct |
14 | Partially correct | 1 ms | 344 KB | Partially correct |
15 | Partially correct | 1 ms | 344 KB | Partially correct |
16 | Partially correct | 1 ms | 344 KB | Partially correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 1 ms | 344 KB | Partially correct |
2 | Partially correct | 0 ms | 344 KB | Partially correct |
3 | Partially correct | 0 ms | 344 KB | Partially correct |
4 | Partially correct | 0 ms | 344 KB | Partially correct |
5 | Partially correct | 0 ms | 344 KB | Partially correct |
6 | Partially correct | 0 ms | 344 KB | Partially correct |
7 | Partially correct | 1 ms | 344 KB | Partially correct |
8 | Partially correct | 1 ms | 344 KB | Partially correct |
9 | Partially correct | 1 ms | 344 KB | Partially correct |
10 | Partially correct | 1 ms | 344 KB | Partially correct |
11 | Partially correct | 1 ms | 596 KB | Partially correct |
12 | Partially correct | 1 ms | 344 KB | Partially correct |
13 | Partially correct | 1 ms | 344 KB | Partially correct |
14 | Partially correct | 1 ms | 344 KB | Partially correct |
15 | Partially correct | 1 ms | 344 KB | Partially correct |
16 | Partially correct | 1 ms | 344 KB | Partially correct |
17 | Partially correct | 8 ms | 344 KB | Partially correct |
18 | Partially correct | 7 ms | 344 KB | Partially correct |
19 | Partially correct | 7 ms | 344 KB | Partially correct |
20 | Partially correct | 8 ms | 344 KB | Partially correct |
21 | Partially correct | 15 ms | 344 KB | Partially correct |
22 | Partially correct | 7 ms | 344 KB | Partially correct |
23 | Partially correct | 7 ms | 344 KB | Partially correct |
24 | Partially correct | 7 ms | 344 KB | Partially correct |
25 | Partially correct | 9 ms | 344 KB | Partially correct |
26 | Partially correct | 7 ms | 344 KB | Partially correct |