#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
int valid(int n, int inputSeq[])
{
int ind = -1;
map<int, int> mp;
for (int i = 0; i < n; i++)
{
if (mp[inputSeq[i]] == 1)
return 0;
if (inputSeq[i] <= n)
ind = i;
mp[inputSeq[i]] = 1;
}
if (ind == -1)
return 1;
for (int i = 0; i < n; i++)
{
if (inputSeq[i] > n)
continue;
if (((inputSeq[ind] - inputSeq[i] + n) % n) != ((ind - i + n) % n))
return 0;
}
return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int ind = -1, mx = 0;
map<int, int> mp;
for (int i = 0; i < n; i++)
{
if (gondolaSeq[i] <= n)
ind = i;
mx = max(gondolaSeq[i], mx);
}
set<pair<int, int>> reps;
if (ind == -1)
{
for (int i = 1; i < n + 1; i++)
reps.insert({gondolaSeq[i - 1], i});
}
else
{
for (int i = 0; i < n; i++)
{
if (gondolaSeq[i] <= n)
continue;
int dis = 0;
if(i > ind)
dis = i - ind;
else
dis = n - ind + i;
int val = gondolaSeq[ind] + dis;
if(val > n)
val = val % n;
reps.insert({gondolaSeq[i], val});
}
}
int i = 0;
while(!reps.empty())
{
pair<int, int> cur = *reps.begin();
reps.erase(reps.begin());
replacementSeq[i] = cur.second;
i++;
cur.second = n + i;
if(cur.first != cur.second)
reps.insert(cur);
}
return i;
}
int countReplacement(int n, int inputSeq[])
{
return -3;
}
# |
Verdict |
Execution time |
Memory |
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 |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
11 ms |
2188 KB |
Output is correct |
7 |
Correct |
6 ms |
596 KB |
Output is correct |
8 |
Correct |
20 ms |
3924 KB |
Output is correct |
9 |
Correct |
6 ms |
1364 KB |
Output is correct |
10 |
Correct |
25 ms |
4436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
11 ms |
2100 KB |
Output is correct |
7 |
Correct |
11 ms |
640 KB |
Output is correct |
8 |
Correct |
20 ms |
3924 KB |
Output is correct |
9 |
Correct |
7 ms |
1364 KB |
Output is correct |
10 |
Correct |
24 ms |
4520 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
13 ms |
2004 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
32 ms |
4556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
456 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
6 ms |
596 KB |
Output is correct |
12 |
Correct |
6 ms |
596 KB |
Output is correct |
13 |
Correct |
17 ms |
2492 KB |
Output is correct |
14 |
Correct |
6 ms |
596 KB |
Output is correct |
15 |
Correct |
24 ms |
2820 KB |
Output is correct |
# |
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 |
0 ms |
212 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |