#include "gondola.h"
#include <vector>
#include <algorithm>
int valid(int n, int inputSeq[])
{
int i, r = -1;
for (i = 0; i < n; i++)
{
if (inputSeq[i] <= n)
{
if (r == -1)
r = (inputSeq[i] + n - (i + 1))%n;
else if ((inputSeq[i] + n - (i + 1))%n != r)
return 0;
}
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int i, r = -1;
for (i = 0; i < n; i++)
{
if (gondolaSeq[i] <= n)
{
if (r == -1)
{
r = (gondolaSeq[i] + n - (i + 1))%n;
break;
}
}
}
std::vector<std::pair<int, int> > V;
for (i = 0; i < n; i++)
{
if (gondolaSeq[i] > n)
{
V.push_back({gondolaSeq[i], i});
gondolaSeq[i] = (i + r)%n + 1;
}
}
if (V.size() == 0)
return 0;
std::sort(V.begin(), V.end());
r = 0;
int j = 0;
for (i = n + 1; i <= V.back().first; i++)
{
replacementSeq[r] = gondolaSeq[V[j].second];
if (V[j].first == i)
j++;
r++;
}
return r;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
480 KB |
Output is correct |
3 |
Correct |
2 ms |
556 KB |
Output is correct |
4 |
Correct |
2 ms |
556 KB |
Output is correct |
5 |
Correct |
2 ms |
556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
556 KB |
Output is correct |
2 |
Correct |
2 ms |
596 KB |
Output is correct |
3 |
Correct |
2 ms |
612 KB |
Output is correct |
4 |
Correct |
2 ms |
612 KB |
Output is correct |
5 |
Correct |
2 ms |
612 KB |
Output is correct |
6 |
Correct |
7 ms |
748 KB |
Output is correct |
7 |
Correct |
14 ms |
876 KB |
Output is correct |
8 |
Correct |
14 ms |
892 KB |
Output is correct |
9 |
Correct |
4 ms |
892 KB |
Output is correct |
10 |
Correct |
12 ms |
892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
892 KB |
Output is correct |
2 |
Correct |
2 ms |
892 KB |
Output is correct |
3 |
Correct |
2 ms |
892 KB |
Output is correct |
4 |
Correct |
2 ms |
892 KB |
Output is correct |
5 |
Correct |
2 ms |
892 KB |
Output is correct |
6 |
Correct |
7 ms |
892 KB |
Output is correct |
7 |
Correct |
23 ms |
964 KB |
Output is correct |
8 |
Correct |
12 ms |
964 KB |
Output is correct |
9 |
Correct |
5 ms |
964 KB |
Output is correct |
10 |
Correct |
13 ms |
964 KB |
Output is correct |
11 |
Incorrect |
2 ms |
964 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
964 KB |
Output is correct |
2 |
Correct |
2 ms |
964 KB |
Output is correct |
3 |
Correct |
2 ms |
964 KB |
Output is correct |
4 |
Correct |
2 ms |
964 KB |
Output is correct |
5 |
Correct |
2 ms |
964 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
964 KB |
Output is correct |
2 |
Correct |
2 ms |
964 KB |
Output is correct |
3 |
Correct |
2 ms |
964 KB |
Output is correct |
4 |
Correct |
2 ms |
964 KB |
Output is correct |
5 |
Correct |
2 ms |
964 KB |
Output is correct |
6 |
Incorrect |
2 ms |
964 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
964 KB |
Output is correct |
2 |
Correct |
2 ms |
964 KB |
Output is correct |
3 |
Correct |
2 ms |
964 KB |
Output is correct |
4 |
Correct |
2 ms |
964 KB |
Output is correct |
5 |
Correct |
2 ms |
964 KB |
Output is correct |
6 |
Incorrect |
2 ms |
964 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
964 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
964 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
964 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
964 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |