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;
int valid(int n, int inputSeq[])
{
map<int,int> mp;
int p = -1;
for (int i = 0; i < n; ++i)
{
if (mp[inputSeq[i]]) return 0;
mp[inputSeq[i]]++;
}
for (int i = 0; i < n; i++){
if (inputSeq[i]<=n){
p=i;
break;
}
}
if (p==-1) return 1;
for (int i = 0; i < n; i++){
if (inputSeq[i]>n) continue;
int step = i-p;
if (i<p) step = n-p+i;
int a = inputSeq[p]-1;
a+=step;
a%=n;
a++;
if (inputSeq[i]!=a) return 0;
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
pair<int,int> v[n];
for (int i = 0; i < n; ++i)
{
v[i]={gondolaSeq[i],i};
}
sort(v,v+n);
int cnt = 0;
for (int i = 0; i < n; i++){
if (v[i].first<=n) continue;
while (cnt<v[i].first-n) replacementSeq[cnt++]=v[i].second;
}
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... |