Skip to content

Commit f566df5

Browse files
committed
LibreOJ: 3148
「CEOI2016」袋鼠
1 parent 992235c commit f566df5

File tree

3 files changed

+65
-7
lines changed

3 files changed

+65
-7
lines changed

.vscode/tasks.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"-Wextra",
1818
"-O2",
1919
"'-Wl,--stack=512000000'",
20-
"-D LOCAL",
21-
"-I /Code/libs/ac-library"
20+
"-IE:/Code/libs/testlib/",
21+
"-DLOCAL",
2222
],
2323
"options": {
2424
"cwd": "${fileDirname}"
@@ -78,8 +78,7 @@
7878
"-Wextra",
7979
"-O2",
8080
"'-Wl,--stack=512000000'",
81-
"-D LOCAL",
82-
"-I E:/Code/libs/ac-library/"
81+
"-D LOCAL"
8382
],
8483
"options": {
8584
"cwd": "${fileDirname}"

LibreOJ/3148.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* @file 3148.cpp
3+
* @author Macesuted ([email protected])
4+
* @date 2022-12-09
5+
*
6+
* @copyright Copyright (c) 2022
7+
*
8+
*/
9+
10+
#include <bits/stdc++.h>
11+
using namespace std;
12+
13+
#ifndef LOCAL
14+
#define endl '\n'
15+
#endif
16+
17+
bool mem1;
18+
19+
#define maxn 2005
20+
#define mod 1000000007
21+
22+
int f[maxn][maxn];
23+
24+
int Mod(int a) { return a >= mod ? a - mod : a; }
25+
int Add(int &a, int b) { return a = Mod(a + b); }
26+
27+
void solve(void) {
28+
int n, S, T;
29+
cin >> n >> S >> T;
30+
f[1][1] = 1;
31+
for (int i = 2; i <= n; i++)
32+
for (int j = 1; j < i; j++) {
33+
int64_t v = f[i - 1][j], cnt = (i > S) + (i > T);
34+
if (!v) continue;
35+
if (i == S || i == T)
36+
Add(f[i][j + 1], v), Add(f[i][j], v);
37+
else
38+
Add(f[i][j + 1], v * (j + 1 - cnt) % mod), Add(f[i][j - 1], v * (j - 1) % mod);
39+
}
40+
cout << f[n][1] << endl;
41+
return;
42+
}
43+
44+
bool mem2;
45+
46+
int main() {
47+
ios::sync_with_stdio(false), cin.tie(nullptr);
48+
#ifdef LOCAL
49+
cerr << "Memory Cost: " << abs(&mem1 - &mem2) / 1024. / 1024. << "MB" << endl;
50+
#endif
51+
52+
int _ = 1;
53+
while (_--) solve();
54+
55+
#ifdef LOCAL
56+
cerr << "Time Cost: " << clock() * 1000. / CLOCKS_PER_SEC << "MS" << endl;
57+
#endif
58+
return 0;
59+
}

compile_flags.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
-xc++
2+
-std=c++20
23
-Wall
34
-Wextra
45
-O2
56
-Wl,--stack=512000000
6-
-D LOCAL
7-
-I E:/Code/libs/ac-library/
8-
-std=c++20
7+
-IE:/Code/libs/testlib/
8+
-DLOCAL

0 commit comments

Comments
 (0)