Submission #1099271

#TimeUsernameProblemLanguageResultExecution timeMemory
1099271LuvidiGondola (IOI14_gondola)C++17
55 / 100
13 ms2396 KiB
#include <bits/stdc++.h> #include "gondola.h" using namespace std; int valid(int n, int a[]) { set<int> s; int sh=0; for(int i=0;i<n;i++){ if(a[i]>n){ if(s.count(a[i]))return 0; s.insert(a[i]); }else{ sh=i+1-a[i]; } } for(int i=0;i<n;i++){ int idx=i+sh; idx=(idx%n+n)%n; if(a[idx]<=n&&a[idx]!=i+1)return 0; } return 1; } //---------------------- int replacement(int n, int a[], int b[]) { int a2[n]; vector<pair<int,int>> v; int sh=0; for(int i=0;i<n;i++){ if(a[i]>n){ v.push_back({a[i],i}); }else{ sh=i+1-a[i]; } } for(int i=0;i<n;i++){ int idx=i+sh; idx=(idx%n+n)%n; a2[idx]=i+1; } sort(begin(v),end(v)); int last=n,cnt=0; for(auto[x,i]:v){ b[cnt++]=a2[i]; last++; while(last<x){ b[cnt++]=last++; } } return cnt; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }
#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...