# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
637797 | 2022-09-03T09:40:57 Z | ogibogi2004 | Secret Permutation (RMI19_permutation) | C++14 | 20 ms | 292 KB |
#include "permutationc.h" #include<bits/stdc++.h> using namespace std; mt19937 mt(69); /*vector<int>p; int query(vector<int>v) { int ans=0; for(int i=1;i<v.size();i++) { ans+=abs(p[v[i]]-p[v[i-1]]); } return ans; } void answer(vector<int>v) { for(auto xd:v)cout<<xd<<" "; cout<<endl; }*/ int val[256]; int dif1[256]; int dif2[256]; int c[256]; int n; void fill_with(int *arr,vector<int>v) { for(int i=0;i<v.size();i++)arr[i]=v[i]; return; } void solve(int N) { n=N; int arr[n]; vector<int>v1; for(int i=1;i<=n;i++)v1.push_back(i); vector<int>answers; fill_with(arr,v1); answers.push_back(query(arr)); for(int i=1;i<n;i++) { v1.clear(); for(int j=i;j<n;j++)v1.push_back(j+1); for(int j=0;j<i;j++)v1.push_back(j+1); fill_with(arr,v1); answers.push_back(query(arr)); } int sum=0; for(auto xd:answers)sum+=xd; sum/=(n-1); //cout<<sum<<endl; for(int i=0;i<n;i++) { dif1[i]=sum-answers[i]; } v1.clear(); answers.clear(); vector<int>v2; for(int i=0;i<n;i+=2)v2.push_back(i); for(int i=1;i<n;i+=2)v2.push_back(i); for(int i=0;i<v2.size();i++) { v1.clear(); for(int j=i;j<v2.size();j++)v1.push_back(v2[j]+1); for(int j=0;j<i;j++)v1.push_back(v2[j]+1); fill_with(arr,v1); answers.push_back(query(arr)); } sum=0; for(auto xd:answers)sum+=xd; sum/=(n-1); for(int i=0;i<v2.size();i++) { dif2[v2[i]]=sum-answers[i]; } vector<int>ans(n,0); ans[1]=ans[0]+dif1[1]; c[1]=1; for(int i=2;i<ans.size();i++) { if(dif2[i]==dif1[i-1]+dif1[i]) { c[i]=c[i-1]; } else c[i]=-c[i-1]; ans[i]=ans[i-1]+c[i]*dif1[i]; } int minans=0; for(int i=0;i<ans.size();i++)minans=min(minans,ans[i]); for(int i=0;i<ans.size();i++) { ans[i]-=minans; ans[i]+=1; } /*cout<<"difs:\n"; for(int i=0;i<n;i++) { cout<<dif1[i]<<" "; } cout<<endl; for(int i=0;i<n;i++) { cout<<dif2[i]<<" "; } cout<<endl; cout<<endl;*/ fill_with(arr,ans); answer(arr); } /*int main() { int N; cin>>N; for(int i=0;i<N;i++) { int x; cin>>x; p.push_back(x); } solve(N); }*/
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Partially correct | 1 ms | 208 KB | Partially correct |
2 | Partially correct | 1 ms | 208 KB | Partially correct |
3 | Partially correct | 0 ms | 208 KB | Partially correct |
4 | Partially correct | 0 ms | 208 KB | Partially correct |
5 | Partially correct | 1 ms | 208 KB | Partially correct |
6 | Partially correct | 0 ms | 208 KB | Partially correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Partially correct | 1 ms | 208 KB | Partially correct |
2 | Partially correct | 1 ms | 208 KB | Partially correct |
3 | Partially correct | 0 ms | 208 KB | Partially correct |
4 | Partially correct | 0 ms | 208 KB | Partially correct |
5 | Partially correct | 1 ms | 208 KB | Partially correct |
6 | Partially correct | 0 ms | 208 KB | Partially correct |
7 | Partially correct | 2 ms | 208 KB | Partially correct |
8 | Partially correct | 2 ms | 208 KB | Partially correct |
9 | Partially correct | 2 ms | 208 KB | Partially correct |
10 | Partially correct | 1 ms | 208 KB | Partially correct |
11 | Partially correct | 1 ms | 208 KB | Partially correct |
12 | Partially correct | 2 ms | 208 KB | Partially correct |
13 | Partially correct | 2 ms | 208 KB | Partially correct |
14 | Partially correct | 2 ms | 208 KB | Partially correct |
15 | Partially correct | 2 ms | 208 KB | Partially correct |
16 | Partially correct | 2 ms | 208 KB | Partially correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Partially correct | 1 ms | 208 KB | Partially correct |
2 | Partially correct | 1 ms | 208 KB | Partially correct |
3 | Partially correct | 0 ms | 208 KB | Partially correct |
4 | Partially correct | 0 ms | 208 KB | Partially correct |
5 | Partially correct | 1 ms | 208 KB | Partially correct |
6 | Partially correct | 0 ms | 208 KB | Partially correct |
7 | Partially correct | 2 ms | 208 KB | Partially correct |
8 | Partially correct | 2 ms | 208 KB | Partially correct |
9 | Partially correct | 2 ms | 208 KB | Partially correct |
10 | Partially correct | 1 ms | 208 KB | Partially correct |
11 | Partially correct | 1 ms | 208 KB | Partially correct |
12 | Partially correct | 2 ms | 208 KB | Partially correct |
13 | Partially correct | 2 ms | 208 KB | Partially correct |
14 | Partially correct | 2 ms | 208 KB | Partially correct |
15 | Partially correct | 2 ms | 208 KB | Partially correct |
16 | Partially correct | 2 ms | 208 KB | Partially correct |
17 | Partially correct | 18 ms | 292 KB | Partially correct |
18 | Partially correct | 20 ms | 288 KB | Partially correct |
19 | Partially correct | 14 ms | 208 KB | Partially correct |
20 | Partially correct | 15 ms | 208 KB | Partially correct |
21 | Partially correct | 13 ms | 288 KB | Partially correct |
22 | Partially correct | 14 ms | 288 KB | Partially correct |
23 | Partially correct | 13 ms | 208 KB | Partially correct |
24 | Partially correct | 14 ms | 288 KB | Partially correct |
25 | Partially correct | 16 ms | 292 KB | Partially correct |
26 | Partially correct | 15 ms | 208 KB | Partially correct |