QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#752232#7824. ЛягушкаmannobodyAC ✓65ms50256kbC++14926b2024-11-15 23:10:512024-11-15 23:10:52

Judging History

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

  • [2024-11-15 23:10:52]
  • 评测
  • 测评结果:AC
  • 用时:65ms
  • 内存:50256kb
  • [2024-11-15 23:10:51]
  • 提交

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;
	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) {
			int newa = a | (1LL << i);
			if (v[newa][i] != -1) ans += v[newa][i];
			else ans += func(newa, i);
		}
	}
	v[a][cur] = ans;
	return ans;
}
signed main() {
	cin >> n >> k;
	int a = 1;
	int cur = 0;
	cout << func(a, cur);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 8ms
memory: 50096kb

input:

3 2

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 17ms
memory: 50116kb

input:

4 2

output:

4

result:

ok single line: '4'

Test #3:

score: 0
Accepted
time: 21ms
memory: 49968kb

input:

2 1

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 12ms
memory: 50116kb

input:

16 1

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 12ms
memory: 50184kb

input:

5 3

output:

15

result:

ok single line: '15'

Test #6:

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

input:

6 5

output:

65

result:

ok single line: '65'

Test #7:

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

input:

7 5

output:

325

result:

ok single line: '325'

Test #8:

score: 0
Accepted
time: 12ms
memory: 50164kb

input:

8 2

output:

44

result:

ok single line: '44'

Test #9:

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

input:

9 4

output:

2043

result:

ok single line: '2043'

Test #10:

score: 0
Accepted
time: 13ms
memory: 50136kb

input:

10 7

output:

84157

result:

ok single line: '84157'

Test #11:

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

input:

11 5

output:

76561

result:

ok single line: '76561'

Test #12:

score: 0
Accepted
time: 14ms
memory: 50256kb

input:

12 9

output:

8000881

result:

ok single line: '8000881'

Test #13:

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

input:

13 11

output:

108505111

result:

ok single line: '108505111'

Test #14:

score: 0
Accepted
time: 17ms
memory: 50148kb

input:

14 7

output:

68467490

result:

ok single line: '68467490'

Test #15:

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

input:

15 3

output:

140176

result:

ok single line: '140176'

Test #16:

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

input:

16 5

output:

65122989

result:

ok single line: '65122989'

Test #17:

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

input:

16 14

output:

236975164804

result:

ok single line: '236975164804'

Test #18:

score: 0
Accepted
time: 20ms
memory: 50136kb

input:

17 4

output:

20785136

result:

ok single line: '20785136'

Test #19:

score: 0
Accepted
time: 32ms
memory: 50148kb

input:

17 16

output:

3554627472076

result:

ok single line: '3554627472076'

Test #20:

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

input:

18 2

output:

19513

result:

ok single line: '19513'

Test #21:

score: 0
Accepted
time: 20ms
memory: 50164kb

input:

18 3

output:

2204535

result:

ok single line: '2204535'

Test #22:

score: 0
Accepted
time: 36ms
memory: 49980kb

input:

18 6

output:

8541922953

result:

ok single line: '8541922953'

Test #23:

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

input:

18 9

output:

820887449383

result:

ok single line: '820887449383'

Test #24:

score: 0
Accepted
time: 57ms
memory: 49996kb

input:

18 15

output:

50001759773869

result:

ok single line: '50001759773869'

Test #25:

score: 0
Accepted
time: 65ms
memory: 50164kb

input:

18 17

output:

56874039553217

result:

ok single line: '56874039553217'