#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include "gondola.h"
using namespace std;
int valid(int n, int inputSeq[]){
map<int,int> m1;
int holdmin = 1e9;
int ind = 0;
for(int i=0;i<n;i++){
if(m1[inputSeq[i]] == 1){
return 0;
}
if(inputSeq[i]<holdmin){
holdmin = inputSeq[i];
ind = i;
}
m1[inputSeq[i]] = 1;
}
for(int i=ind;i<n;i++){
if(inputSeq[i]<=n && inputSeq[i]!=holdmin){
return 0;
}
holdmin++;
}
if(ind == 0){
return 1;
}
for(int i=0;i<ind;i++){
if(inputSeq[i]<=n && inputSeq[i]!=holdmin){
// cout<<inputSeq[i]<<endl;
return 0;
}
holdmin++;
}
return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
int holdmin =n+1;
int pos = 0;
for(int i=0;i<n;i++){
if(gondolaSeq[i]<holdmin){
holdmin = gondolaSeq[i];
pos = i;
}
}
vector<pair<int,int>> v1;
if(holdmin>n){
for(int i=0;i<n;i++){
//cout<<n<<endl;
v1.push_back(make_pair(gondolaSeq[i],i+1));
}
}else{
int x = holdmin;
for(int i=pos;i<n;i++){
if(gondolaSeq[i]>n){
v1.push_back(make_pair(gondolaSeq[i],x));
//cout<<gondolaSeq[i]<<" "<<x<<endl;
}
x++;
if(x == n+1){
x = 1;
}
}
for(int i=0;i<pos;i++){
if(gondolaSeq[i]>n){
v1.push_back(make_pair(gondolaSeq[i],x));
//cout<<gondolaSeq[i]<<" "<<x<<endl;
}
x++;
if(x == n+1){
x = 1;
}
}
}
sort(v1.begin(),v1.end());
int start = n+1;
int ind = 0;
for(auto x:v1){
int curr = x.first;
int val = x.second;
for(int i=start;i<=curr;i++){
replacementSeq[ind] = val;
val = i;
ind++;
}
start = curr+1;
}
return ind;
}
int countReplacement(int n, int inputSeq[]){
return 0;
}
/*int main(){
int arr[100];
int arr2[10000];
int n;
cin>>n;
for(int i=0;i<n;i++){
cin>>arr[i];
}
cout<<replacement(72,arr,arr2)<<endl;
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
20 ms |
2296 KB |
Output is correct |
7 |
Correct |
13 ms |
632 KB |
Output is correct |
8 |
Correct |
35 ms |
3960 KB |
Output is correct |
9 |
Correct |
12 ms |
1528 KB |
Output is correct |
10 |
Correct |
48 ms |
4600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
252 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
20 ms |
2168 KB |
Output is correct |
7 |
Correct |
13 ms |
632 KB |
Output is correct |
8 |
Correct |
34 ms |
3960 KB |
Output is correct |
9 |
Correct |
12 ms |
1528 KB |
Output is correct |
10 |
Correct |
47 ms |
4728 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
24 ms |
2140 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
59 ms |
4728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
308 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
12 ms |
1144 KB |
Output is correct |
12 |
Correct |
13 ms |
1276 KB |
Output is correct |
13 |
Correct |
17 ms |
1532 KB |
Output is correct |
14 |
Correct |
12 ms |
1016 KB |
Output is correct |
15 |
Correct |
39 ms |
2436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |