# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
331738 | 2020-11-29T19:56:41 Z | Sho10 | Secret Permutation (RMI19_permutation) | C++14 | 1 ms | 364 KB |
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10 #define ll long long #include "permutation.h" #define double long double #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #define all(a) (a).begin(), (a).end() #define f first #define s second #define pb push_back #define mp make_pair #define pi pair #define rc(s) return cout<<s,0 #define endl '\n' #define mod 1000007 #define PI 3.14159265359 #define MAXN 100005 #define INF 1000000005 #define LINF 1000000000000000005ll #define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; ll a[300],b[300],nr[300],n; ll calc(ll pos,ll l,ll r){ vector<int>v; v.pb(l); v.pb(r); v.pb(pos); for(ll i=1;i<=n;i++) { if(i!=l&&i!=r&&i!=pos){ v.pb(i); } } ll x=query(v); v.clear(); v.pb(r); v.pb(l); v.pb(pos); for(ll i=1;i<=n;i++) { if(i!=l&&i!=r&&i!=pos){ v.pb(i); } } ll y=query(v); return x-y; } void solve(int N){ n=N; for(ll i=1;i+2<=n;i++) { a[i]=calc(i,i+1,i+2); } for(ll i=2;i<n;i++) b[i]=calc(i,i-1,i+1); vector<int>ans; for(ll i=1;i<=n;i++) { for(ll j=1;j<=n;j++) { if(i==j){ continue; } ans.clear(); ans.pb(i); ans.pb(j); ll check=0; while(ans.size()<n){ ll s1,s2,s3; s1=abs(ans.back()-ans[ans.size()-2]); s2=abs(a[ans.size()-1]+s1); s3=abs(b[ans.size()]+s1); ll x,y; x=ans[ans.size()-2]; y=ans.back(); if(s2==s3+s1){ if(x>y){ ans.pb(x-s2); }else ans.pb(x+s2); }else if(s3==s1+s2){ if(x>y){ ans.pb(x+s2); }else ans.pb(x-s2); }else if(s1==s2+s3){ if(x>y){ ans.pb(x-s2); }else ans.pb(x+2); }else { check=1; break; } } for(auto it : ans){ if(it<1||it>n){ check=1; } } if(check==0){ memset(nr,0,sizeof(nr)); for(auto it : ans){ if(nr[it]){ check=0; break; } nr[it]=1; } } if(check==0){ answer(ans); return; } } } answer(ans); } /* int32_t main(){ CODE_START; */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |