# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
835732 |
2023-08-23T18:41:30 Z |
7mody |
Gondola (IOI14_gondola) |
C++17 |
|
45 ms |
5696 KB |
#include "gondola.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 250005;
const int mod=1e9+9;
ll power(ll a,ll n){
ll res=1;
while(n){
if(n&1) res=(1LL*res*a)%mod;
a=(a*a)%mod;
n>>=1;
}
return res;
}
map<int,int> mp;
int valid(int n, int p[]){
int start=-1;
for(int i=0;i<n;i++){
if(mp[p[i]]) return 0;
mp[p[i]]=1;
if(p[i]<=n){
int curr=(i+1-p[i]+n)%n;
if(start==-1) start=curr;
else if(start!=curr) return 0;
}
}
return 1;
}
// --------------------------------------------------------------
int replacement(int n, int p[], int res[]){
int start=1;
deque<int> arr(n);
for(int i=0; i < n;i++){
if(p[i]<=n) start=(i+1-p[i]+n)%n;
arr[i]=p[i];
}
while(start){
start--;
int temp=arr.front();
arr.pop_front();
arr.push_back(temp);
}
vector<pair<int,int>> curr;
for(int i=0; i < n;i++){
if(arr[i]>n) curr.push_back({arr[i],i});
}
int size=0;
sort(curr.begin(),curr.end());
int del=n+1;
for(auto [val,i] : curr){
res[size++]=i+1;
while(del<val) res[size++]=del++;
del++;
}
return size;
}
// --------------------------------------------------------------
int countReplacement(int n, int p[]){
if(!valid(n,p)) return 0;
vector<int> arr;
int res=1,a=n;
for(int i=0;i<n;i++){
if(p[i]<=n) a--;
else arr.push_back(p[i]);
}
if(a==n) res=n;
int pre=n;
sort(arr.begin(),arr.end());
for(int x:arr){
res=ll(res)*power(a,x-pre-1)%mod;
pre=x;
a--;
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
9 ms |
2112 KB |
Output is correct |
7 |
Correct |
6 ms |
596 KB |
Output is correct |
8 |
Correct |
18 ms |
3924 KB |
Output is correct |
9 |
Correct |
8 ms |
1360 KB |
Output is correct |
10 |
Correct |
22 ms |
4484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
9 ms |
2176 KB |
Output is correct |
7 |
Correct |
6 ms |
528 KB |
Output is correct |
8 |
Correct |
18 ms |
3848 KB |
Output is correct |
9 |
Correct |
5 ms |
1400 KB |
Output is correct |
10 |
Correct |
22 ms |
4420 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
3 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
6 ms |
536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
312 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
312 KB |
Output is correct |
11 |
Correct |
6 ms |
1520 KB |
Output is correct |
12 |
Correct |
7 ms |
1492 KB |
Output is correct |
13 |
Correct |
11 ms |
1520 KB |
Output is correct |
14 |
Correct |
6 ms |
1344 KB |
Output is correct |
15 |
Correct |
16 ms |
2384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
244 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
33 ms |
4372 KB |
Output is correct |
10 |
Correct |
25 ms |
3704 KB |
Output is correct |
11 |
Correct |
9 ms |
1620 KB |
Output is correct |
12 |
Correct |
12 ms |
1936 KB |
Output is correct |
13 |
Correct |
3 ms |
700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
35 ms |
4360 KB |
Output is correct |
10 |
Correct |
25 ms |
3676 KB |
Output is correct |
11 |
Correct |
9 ms |
1556 KB |
Output is correct |
12 |
Correct |
11 ms |
1876 KB |
Output is correct |
13 |
Correct |
3 ms |
596 KB |
Output is correct |
14 |
Correct |
40 ms |
5168 KB |
Output is correct |
15 |
Correct |
45 ms |
5696 KB |
Output is correct |
16 |
Correct |
7 ms |
1404 KB |
Output is correct |
17 |
Correct |
29 ms |
3880 KB |
Output is correct |
18 |
Correct |
16 ms |
2452 KB |
Output is correct |