#include "gondola.h"
#include <algorithm>
#include <iostream>
#include <cassert>
#include <numeric>
#include <vector>
#include <set>
typedef long long llong;
const int MAXN = 100000 + 10;
const int INF = 1e9;
std::set <int> s;
int n;
int getPosDiff(int last, int curr)
{
if (last > curr)
{
return n - last + curr;
}
return curr - last;
}
int valid(int N, int inputSeq[])
{
n = N;
int minPos = 0;
for (int i = 1 ; i < n ; ++i)
{
if (s.count(inputSeq[i]))
{
return 0;
}
s.insert(inputSeq[i]);
if (inputSeq[i] < inputSeq[minPos])
{
minPos = i;
}
}
if (inputSeq[minPos] > n)
{
return 1;
}
for (int i = minPos - 1 ; i >= std::max(0, minPos - inputSeq[minPos] + 1) ; --i)
{
if (inputSeq[i] <= n)
{
return 0;
}
}
if (minPos + 1 < inputSeq[minPos])
{
for (int i = n - 1 ; i >= n + minPos + 1 - inputSeq[minPos] ; --i)
{
if (inputSeq[i] <= n)
{
return 0;
}
}
}
int lastPos = minPos;
int last = inputSeq[minPos];
for (int i = minPos + 1 ; i < n ; ++i)
{
if (inputSeq[i] <= n)
{
if (last > inputSeq[i])
{
return 0;
}
if (getPosDiff(lastPos, i) != inputSeq[i] - last)
{
return 0;
}
last = inputSeq[i];
lastPos = i;
}
}
for (int i = 1 ; i < minPos ; ++i)
{
if (inputSeq[i] <= n)
{
if (last > inputSeq[i])
{
return 0;
}
if (getPosDiff(lastPos, i) != inputSeq[i] - last)
{
return 0;
}
last = inputSeq[i];
lastPos = i;
}
}
return 1;
}
//----------------------
int a[MAXN];
int replacement(int N, int gondolaSeq[], int replacementSeq[])
{
return -2;
n = N;
int minPos = 0;
for (int i = 1 ; i < n ; ++i)
{
if (gondolaSeq[i] < gondolaSeq[minPos])
{
minPos = i;
}
}
// int cnt = inPu
// for (int i = minPos - 1 )
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
10 ms |
2268 KB |
Output is correct |
7 |
Correct |
6 ms |
724 KB |
Output is correct |
8 |
Correct |
18 ms |
3988 KB |
Output is correct |
9 |
Correct |
6 ms |
1492 KB |
Output is correct |
10 |
Correct |
23 ms |
4624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
312 KB |
Output is correct |
6 |
Correct |
10 ms |
2316 KB |
Output is correct |
7 |
Correct |
7 ms |
732 KB |
Output is correct |
8 |
Correct |
24 ms |
4052 KB |
Output is correct |
9 |
Correct |
6 ms |
1556 KB |
Output is correct |
10 |
Correct |
25 ms |
4612 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
11 ms |
2168 KB |
Output is correct |
14 |
Correct |
1 ms |
316 KB |
Output is correct |
15 |
Correct |
29 ms |
4808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
316 KB |
Integer -2 violates the range [0, 350000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
312 KB |
Integer -2 violates the range [0, 350000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Integer -2 violates the range [0, 350000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
312 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
316 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
316 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |