# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
140193 |
2019-08-02T08:43:05 Z |
ggoh |
Gondola (IOI14_gondola) |
C++14 |
|
95 ms |
6776 KB |
#include "gondola.h"
#include <bits/stdc++.h>
int i;
struct A{
int val,ind;
}data[100005];
bool cmp(A aa,A bb){return aa.val<bb.val;}
long long X=1e9+9;
long long f(long long p,long long q)
{
if(q==0)return 1ll;
if(q==1)return p;
long long O=f(p,q/2);
O=O*O%X;
if(q%2)return O*p%X;
return O;
}
int valid(int n, int inputSeq[])
{
int ST=-1,st,C=1;
std::map<int,int>ch;
for(i=0;i<n;i++)
{
if(ch[inputSeq[i]]==1){C=0;break;}
ch[inputSeq[i]]=1;
}
for(i=0;i<n;i++)
{
if(inputSeq[i]<=n)
{
st=i-inputSeq[i]+1;st=(st+n)%n;
if(ST==-1)ST=st;
else if(ST!=st){C=0;break;}
}
}
return C;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int ST=0,ba,sz=0,ans=0;
for(i=0;i<n;i++)
{
if(gondolaSeq[i]<=n)ST=(i-gondolaSeq[i]+1+n)%n;
else data[sz++]={gondolaSeq[i],i};
}
std::sort(data,data+sz,cmp);
ba=n;
for(i=0;i<sz;i++)
{
replacementSeq[ans++]=(data[i].ind-ST+n)%n+1;
for(int j=ba+1;j<data[i].val;j++)
{
replacementSeq[ans++]=j;
}
ba=data[i].val;
}
return ans;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
if(valid(n,inputSeq)==0)return 0;
int ST=-1,ba,sz=0;
long long ans=1ll;
for(i=0;i<n;i++)
{
if(inputSeq[i]<=n)ST=(i-inputSeq[i]+1+n)%n;
else data[sz++]={inputSeq[i],i};
}
if(ST==-1)ST=0,ans*=n;
std::sort(data,data+sz,cmp);
ba=n;
for(i=0;i<sz;i++)
{
ans*=f(sz-i,data[i].val-ba-1);
ans%=X;
ba=data[i].val;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 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 |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
256 KB |
Output is correct |
6 |
Correct |
20 ms |
2296 KB |
Output is correct |
7 |
Correct |
13 ms |
760 KB |
Output is correct |
8 |
Correct |
36 ms |
3960 KB |
Output is correct |
9 |
Correct |
12 ms |
1528 KB |
Output is correct |
10 |
Correct |
48 ms |
4600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
20 ms |
2168 KB |
Output is correct |
7 |
Correct |
13 ms |
760 KB |
Output is correct |
8 |
Correct |
36 ms |
3960 KB |
Output is correct |
9 |
Correct |
12 ms |
1532 KB |
Output is correct |
10 |
Correct |
48 ms |
4600 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
25 ms |
2040 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
60 ms |
4700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
296 KB |
Output is correct |
4 |
Correct |
2 ms |
276 KB |
Output is correct |
5 |
Correct |
2 ms |
376 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 |
380 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 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 |
632 KB |
Output is correct |
12 |
Correct |
13 ms |
632 KB |
Output is correct |
13 |
Correct |
18 ms |
1400 KB |
Output is correct |
14 |
Correct |
11 ms |
632 KB |
Output is correct |
15 |
Correct |
24 ms |
2264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
252 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 |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
256 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 |
62 ms |
4552 KB |
Output is correct |
10 |
Correct |
50 ms |
3832 KB |
Output is correct |
11 |
Correct |
19 ms |
1656 KB |
Output is correct |
12 |
Correct |
23 ms |
1912 KB |
Output is correct |
13 |
Correct |
6 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
64 ms |
4600 KB |
Output is correct |
10 |
Correct |
48 ms |
3704 KB |
Output is correct |
11 |
Correct |
19 ms |
1660 KB |
Output is correct |
12 |
Correct |
24 ms |
1912 KB |
Output is correct |
13 |
Correct |
6 ms |
632 KB |
Output is correct |
14 |
Correct |
81 ms |
5344 KB |
Output is correct |
15 |
Correct |
95 ms |
6776 KB |
Output is correct |
16 |
Correct |
15 ms |
1500 KB |
Output is correct |
17 |
Correct |
69 ms |
4700 KB |
Output is correct |
18 |
Correct |
32 ms |
2936 KB |
Output is correct |