#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
int valid(int n, int inputSeq[])
{
int st = 0;
for(int i = 0; i < n; i++){
if(inputSeq[i] == 1)st = i;
}
vector<int> cnt(250500, 0);
for(int i = 0; i < n; i++){
cnt[inputSeq[i]]++;
}
for(int i = 0; i <= 250500; i++){
if(cnt[i] > 1){
return 0;
}
}
for(int it = 0; it < n - 2; it++){
int p = (it + st) % n;
int nx = (it + 1 + st) % n;
if(inputSeq[p] > n || inputSeq[nx] > n){
continue;
}
if(inputSeq[nx] - inputSeq[p] != 1){
return 0;
}
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
vector<int> a(n + 1, 0);
int cnt = 0;
int mx = 0;
int id1 = 0;
for(int i = 0; i < n; i++){
int x = gondolaSeq[i];
if(x > mx){
id1 = i;
}
mx = max(mx, x);
if(x <= n){
a[((i - x + 1) % n + n) % n]++;
cnt++;
}
}
vector<int> id(250500, -1);
for(int i = 0; i < n; i++){
id[gondolaSeq[i]] = i;
}
bool f = true;
int newn = n + 1;
int l = 0;
for(int i = 0; i < n; i++){
if(a[i] == cnt){
f = false;
vector<int> newid(n, 0);
for(int j = 0; j < n; j++){
newid[(i + j) % n] = j + 1;
}
while(newn <= mx){
if(id[newn] == -1){
replacementSeq[l++] = newid[id1];
newid[id1] = newn;
}else{
replacementSeq[l++] = newid[id[newn]];
}
newn++;
}
break;
}
}
assert(f == false);
return l;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
int st = 0;
for(int i = 0; i < n; i++){
if(inputSeq[i] == 1)st = i;
}
map<int, int> cnt;
for(int i = 0; i < n; i++){
cnt[inputSeq[i]]++;
}
for(auto x : cnt){
if(x.second > 1){
return 0;
}
}
for(int it = 0; it < n - 2; it++){
int p = (it + st) % n;
int nx = (it + 1 + st) % n;
if(inputSeq[p] > n || inputSeq[nx] > n){
continue;
}
if(inputSeq[nx] - inputSeq[p] != 1){
return 0;
}
}
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1228 KB |
Output is correct |
2 |
Correct |
2 ms |
1228 KB |
Output is correct |
3 |
Correct |
1 ms |
1228 KB |
Output is correct |
4 |
Correct |
1 ms |
1228 KB |
Output is correct |
5 |
Correct |
2 ms |
1228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1228 KB |
Output is correct |
2 |
Correct |
1 ms |
1228 KB |
Output is correct |
3 |
Correct |
1 ms |
1228 KB |
Output is correct |
4 |
Correct |
1 ms |
1228 KB |
Output is correct |
5 |
Correct |
1 ms |
1228 KB |
Output is correct |
6 |
Correct |
6 ms |
1356 KB |
Output is correct |
7 |
Correct |
14 ms |
1616 KB |
Output is correct |
8 |
Correct |
10 ms |
1484 KB |
Output is correct |
9 |
Correct |
5 ms |
1356 KB |
Output is correct |
10 |
Correct |
11 ms |
1612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1228 KB |
Output is correct |
2 |
Correct |
1 ms |
1228 KB |
Output is correct |
3 |
Correct |
1 ms |
1228 KB |
Output is correct |
4 |
Correct |
1 ms |
1228 KB |
Output is correct |
5 |
Correct |
1 ms |
1228 KB |
Output is correct |
6 |
Correct |
6 ms |
1428 KB |
Output is correct |
7 |
Correct |
11 ms |
1616 KB |
Output is correct |
8 |
Correct |
9 ms |
1484 KB |
Output is correct |
9 |
Correct |
4 ms |
1356 KB |
Output is correct |
10 |
Correct |
11 ms |
1612 KB |
Output is correct |
11 |
Correct |
1 ms |
1228 KB |
Output is correct |
12 |
Correct |
1 ms |
1228 KB |
Output is correct |
13 |
Correct |
6 ms |
1356 KB |
Output is correct |
14 |
Correct |
1 ms |
1228 KB |
Output is correct |
15 |
Correct |
12 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1228 KB |
Output is correct |
2 |
Correct |
1 ms |
1228 KB |
Output is correct |
3 |
Correct |
1 ms |
1228 KB |
Output is correct |
4 |
Correct |
1 ms |
1228 KB |
Output is correct |
5 |
Correct |
1 ms |
1228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1228 KB |
Output is correct |
2 |
Correct |
1 ms |
1228 KB |
Output is correct |
3 |
Correct |
1 ms |
1228 KB |
Output is correct |
4 |
Correct |
1 ms |
1228 KB |
Output is correct |
5 |
Correct |
1 ms |
1228 KB |
Output is correct |
6 |
Correct |
1 ms |
1228 KB |
Output is correct |
7 |
Correct |
1 ms |
1228 KB |
Output is correct |
8 |
Correct |
2 ms |
1192 KB |
Output is correct |
9 |
Correct |
2 ms |
1228 KB |
Output is correct |
10 |
Correct |
2 ms |
1188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1228 KB |
Output is correct |
2 |
Correct |
1 ms |
1228 KB |
Output is correct |
3 |
Correct |
1 ms |
1228 KB |
Output is correct |
4 |
Correct |
1 ms |
1228 KB |
Output is correct |
5 |
Correct |
1 ms |
1228 KB |
Output is correct |
6 |
Correct |
1 ms |
1228 KB |
Output is correct |
7 |
Correct |
1 ms |
1228 KB |
Output is correct |
8 |
Correct |
2 ms |
1228 KB |
Output is correct |
9 |
Correct |
2 ms |
1228 KB |
Output is correct |
10 |
Correct |
2 ms |
1228 KB |
Output is correct |
11 |
Correct |
12 ms |
2636 KB |
Output is correct |
12 |
Correct |
13 ms |
2744 KB |
Output is correct |
13 |
Correct |
14 ms |
2124 KB |
Output is correct |
14 |
Correct |
14 ms |
2600 KB |
Output is correct |
15 |
Correct |
23 ms |
2352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |