답안 #755784

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
755784 2023-06-10T16:06:50 Z vjudge1 A Huge Tower (CEOI10_tower) C++17
0 / 100
120 ms 262144 KB
///YOU WILL MAKE IT
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+4;
long long MOD=1e9+7;
long long memo[25][1<<22];
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;
    for(int h=0;h<n;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;
   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:31:14: warning: unused variable 'ans' [-Wunused-variable]
   31 |    long long ans=0;
      |              ^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 102 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 112 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 108 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 104 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 105 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 104 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 100 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 111 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 120 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 104 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 99 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 102 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 98 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 96 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 99 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 102 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 99 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 103 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 102 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 101 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -