#include "gondola.h"
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
#define UNDEF -1
typedef pair<int, int> pii;
long long mod = 1000000009;
int valid(int n, int inputSeq[])
{
vector<int> L;
L.resize(n);
int temp;
int shift = -1;
for (int i=0; i<n; i++){
L[i] = inputSeq[i];
if (L[i] <= n){
temp = (i-L[i]+n+1)%n;
if (shift == UNDEF) shift = temp;
else if (shift != temp) return 0;
}
}
sort(L.begin(), L.end());
for (int i=1; i<n; i++) if (L[i-1] == L[i]) return 0;
L.clear();
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int min_val = 1000000, min_index = -1;
vector<pii> L;
for (int i=0; i<n; i++){
if (min_val > gondolaSeq[i]){
min_index = i;
min_val = gondolaSeq[i];
}
}
bool b = (min_val > n);
for (int j=0; j<n; j++){
int i = min_index + j;
int c;
if (b) c = j;
else{
c = (j + min_val)%n;
}
L.push_back(pii(gondolaSeq[i%n], (c == 0 ? n : c)));
}
sort(L.begin(), L.end());
int l = 0;
for (int i=0; i<n; i++){
while (L[i].first != L[i].second){
replacementSeq[l] = L[i].second;
l++;
L[i].second = n+l;
}
}
return l;
}
//----------------------
long long llpow(int a, int b){
if (b%2 == 0) return (llpow(a, b/2) * llpow(a, b/2))%mod;
return (llpow(a, b-1) * a) % mod;
}
int pow(int a, int b){
return (int) llpow(a, b);
}
int countReplacement(int n, int inputSeq[])
{
if (!valid(n, inputSeq)) return 0;
int min_val = 1000000, min_index = -1;
vector<pii> L;
for (int i=0; i<n; i++){
if (min_val > gondolaSeq[i]){
min_index = i;
min_val = gondolaSeq[i];
}
}
bool b = (min_val > n);
for (int j=0; j<n; j++){
int i = min_index + j;
int c;
if (b) c = j;
else{
c = (j + min_val)%n;
}
L.push_back(pii(gondolaSeq[i%n], (c == 0 ? n : c)));
}
sort(L.begin(), L.end());
int ans = 0;
for (int i=0; i<n; i++){
ans = 1;
}
return -1
}
Compilation message
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:83:17: error: 'gondolaSeq' was not declared in this scope
if (min_val > gondolaSeq[i]){
^~~~~~~~~~
gondola.cpp:96:20: error: 'gondolaSeq' was not declared in this scope
L.push_back(pii(gondolaSeq[i%n], (c == 0 ? n : c)));
^~~~~~~~~~
gondola.cpp:104:1: error: expected ';' before '}' token
}
^