#include <bits/stdc++.h>
#include "gondola.h"
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
const int N = 3e5 + 5;
// int gondolaSequence[100001];
// int replacementSequence[250001];
int ans[N];
bool check[N];
int valid(int n, int inputSeq[]) {
int id1 = 0, id2 = 0;
for (int i = 0; i < n; i++) {
if (check[inputSeq[i]]) return 0;
check[inputSeq[i]] = 1;
}
for (int i = 0; i < n; i++) {
if (inputSeq[i] <= n) {
id1 = inputSeq[i];
id2 = i;
break;
}
}
if (id1 == 0) return 1;
id2 -= id1 - 1;
if (id2 < 0) id2 += n;
for (int i = id2; i < id2 + n; i++) {
if (inputSeq[i % n] > n) continue;
if (i - id2 != inputSeq[i % n] - 1) return 0;
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
int id1 = 1, id2 = 0, mx = 0;
for (int i = 0; i < n; i++) {
if (gondolaSeq[i] <= n) {
id1 = gondolaSeq[i];
id2 = i;
break;
}
}
id2 -= id1 - 1;
if (id2 < 0) id2 += n;
int len = 0, id3 = -1;
for (int i = 0; i < n; i++) {
mx = max(mx, gondolaSeq[i]);
if (gondolaSeq[i] <= n) continue;
if (id3 == -1) id3 = ((i + n - id2) % n) + 1;
else ans[gondolaSeq[i]] = ((i + n - id2) % n) + 1;
}
if (id3 == -1) return 0;
int ans2 = id3, target = n + 1;
while (target <= mx) {
if (ans[target] == 0) {
replacementSeq[len] = ans2;
ans2 = target;
}
else replacementSeq[len] = ans[target];
len++, target++;
}
return len;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
// int main()
// {
// int i, n, tag;
// int nr;
// assert(scanf("%d", &tag)==1);
// assert(scanf("%d", &n)==1);
// for(i=0;i< n;i++)
// assert( scanf("%d", &gondolaSequence[i]) ==1);
// switch (tag){
// case 1: case 2: case 3:
// printf("%d\n", valid(n, gondolaSequence));
// break;
// case 4: case 5: case 6:
// nr = replacement(n, gondolaSequence, replacementSequence);
// printf("%d ", nr);
// if (nr > 0)
// {
// for (i=0; i<nr-1; i++)
// printf("%d ", replacementSequence[i]);
// printf("%d\n", replacementSequence[nr-1]);
// }
// else printf("\n");
// break;
// case 7: case 8: case 9: case 10:
// printf("%d\n", countReplacement(n, gondolaSequence));
// break;
// }
// return 0;
// }
# |
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 |
3 ms |
468 KB |
Output is correct |
7 |
Correct |
6 ms |
724 KB |
Output is correct |
8 |
Correct |
6 ms |
596 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
8 ms |
612 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 |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
4 ms |
452 KB |
Output is correct |
7 |
Correct |
6 ms |
700 KB |
Output is correct |
8 |
Correct |
6 ms |
596 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
6 ms |
596 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
5 ms |
652 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
8 ms |
736 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 |
0 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 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
0 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 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
8 |
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 |
- |
# |
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 |
- |