# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
896788 |
2024-01-02T06:56:17 Z |
LCJLY |
Gondola (IOI14_gondola) |
C++14 |
|
15 ms |
4204 KB |
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
int valid(int n, int arr[]){
unordered_set<int>se;
bool amos=true;
deque<int>d;
int mini=INT_MAX;
int small=0;
int big=0;
for(int x=0;x<n;x++){
if(se.find(arr[x])!=se.end()) amos=false;
se.insert(arr[x]);
if(arr[x]<=n){
d.push_back(arr[x]);
mini=min(mini,arr[x]);
small++;
}
else big++;
}
//int ptr=1;
//for(int x=1;x<=n;x++){
//if(se.find(x)==se.end()){
//if(se.find(ptr+n)==se.end()) amos=false;
//ptr++;
//}
//}
if(n-small!=big) amos=false;
if(!d.empty()){
while(d.front()!=mini){
d.push_front(d.back());
d.pop_back();
}
for(int x=1;x<(int)d.size();x++){
if(d[x]<d[x-1]) amos=false;
}
}
return amos;
}
int replacement(int n, int arr[], int ans[]){
int maxi=0;
int shift=-1;
deque<int>d;
for(int x=0;x<n;x++){
maxi=max(maxi,arr[x]);
if(arr[x]<=n){
if(arr[x]>=x+1){
shift=arr[x]-(x+1);
}
else{
shift=arr[x]+n-(x+1);
}
}
d.push_back(arr[x]);
}
while(shift>0){
shift--;
d.push_front(d.back());
d.pop_back();
}
vector<pair<int,int>>v;
for(int x=0;x<n;x++){
if(d[x]>n){
v.push_back({d[x],x});
}
}
sort(v.begin(),v.end());
int index=0;
int cur=n;
for(auto it:v){
bool done=true;
while(cur<it.first){
if(done){
ans[index]=it.second+1;
done=false;
index++;
}
else{
ans[index]=cur;
index++;
}
cur++;
}
}
return maxi-n;
}
//----------------------
int countReplacement(int n, int inputSeq[]){
return 0;
}
//
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
2120 KB |
Output is correct |
7 |
Correct |
12 ms |
3692 KB |
Output is correct |
8 |
Correct |
9 ms |
3692 KB |
Output is correct |
9 |
Correct |
3 ms |
1628 KB |
Output is correct |
10 |
Correct |
11 ms |
4204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
2112 KB |
Output is correct |
7 |
Correct |
12 ms |
3692 KB |
Output is correct |
8 |
Correct |
10 ms |
3944 KB |
Output is correct |
9 |
Correct |
3 ms |
1628 KB |
Output is correct |
10 |
Correct |
11 ms |
4200 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
6 ms |
860 KB |
Output is correct |
12 |
Correct |
7 ms |
1116 KB |
Output is correct |
13 |
Correct |
10 ms |
1516 KB |
Output is correct |
14 |
Correct |
6 ms |
860 KB |
Output is correct |
15 |
Correct |
15 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |