#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
int pos(int n,int rng[]){
return min_element(rng,rng+n)-rng;
}
int ds(int p,int i,int n){
return i<p ? n-p+i:i-p;
}
int valid(int n, int inputSeq[])
{
int mn=pos(n,inputSeq);
int mx=inputSeq[mn];
int se=mn;
if(distance(inputSeq,unique(inputSeq,inputSeq+n))!=n)return 0;
for(int j=1;j<n;++j){
mn++;
if(mn==n)mn=0;
if(inputSeq[mn]<=n&&inputSeq[mn]-inputSeq[se]!=ds(se,mn,n)){
return 0;
}
if(inputSeq[mn]<=n)mx=max(mx,inputSeq[mn]);
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
vector<pair<int,int>> vx;
int p=pos(n,gondolaSeq);
for(int i=0;i<n;++i){
if(gondolaSeq[i]>n){
vx.push_back({gondolaSeq[i],ds(p,i,n)});
}
}
sort(vx.begin(),vx.end());
int sz=0;
for(auto to:vx){
int x=to.first;
int st=to.second+1;
if(st!=x){
replacementSeq[sz++]=st;
}
while(true){
n++;
st=n;
if(st<x)
replacementSeq[sz++]=n;
else break;
}
// cout<<x<< " "<<st<<endl;
}
return sz;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return 5;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
464 KB |
Output is correct |
3 |
Correct |
3 ms |
468 KB |
Output is correct |
4 |
Correct |
3 ms |
468 KB |
Output is correct |
5 |
Correct |
3 ms |
544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
544 KB |
Output is correct |
2 |
Correct |
2 ms |
544 KB |
Output is correct |
3 |
Correct |
3 ms |
544 KB |
Output is correct |
4 |
Correct |
3 ms |
568 KB |
Output is correct |
5 |
Correct |
3 ms |
568 KB |
Output is correct |
6 |
Correct |
11 ms |
696 KB |
Output is correct |
7 |
Correct |
20 ms |
824 KB |
Output is correct |
8 |
Correct |
17 ms |
824 KB |
Output is correct |
9 |
Correct |
7 ms |
824 KB |
Output is correct |
10 |
Correct |
24 ms |
984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
984 KB |
Output is correct |
2 |
Correct |
3 ms |
984 KB |
Output is correct |
3 |
Correct |
3 ms |
984 KB |
Output is correct |
4 |
Correct |
3 ms |
984 KB |
Output is correct |
5 |
Correct |
3 ms |
984 KB |
Output is correct |
6 |
Correct |
10 ms |
984 KB |
Output is correct |
7 |
Correct |
16 ms |
984 KB |
Output is correct |
8 |
Correct |
17 ms |
984 KB |
Output is correct |
9 |
Correct |
8 ms |
984 KB |
Output is correct |
10 |
Correct |
26 ms |
984 KB |
Output is correct |
11 |
Correct |
3 ms |
984 KB |
Output is correct |
12 |
Correct |
3 ms |
984 KB |
Output is correct |
13 |
Correct |
14 ms |
984 KB |
Output is correct |
14 |
Correct |
3 ms |
984 KB |
Output is correct |
15 |
Correct |
19 ms |
984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
984 KB |
Output is correct |
2 |
Incorrect |
3 ms |
984 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
984 KB |
Output is correct |
2 |
Incorrect |
3 ms |
984 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
984 KB |
Output is correct |
2 |
Incorrect |
2 ms |
984 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |