Submission #598125

#TimeUsernameProblemLanguageResultExecution timeMemory
598125enerelt14Gondola (IOI14_gondola)C++14
35 / 100
17 ms3080 KiB
#include "gondola.h" #include<bits/stdc++.h> using namespace std; int valid(int n, int inputSeq[]){ int k=n+1, s; for (int i=0;i<n;i++){ if (i>n)continue; s=inputSeq[i]-i; if (k==n+1)k=s; if (k!=s && min(k, s)+n!=max(k, s))return 0; } return 1; } int replacement(int n, int gondolaSeq[], int replacementSeq[]){ int mx=0, k=1; for (int i=0;i<n;i++)mx=max(mx, gondolaSeq[i]); bool vis[mx+1]={0}; int pos[mx+1], a[n]; for (int i=0;i<n;i++){ vis[gondolaSeq[i]]=1; pos[gondolaSeq[i]]=i; if (gondolaSeq[i]<=n)k=gondolaSeq[i]-i; } for (int i=0;i<n;i++){ a[i]=k+i; if (a[i]<=0)a[i]+=n; } for (int i=n+1;i<=mx;i++){ if (vis[i]){ replacementSeq[i-n-1]=a[pos[i]]; a[pos[i]]=i; continue; } replacementSeq[i-n-1]=a[pos[mx]]; a[pos[mx]]=i; } return mx-n; } int countReplacement(int n, int inputSeq[]){ return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...