This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |