QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#750706 | #7824. Лягушка | mannobody | TL | 134ms | 50264kb | C++14 | 907b | 2024-11-15 15:34:07 | 2024-11-15 15:34:08 |
Judging History
answer
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <set>
#include <unordered_set>
#include <stack>
#include <iomanip>
#include <unordered_map>
#include <fstream>
#include <queue>
#include <cmath>
using namespace std;
#define int long long
#define ld long double
vector<vector<int>> v(1LL << 18, vector<int>(18, -1));
int n, k;
inline int func(int a, int cur) {
if (cur == n - 1) return 1;
if (a + 1 == 1LL << n) return 0;
a |= (1LL << cur);
int ans = 0;
int left, right;
left = max(0LL, cur - k);
right = min(n - 1, cur + k);
for (int i = left; i <= right; ++i) {
if (((a >> i) & 1) == 0) {
if (v[a][i] != -1) ans += v[a][i];
else ans += func(a, i);
}
}
v[a][cur] = ans;
return ans;
}
signed main() {
cin >> n >> k;
int a = 0;
int cur = 0;
cout << func(a, cur);
}
詳細信息
Test #1:
score: 100
Accepted
time: 8ms
memory: 50012kb
input:
3 2
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 15ms
memory: 50092kb
input:
4 2
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 8ms
memory: 50168kb
input:
2 1
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 12ms
memory: 50164kb
input:
16 1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 13ms
memory: 50264kb
input:
5 3
output:
15
result:
ok single line: '15'
Test #6:
score: 0
Accepted
time: 11ms
memory: 50132kb
input:
6 5
output:
65
result:
ok single line: '65'
Test #7:
score: 0
Accepted
time: 13ms
memory: 49960kb
input:
7 5
output:
325
result:
ok single line: '325'
Test #8:
score: 0
Accepted
time: 4ms
memory: 49996kb
input:
8 2
output:
44
result:
ok single line: '44'
Test #9:
score: 0
Accepted
time: 11ms
memory: 50012kb
input:
9 4
output:
2043
result:
ok single line: '2043'
Test #10:
score: 0
Accepted
time: 7ms
memory: 50132kb
input:
10 7
output:
84157
result:
ok single line: '84157'
Test #11:
score: 0
Accepted
time: 17ms
memory: 50152kb
input:
11 5
output:
76561
result:
ok single line: '76561'
Test #12:
score: 0
Accepted
time: 134ms
memory: 50104kb
input:
12 9
output:
8000881
result:
ok single line: '8000881'
Test #13:
score: -100
Time Limit Exceeded
input:
13 11