#include "gondola.h"
#include <algorithm>
using namespace std;
int valid(int n, int inputSeq[])
{
int i;
int s,t;
bool check[250010];
s = -1;
for(i=0; i<n; i++){
if(check[inputSeq[i]]) return 0;
check[inputSeq[i]] = true;
if(inputSeq[i] <= n){
t = i+2-inputSeq[i];
if(t <= 0) t += n;
if(s == -1){
s = t;
}else if(s != t){
return 0;
}
}
}
return 1;
}
//----------------------
struct datar{
int num,value;
}a[100002];
bool cmp(datar x,datar y){
return x.value < y.value;
}
int first[100002];
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int i,j,cnt;
int s,t,big,nnum;
s = -1;
for(i=0; i<n; i++){
if(gondolaSeq[i] <= n){
t = i+2-gondolaSeq[i];
if(t <= 0) t += n;
s = t;
break;
}
}
big = 0;
for(i=0; i<n; i++) big = max(big,gondolaSeq[i]);
if(big == n){
return 0;
}
for(i=n; i>=1; i--) gondolaSeq[i] = gondolaSeq[i-1];
cnt = 0;
if(s == -1) s = 1;
first[s] = 1;
for(i=1; i<n; i++){
t = s+i;
if(t > n) t -= n;
first[t] = i+1;
}
for(i=1; i<=n; i++){
a[i].num = i;
a[i].value = gondolaSeq[i];
}
sort(a+1,a+n+1,cmp);
nnum = n+1;
if(a[1].value > n){
replacementSeq[cnt] = first[a[1].num];
cnt++; nnum++;
for(i=nnum; i<=a[1].value; i++){
replacementSeq[cnt] = nnum-1;
cnt++; nnum++;
}
}
for(i=2; i<=n; i++){
if(a[i].value <= n) continue;
replacementSeq[cnt] = first[a[i].num]; cnt++; nnum++;
for(j=nnum; j<=a[i].value; j++){
replacementSeq[cnt] = nnum-1;
cnt++; nnum++;
}
}
return cnt;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3736 KB |
Output is correct |
2 |
Correct |
0 ms |
3740 KB |
Output is correct |
3 |
Correct |
0 ms |
3740 KB |
Output is correct |
4 |
Correct |
0 ms |
3740 KB |
Output is correct |
5 |
Correct |
0 ms |
3740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3744 KB |
Output is correct |
2 |
Correct |
0 ms |
3740 KB |
Output is correct |
3 |
Correct |
0 ms |
3744 KB |
Output is correct |
4 |
Correct |
0 ms |
3740 KB |
Output is correct |
5 |
Correct |
0 ms |
3736 KB |
Output is correct |
6 |
Correct |
0 ms |
3736 KB |
Output is correct |
7 |
Correct |
0 ms |
3664 KB |
Output is correct |
8 |
Correct |
8 ms |
3736 KB |
Output is correct |
9 |
Correct |
0 ms |
3736 KB |
Output is correct |
10 |
Correct |
0 ms |
3736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3736 KB |
Output is correct |
2 |
Correct |
0 ms |
3744 KB |
Output is correct |
3 |
Correct |
0 ms |
3736 KB |
Output is correct |
4 |
Correct |
0 ms |
3740 KB |
Output is correct |
5 |
Correct |
0 ms |
3740 KB |
Output is correct |
6 |
Correct |
6 ms |
3736 KB |
Output is correct |
7 |
Correct |
0 ms |
3660 KB |
Output is correct |
8 |
Correct |
8 ms |
3736 KB |
Output is correct |
9 |
Correct |
0 ms |
3740 KB |
Output is correct |
10 |
Correct |
11 ms |
3740 KB |
Output is correct |
11 |
Correct |
0 ms |
3744 KB |
Output is correct |
12 |
Correct |
0 ms |
3736 KB |
Output is correct |
13 |
Correct |
5 ms |
3736 KB |
Output is correct |
14 |
Correct |
0 ms |
3740 KB |
Output is correct |
15 |
Correct |
9 ms |
3672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3620 KB |
Output is correct |
2 |
Correct |
0 ms |
3620 KB |
Output is correct |
3 |
Correct |
0 ms |
3620 KB |
Output is correct |
4 |
Correct |
0 ms |
3620 KB |
Output is correct |
5 |
Correct |
0 ms |
3620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3620 KB |
Output is correct |
2 |
Correct |
0 ms |
3620 KB |
Output is correct |
3 |
Correct |
0 ms |
3620 KB |
Output is correct |
4 |
Correct |
0 ms |
3620 KB |
Output is correct |
5 |
Correct |
0 ms |
3620 KB |
Output is correct |
6 |
Correct |
0 ms |
3620 KB |
Output is correct |
7 |
Correct |
0 ms |
3620 KB |
Output is correct |
8 |
Correct |
0 ms |
3620 KB |
Output is correct |
9 |
Correct |
0 ms |
3620 KB |
Output is correct |
10 |
Correct |
0 ms |
3620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3620 KB |
Output is correct |
2 |
Correct |
0 ms |
3620 KB |
Output is correct |
3 |
Correct |
0 ms |
3620 KB |
Output is correct |
4 |
Correct |
0 ms |
3620 KB |
Output is correct |
5 |
Correct |
0 ms |
3620 KB |
Output is correct |
6 |
Correct |
0 ms |
3620 KB |
Output is correct |
7 |
Correct |
0 ms |
3620 KB |
Output is correct |
8 |
Correct |
0 ms |
3620 KB |
Output is correct |
9 |
Correct |
0 ms |
3620 KB |
Output is correct |
10 |
Correct |
0 ms |
3620 KB |
Output is correct |
11 |
Correct |
11 ms |
3620 KB |
Output is correct |
12 |
Correct |
8 ms |
3620 KB |
Output is correct |
13 |
Correct |
0 ms |
3620 KB |
Output is correct |
14 |
Correct |
0 ms |
3620 KB |
Output is correct |
15 |
Correct |
15 ms |
3620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
3620 KB |
Output isn't correct - Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
3620 KB |
Output isn't correct - Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
3620 KB |
Output isn't correct - Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
3620 KB |
Output isn't correct - Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |