#include "gondola.h"
#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int b[N], ind[N], mx, sz;
int valid(int n, int inputSeq[])
{
memset(ind, -1, sizeof(ind));
int pos = -1;
for (int i = 0; i < n; i++) {
if (a[i] <= n) {
pos = i;
}
if (a[i] > a[mx]) {
mx = i;
}
ind[a[i]] = i;
}
if (pos == -1) {
for (int i = 0; i < n; i++) {
b[i] = i + 1;
}
}
else {
int cn = 1;
b[pos] = a[pos];
for (int i = (pos + 1) % n; i != pos; i = (i + 1) % n) {
b[i] = a[pos] + cn;
cn++;
}
}
for (int i = 0; i < n; i++) {
if (a[i] > n) continue;
if (a[i] != b[i])
return 0;
}
return 1;
}
int replacement(int n, int a[], int ans[])
{
memset(ind, -1, sizeof(ind));
int pos = -1;
for (int i = 0; i < n; i++) {
if (a[i] <= n) {
pos = i;
}
if (a[i] > a[mx]) {
mx = i;
}
ind[a[i]] = i;
}
if (pos == -1) {
for (int i = 0; i < n; i++) {
b[i] = i + 1;
}
}
else {
int cn = 1;
b[pos] = a[pos];
for (int i = (pos + 1) % n; i != pos; i = (i + 1) % n) {
b[i] = a[pos] + cn;
cn++;
}
}
for (int i = n + 1; i <= a[mx]; i++) {
if (ind[i] == -1) {
ans[sz++] = b[mx];
b[mx] = i;
}
else {
ans[sz++] = b[ind[i]];
b[ind[i]] = i;
}
}
return sz;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
Compilation message
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:17:7: error: 'a' was not declared in this scope
if (a[i] <= n) {
^
gondola.cpp:20:7: error: 'a' was not declared in this scope
if (a[i] > a[mx]) {
^
gondola.cpp:23:7: error: 'a' was not declared in this scope
ind[a[i]] = i;
^
gondola.cpp:32:12: error: 'a' was not declared in this scope
b[pos] = a[pos];
^
gondola.cpp:39:7: error: 'a' was not declared in this scope
if (a[i] > n) continue;
^
gondola.cpp:40:7: error: 'a' was not declared in this scope
if (a[i] != b[i])
^