# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
433774 |
2021-06-20T10:37:59 Z |
medmdg |
Gondola (IOI14_gondola) |
C++14 |
|
23 ms |
2116 KB |
#include<bits/stdc++.h>
#include "gondola.h"
#define ll long long
using namespace std;
int valid(int n, int inputSeq[])
{
int h=1;
for(int i=1;i<n;i++){
if(inputSeq[i]!=(inputSeq[i-1]%n+1))
h=0;
}
return h;
}
int replacement(int n, int gs[], int rs[])
{
vector<pair<ll,ll> > fi(n);
fi[0]=make_pair(-1,-1);
for(int i=0;i<n;i++){
if(gs[i]<=n){
for(int j=i;j<i+n;j++){
fi[j%n]=make_pair(-gs[j%n],(gs[i]-1+(j-i))%n+1);
}
break;
}
}
ll pt=0;
if(fi[0].second==-1)
for(int i=0;i<n;i++){
fi[i]=make_pair(-gs[i],i+1);
}
sort(fi.begin(),fi.end());
ll ind=n+1;
while(fi.size()){
ll k=fi.size()-1;
while(ind<=-fi[k].first){
rs[pt]=fi[k].second;
fi[k].second=ind;
ind++;
pt++;
}
fi.pop_back();
}
return pt;
}
const ll M=1000000007;
ll exp(ll a, ll b){
ll val=1;
ll cur=1;
while(b){
cur*=a;
cur%=M;
if(b&1) val*=cur;
b/=2;
val%=M;
}
return val;
}
//----------------------
int countReplacement(int n, int gs[])
{
ll ans=1;
bool h;
vector<pair<ll,ll> > fi(n);
fi[0]=make_pair(-1,-1);
for(int i=0;i<n;i++){
if(gs[i]<=n){
for(int j=i;j<i+n;j++){
fi[j%n]=make_pair(-gs[j%n],(gs[i]-1+(j-i))%n+1);
}
break;
}
}
ll pt=0;
h=(fi[0].second==-1);
if(fi[0].second==-1)
for(int i=0;i<n;i++){
fi[i]=make_pair(-gs[i],i+1);
}
sort(fi.begin(),fi.end());
ll ind=n+1;ll rest=n;
while(fi.size()){
ll k=fi.size()-1;
if(ind>=-fi[k].first){
fi.pop_back();
rest--;
continue;
}
while(ind<-fi[k].first){
ans*=rest;
ind++;
ans%=M;
}
}
if(h)
ans*=n;
ans%=M;
return ans;
}
Compilation message
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:97:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
97 | if(h)
| ^~
gondola.cpp:99:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
99 | ans%=M;
| ^~~
gondola.cpp:76:6: warning: unused variable 'pt' [-Wunused-variable]
76 | ll pt=0;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 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 |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
5 ms |
332 KB |
Output is correct |
7 |
Correct |
12 ms |
524 KB |
Output is correct |
8 |
Correct |
9 ms |
460 KB |
Output is correct |
9 |
Correct |
4 ms |
332 KB |
Output is correct |
10 |
Correct |
12 ms |
580 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 |
0 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 |
5 ms |
332 KB |
Output is correct |
7 |
Correct |
11 ms |
588 KB |
Output is correct |
8 |
Correct |
9 ms |
524 KB |
Output is correct |
9 |
Correct |
3 ms |
332 KB |
Output is correct |
10 |
Correct |
10 ms |
588 KB |
Output is correct |
11 |
Correct |
0 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 |
11 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 |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 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 |
# |
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 |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 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 |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
19 ms |
1740 KB |
Output is correct |
12 |
Correct |
21 ms |
2004 KB |
Output is correct |
13 |
Correct |
18 ms |
1188 KB |
Output is correct |
14 |
Correct |
23 ms |
1740 KB |
Output is correct |
15 |
Correct |
23 ms |
2116 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 |
0 ms |
300 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |