# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
755931 | vjudge1 | A Huge Tower (CEOI10_tower) | C++17 | 106 ms | 262144 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///YOU WILL MAKE IT
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+4;
long long MOD=1e9+9;
long long memo[20][1<<21];
int y[N],n,d;
long long dp(int i,int j){
// cout<<i<<" "<<j<<endl;
if(__builtin_popcount(j)==n){
return 1;
}
if(memo[i][j]!=-1)
return memo[i][j];
memo[i][j]=0;
int ind=upper_bound(y,y+n,y[i]+d)-y;
ind--;
if(j==0){
ind=n-1;
}
//cout<<ind<<" "<<y[i]<<endl;
for(int h=0;h<=ind;h++){
if(j==0||(!(j&(1<<h)))){
memo[i][j]+=dp(h,j^(1<<h));
memo[i][j]%=MOD;
}
}
return memo[i][j];
}
void solve(){
memset(memo,-1,sizeof(memo));
cin>>n>>d;
for(int i=0;i<n;i++){
cin>>y[i];
}
// y[n]=1e9;
long long ans=0;
sort(y,y+n);
cout<<dp(0,0)<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t=1;
// cin>>t;
while(t--){
solve();
}
}
// Bac Math 2k24
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |