#include <iostream>
#include <algorithm>
#include <vector>
#include "gondola.h"
#define MAX 250000
using namespace std;
int mark[MAX + 10];
vector <pair <int, int>> v;
int valid(int n, int inputSeq[])
{
int posOrig = -1;
for (int i = 0; i < n; i++)
{
if (mark[inputSeq[i]] == 1)
return 0;
if (inputSeq[i] <= n)
posOrig = i;
mark[inputSeq[i]] = 1;
}
if (posOrig == -1)
return 1;
int pos = posOrig;
for (int i = 1; i <= n; i++)
{
if (inputSeq[pos] <= n && (inputSeq[pos] - inputSeq[posOrig] + n) % n != (pos - posOrig + n) % n)
return 0;
pos = (pos + 1) % n;
}
return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int posOrig = -1;
for (int i = 0; i < n; i++)
if (gondolaSeq[i] <= n)
posOrig = i;
if (posOrig == -1)
for (int i = 0; i < n; i++)
v.push_back({gondolaSeq[i], i + 1});
else
{
int pos = posOrig;
int ind = gondolaSeq[posOrig];
for (int i = 1; i <= n; i++)
{
if (gondolaSeq[pos] > n)
v.push_back({gondolaSeq[pos], ind});
pos = (pos + 1) % n;
if (ind == n - 1)
ind = (ind + 1) % n + n;
else
ind = (ind + 1) % n;
}
}
sort(v.begin(), v.end());
int l = 0, nn = n + 1;
for (auto it : v)
{
replacementSeq[l] = it.second;
l++;
nn++;
while (nn <= it.first)
{
replacementSeq[l] = nn - 1;
l++;
nn++;
}
}
return l;
}
Compilation message
/usr/bin/ld: /tmp/ccFAFO0h.o: in function `main':
grader.cpp:(.text.startup+0x108): undefined reference to `countReplacement'
collect2: error: ld returned 1 exit status