#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
int valid(int n, int inputSeq[]) {
vector <int> a(n);
for (int i = 0;i < n;i++) {
if (inputSeq[i] > n) {
a[i] = 0;
}
else {
a[i] = inputSeq[i];
}
}
bool pos = false;
int idx = 0;
for (int i = 0;i < n;i++) {
if (a[i] != 0 && pos == false) {
pos = true;
idx = i;
}
}
int idy = idx + 1;
if (pos == false) {
return 1;
}
while (idy != idx) {
if (idy == 0) {
if (a[idy] != 0 && a[idy] != (a[n - 1] % n + 1)) {
pos = false;
break;
}
else if (a[idy] == 0) {
a[idy] = a[n - 1] % n + 1;
}
}
else {
if (a[idy] != 0 && a[idy] != (a[idy - 1] % n + 1)) {
pos = false;
break;
}
else if (a[idy] == 0) {
a[idy] = a[idy - 1] % n + 1;
}
// cout << 'a';
}
idy++;
idy %= n;
}
return pos;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
return -2;
}
//----------------------
int countReplacement(int n, int inputSeq[]) {
return -3;
}
//int main() {
// int arr[5] = {1, 2, 3, 4, 6};
// cout << valid(5, arr) << endl;
//}
| # | 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... |