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 "gondola.h"
#include <bits/stdc++.h>
using namespace std;
//valid
vector<pair<int,int>> input;//(val,id)
vector<pair<int,int>> rep;//(val,id)
int valid(int n, int inputSeq[])
{
for(int i=0;i<n;i++){
input.push_back({inputSeq[i],i});
}
sort(input.begin(),input.end());
int prev=-1;
for(int i=0;i<n;i++){
if(input[i].first==prev) return 0;
prev=input[i].first;
}
int prev_pos=-1;
for(int i=0;i<n&&input[i].first<=n;i++){
if((i!=0)&&((input[i].first-prev)!=((input[i].second-prev_pos+n)%n))){
return 0;
}
prev=input[i].first;
prev_pos=input[i].second;
}
return 1;
}
//----------------------
int mod1(int x,int m){
x%=m;
if(x==0) x=m;
return x;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int extra=0;
for(int i=0;i<n;i++){
if(gondolaSeq[i]>n) rep.push_back({gondolaSeq[i],i});
else extra=(gondolaSeq[i]-i+n)%n;
}
for(auto& p:rep){
p.second+=extra;
p.second=mod1(p.second,n);
}
sort(rep.begin(),rep.end());
int l=0;
int prev=n;
for(auto p:rep){
replacementSeq[l]=p.second;
l++;
for(int i=prev+1;i<p.first;i++){
replacementSeq[l]=i;
l++;
}
prev=p.first;
}
return l;
}
//----------------------
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... |