QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#750625#7824. ЛягушкаmannobodyTL 159ms50168kbC++14900b2024-11-15 15:14:142024-11-15 15:14:15

Judging History

你现在查看的是最新测评结果

  • [2024-11-15 15:14:15]
  • 评测
  • 测评结果:TL
  • 用时:159ms
  • 内存:50168kb
  • [2024-11-15 15:14:14]
  • 提交

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;
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);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 50092kb

input:

3 2

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 16ms
memory: 50096kb

input:

4 2

output:

4

result:

ok single line: '4'

Test #3:

score: 0
Accepted
time: 15ms
memory: 49960kb

input:

2 1

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 11ms
memory: 50140kb

input:

16 1

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 11ms
memory: 50012kb

input:

5 3

output:

15

result:

ok single line: '15'

Test #6:

score: 0
Accepted
time: 19ms
memory: 50008kb

input:

6 5

output:

65

result:

ok single line: '65'

Test #7:

score: 0
Accepted
time: 7ms
memory: 49988kb

input:

7 5

output:

325

result:

ok single line: '325'

Test #8:

score: 0
Accepted
time: 7ms
memory: 50168kb

input:

8 2

output:

44

result:

ok single line: '44'

Test #9:

score: 0
Accepted
time: 7ms
memory: 50112kb

input:

9 4

output:

2043

result:

ok single line: '2043'

Test #10:

score: 0
Accepted
time: 18ms
memory: 50120kb

input:

10 7

output:

84157

result:

ok single line: '84157'

Test #11:

score: 0
Accepted
time: 8ms
memory: 49992kb

input:

11 5

output:

76561

result:

ok single line: '76561'

Test #12:

score: 0
Accepted
time: 159ms
memory: 50004kb

input:

12 9

output:

8000881

result:

ok single line: '8000881'

Test #13:

score: -100
Time Limit Exceeded

input:

13 11

output:


result: