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;
#define f(i,a,b) for(int i = a; i < b; i++)
const int N = 250005;
int cant[N];
int valid(int n, int X[]){
f(i,0,n) cant[X[i]]++;
int ct = 0, id;
f(i,1,N) {
if(cant[i] > 1) return 0;
if(i <= n) ct++;
}
if(ct == 0) return 1;
f(i,0,n) if(X[i] <= n) id = i;
vector <int> a, v1, v2;
int pr = X[id]-1;
f(i,0,n-id){
pr++;
if(pr == n) pr = 1;
v2.push_back(pr);
}
f(i,0,id){
pr++;
if(pr == n) pr = 1;
v1.push_back(pr);
}
for(int x: v1) a.push_back(x);
for(int x: v2) a.push_back(x);
int ans = 1;
f(i,0,n) if(a[i] <= n and a[i] != X[i]) ans = 0;
return ans;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
return -2;
}
int countReplacement(int n, int inputSeq[])
{
return -3;
}
Compilation message (stderr)
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:21:16: warning: 'id' may be used uninitialized in this function [-Wmaybe-uninitialized]
21 | int pr = X[id]-1;
| ^~
# | 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... |