Submission #755927

# Submission time Handle Problem Language Result Execution time Memory
755927 2023-06-10T17:49:48 Z vjudge1 A Huge Tower (CEOI10_tower) C++17
40 / 100
1000 ms 262144 KB
///YOU WILL MAKE IT
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+4;
long long MOD=1e9+9;
long long memo[21][1<<20];
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--;
    //cout<<ind<<" "<<y[i]<<endl;
    for(int h=0;h<=ind;h++){
        if((!(j&(1<<h)))&&y[i]+d>=y[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(n,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

tower.cpp: In function 'void solve()':
tower.cpp:34:14: warning: unused variable 'ans' [-Wunused-variable]
   34 |    long long ans=0;
      |              ^~~
# Verdict Execution time Memory Grader output
1 Correct 64 ms 172548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 172632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 172652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 172668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 85 ms 172672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 258 ms 172692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 172568 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 82 ms 172620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 149 ms 172548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 227 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 240 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 232 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 224 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 229 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 221 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 237 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 231 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 226 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 274 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 309 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -