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;
set<int> visited;
int valid(int n,int input[]){
for(int i=0;i<n;i++)
if(visited.find(input[i])!=visited.end())
return 0;
else
visited.insert(input[i]);
int start = -1;
for(int i=0;i<n;i++)if(input[i]<=n){
start = i;
break;
}
if(start==-1)return 1;
int next = input[start];
int pos = start;
for(int i=0;i<n;i++){
if(input[pos]<=n&&input[pos]!=next)return 0;
pos++;
if(pos>=n)pos=0;
next++;
if(next>n)next=1;
}
return 1;
}
pair<int,int> x[200002];
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
int start = 0;
for(int i=0;i<n;i++){
if(gondolaSeq[i]<=n){start = i;break;}
}
int next = gondolaSeq[start]<=n?gondolaSeq[start]:1;
vector<pair<int,int>> vec;
int pos = 0;
for(int i=0;i<n;i++){
x[i] = {gondolaSeq[pos++],next++};
if(next>n)next = 1;
if(pos>=n)pos=0;
}
sort(x,x+n);
int last = n;
int l = 0;
for(int i=0;i<n;i++){
while(x[i].first != x[i].second){
replacementSeq[l++] = x[i].second;
x[i].second = ++last;
}
}
return l;
}
int countReplacement(int n, int inputSeq[]){
return 0;
}
# | 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... |