# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
410950 |
2021-05-24T00:28:56 Z |
MDario |
Gondola (IOI14_gondola) |
C++11 |
|
69 ms |
6000 KB |
#include "gondola.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
const ll mod=1e9+9;
ll qpow(ll xf, ll yf){
if(yf==0)return 1;
if(yf&1)return (qpow(xf, yf-1)*xf)%mod;
return qpow((xf*xf)%mod, yf/2);
}
int valid(int n, int a[]){
map<int, int>m;
int c=0;
for(int i=0; i<n; i++){
if(m[a[i]]){
return 0;
}
m[a[i]]=1;
if(a[i]<=n){
if(c==0){
c=(a[i]-i+n-1)%n+1;
}
else if((a[i]-i+n-1)%n+1!=c){
return 0;
}
}
}
return 1;
}
//----------------------
int replacement(int n, int a[], int replacementSeq[]){
vector<pair<int, int>> v;
int c=0;
for(int i=0; i<n; i++){
if(a[i]<=n)c=(a[i]-i+n-1)%n+1;
}
if(c==0){
for(int i=0; i<n; i++){
v.push_back({a[i], i+1});
}
}
else{
for(int i=0; i<n; i++){
v.push_back({a[i], (c+i-1)%n+1});
}
}
sort(v.begin(), v.end());
c=n+1;
for(int i=0; i<n; i++){
while(v[i].F>v[i].S){
replacementSeq[c-n-1]=v[i].S;
v[i].S=c;
c++;
}
}
return c-n-1;
}
//----------------------
int countReplacement(int n, int a[]){
if(!valid(n, a))return 0;
vector<ll> v;
ll c=n+1, c1=0;
for(int i=0; i<n; i++){
if(a[i]>n)v.push_back(a[i]);
}
sort(v.begin(), v.end());
c1=v.size();
ll r=1;
if(c1==n)r=n;
for(int i=0; i<c1; i++){
r=(r*qpow(c1-i, v[i]-c))%mod;
c=v[i]+1;
}
return r;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
14 ms |
2124 KB |
Output is correct |
7 |
Correct |
10 ms |
588 KB |
Output is correct |
8 |
Correct |
30 ms |
3804 KB |
Output is correct |
9 |
Correct |
9 ms |
1356 KB |
Output is correct |
10 |
Correct |
34 ms |
4460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
14 ms |
2208 KB |
Output is correct |
7 |
Correct |
10 ms |
560 KB |
Output is correct |
8 |
Correct |
29 ms |
3864 KB |
Output is correct |
9 |
Correct |
11 ms |
1440 KB |
Output is correct |
10 |
Correct |
34 ms |
4392 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
5 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
12 ms |
608 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
13 ms |
1712 KB |
Output is correct |
12 |
Correct |
15 ms |
1788 KB |
Output is correct |
13 |
Correct |
20 ms |
1144 KB |
Output is correct |
14 |
Correct |
13 ms |
1732 KB |
Output is correct |
15 |
Correct |
27 ms |
2160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
49 ms |
3980 KB |
Output is correct |
10 |
Correct |
36 ms |
3404 KB |
Output is correct |
11 |
Correct |
13 ms |
1356 KB |
Output is correct |
12 |
Correct |
17 ms |
1612 KB |
Output is correct |
13 |
Correct |
4 ms |
588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
46 ms |
3984 KB |
Output is correct |
10 |
Correct |
36 ms |
3412 KB |
Output is correct |
11 |
Correct |
13 ms |
1412 KB |
Output is correct |
12 |
Correct |
17 ms |
1576 KB |
Output is correct |
13 |
Correct |
4 ms |
588 KB |
Output is correct |
14 |
Correct |
61 ms |
5292 KB |
Output is correct |
15 |
Correct |
69 ms |
6000 KB |
Output is correct |
16 |
Correct |
13 ms |
1260 KB |
Output is correct |
17 |
Correct |
43 ms |
4048 KB |
Output is correct |
18 |
Correct |
23 ms |
2660 KB |
Output is correct |