이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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));
res %= MOD;
}
cout << res;
}
# | 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... |