# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
955102 |
2024-03-29T11:47:26 Z |
4QT0R |
Gondola (IOI14_gondola) |
C++17 |
|
27 ms |
4672 KB |
#include <bits/stdc++.h>
#include "gondola.h"
using namespace std;
#define pii pair<int,int>
int valid(int n, int inputSeq[]){
set<int> s(inputSeq,inputSeq+n);
if ((int)s.size()<n)return 0;
pii mn={n+1,-1};
for (int i = 0; i<n; i++){
if (inputSeq[i]<mn.first)mn={inputSeq[i],i};
}
int cur=mn.first;
for (int i = mn.second+1; i<n; i++){
if (inputSeq[i]<=n && inputSeq[i]!=++cur)return 0;
}
for (int i = 0; ++cur<=n; i++){
if (inputSeq[i]<=n && inputSeq[i]!=cur)return 0;
}
return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
int st=0;
for (int i = 0; i<n; i++){
if (gondolaSeq[i]<=n){
st=(i-gondolaSeq[i]+1+n)%n;
break;
}
}
vector<int> kol(n);
for (int i = st; i<n+st; i++)kol[i-st]=gondolaSeq[i%n];
priority_queue<pii,vector<pii>,greater<pii>> pq;
int l=0,bro=n+1;
for (int i = 0; i<n; i++){
if (kol[i]>n)pq.push({kol[i],i+1});
}
while(pq.size()){
pii now=pq.top();
pq.pop();
replacementSeq[l++]=now.second;
while(bro<now.first)replacementSeq[l++]=bro++;
}
return l;
}
int countReplacement(int n, int inputSeq[]){
if (!valid(n,inputSeq))return 0;
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
596 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 |
2352 KB |
Output is correct |
7 |
Correct |
20 ms |
3732 KB |
Output is correct |
8 |
Correct |
13 ms |
3932 KB |
Output is correct |
9 |
Correct |
3 ms |
1372 KB |
Output is correct |
10 |
Correct |
12 ms |
4444 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 |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
6 ms |
2140 KB |
Output is correct |
7 |
Correct |
20 ms |
3656 KB |
Output is correct |
8 |
Correct |
13 ms |
3932 KB |
Output is correct |
9 |
Correct |
4 ms |
1372 KB |
Output is correct |
10 |
Correct |
11 ms |
4448 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
360 KB |
Output is correct |
13 |
Correct |
10 ms |
2148 KB |
Output is correct |
14 |
Correct |
0 ms |
356 KB |
Output is correct |
15 |
Correct |
27 ms |
4672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
500 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
512 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
1 ms |
344 KB |
Output is correct |
7 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
8 |
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 |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |