#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
int prev(int in, int n)
{
return (--in + n) % n;
}
int next(int in, int n)
{
return ++in % n;
}
map<int, int> pos;
map<int, int> freq;
int valid(int n, int inputSeq[])
{
for (int i = 0; i < n; i++)
{
pos[inputSeq[i]] = i;
freq[inputSeq[i]]++;
}
vi sortedInput(inputSeq, inputSeq + n);
sort(sortedInput.begin(), sortedInput.end());
bool ans = true;
int expectedMax = n;
for (int i = 0; i < n; i++)
{
int cur = sortedInput[i];
int nxt = sortedInput[next(i, n)];
int gap = nxt - cur;
if (gap == 1 || i == n - 1)
ans &= (pos[nxt] == next(pos[cur], n));
else
expectedMax += gap;
ans &= freq[cur] == 1;
}
return (ans && (expectedMax == sortedInput.back()));
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
return -2;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
308 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
24 ms |
4240 KB |
Output is correct |
7 |
Correct |
54 ms |
7480 KB |
Output is correct |
8 |
Correct |
50 ms |
8076 KB |
Output is correct |
9 |
Correct |
16 ms |
2752 KB |
Output is correct |
10 |
Correct |
59 ms |
9192 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
308 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
25 ms |
4300 KB |
Output is correct |
7 |
Correct |
55 ms |
7512 KB |
Output is correct |
8 |
Correct |
45 ms |
7860 KB |
Output is correct |
9 |
Correct |
14 ms |
2752 KB |
Output is correct |
10 |
Correct |
67 ms |
9224 KB |
Output is correct |
11 |
Correct |
1 ms |
304 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
28 ms |
4028 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
74 ms |
9524 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Integer -2 violates the range [0, 350000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Integer -2 violates the range [0, 350000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Integer -2 violates the range [0, 350000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
308 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |