# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1053990 | 2024-08-12T02:44:33 Z | huutuan | Secret Permutation (RMI19_permutation) | C++14 | 30 ms | 344 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) { if (n==3){ if (query({1, 2, 3})==2) answer({1, 2, 3}); if (query({2, 1, 3})==2) answer({2, 1, 3}); answer({3, 1, 2}); } vector<int> ans(n+1, -1); while (1){ int x=rand(1, n); int y=x; while (y==x) y=rand(1, n); if (x>y) swap(x, y); map<int, int> cnt; vector<int> dd(n+1); for (int i=1; i<=n; ++i) if (i!=x && i!=y){ vector<int> v; v.push_back(i); v.push_back(x); for (int j=1; j<=n; ++j) if (j!=i && j!=x && j!=y) v.push_back(j); v.push_back(y); int d=query(v); v.erase(v.begin()); v.push_back(i); d-=query(v); ++cnt[d]; dd[i]=d; } for (auto &j:cnt) if (j.second>=2){ int diff=abs(j.first); ans[x]=cnt[-diff]+1; ans[y]=n-cnt[diff]; int px=y; for (int k=1; k<=n; ++k) if (k!=x && k!=y && abs(dd[k])!=diff){ ans[k]=(dd[k]+ans[x]+ans[y])/2; if (ans[k]==ans[x]+1) px=k; } for (int k=1; k<=n; ++k) if (ans[k]==-1){ vector<int> v; v.push_back(k); v.push_back(y); v.push_back(x); for (int l=1; l<=n; ++l) if (l!=k && l!=x && l!=y) v.push_back(l); int dx=query(v); swap(v[0], v[1]); dx-=query(v); dx=abs(ans[x]-ans[y])-dx; v.clear(); v.push_back(k); v.push_back(x); v.push_back(px); for (int l=1; l<=n; ++l) if (l!=k && l!=px && l!=x) v.push_back(l); int dx1=query(v); swap(v[0], v[1]); dx1-=query(v); dx1=abs(ans[px]-ans[x])-dx1; if (dx<dx1){ ans[k]=ans[x]-dx; }else{ ans[k]=ans[x]+dx; } } ans.erase(ans.begin()); 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 | 2 ms | 344 KB | Partially correct |
8 | Partially correct | 1 ms | 344 KB | Partially correct |
9 | Partially correct | 2 ms | 344 KB | Partially correct |
10 | Partially correct | 2 ms | 344 KB | Partially correct |
11 | Partially correct | 1 ms | 344 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 | 3 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 | 2 ms | 344 KB | Partially correct |
8 | Partially correct | 1 ms | 344 KB | Partially correct |
9 | Partially correct | 2 ms | 344 KB | Partially correct |
10 | Partially correct | 2 ms | 344 KB | Partially correct |
11 | Partially correct | 1 ms | 344 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 | 3 ms | 344 KB | Partially correct |
17 | Partially correct | 27 ms | 344 KB | Partially correct |
18 | Partially correct | 19 ms | 344 KB | Partially correct |
19 | Partially correct | 14 ms | 344 KB | Partially correct |
20 | Partially correct | 30 ms | 340 KB | Partially correct |
21 | Partially correct | 17 ms | 344 KB | Partially correct |
22 | Partially correct | 15 ms | 344 KB | Partially correct |
23 | Partially correct | 11 ms | 344 KB | Partially correct |
24 | Partially correct | 27 ms | 344 KB | Partially correct |
25 | Partially correct | 21 ms | 344 KB | Partially correct |
26 | Partially correct | 10 ms | 344 KB | Partially correct |