Submission #874373

# Submission time Handle Problem Language Result Execution time Memory
874373 2023-11-16T19:15:02 Z Irate A Huge Tower (CEOI10_tower) C++14
20 / 100
844 ms 177848 KB
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 9;
int n, d;
vector<int>v;
int dp[20][(1 << 20)];
int rec(int indx, int mask){
	int res = 0;
	if(mask == 0)return 1;
	if(dp[indx][mask] != -1)return dp[indx][mask];
	for(int i = 0;i < n;++i){
		if((mask & (1 << i)) && v[indx] + d >= v[i]){
			res += rec(i, mask ^ (1 << i));
			res %= MOD;
		}	
	}
	return dp[indx][mask] = res;
}
int main()
{
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);
    cin >> n >> d;
    v.resize(n);
    for(int i = 0;i < n;++i){
    	cin >> v[i];
    }
    int res = 0;
    for(int i = 0;i < 20;++i){
    	for(int j = 0;j < (1 << 20);++j){
    		dp[i][j] = -1;
    	}
    }
    for(int i = 0;i < n;++i){
    	res += rec(i, ((1 << n) - 1) ^ (1 << i));
    }
    cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 40 ms 82516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 82468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 82264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 82268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 82268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 103 ms 82268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 844 ms 82492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 82268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 82264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 79 ms 166956 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 81 ms 166800 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 83 ms 166924 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 83 ms 166724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 82 ms 166868 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 80 ms 166740 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 93 ms 166940 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 83 ms 166992 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 98 ms 167760 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 162 ms 171168 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 298 ms 177848 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -