Submission #26111371
Source Code Expand
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
#define fi first
#define se second
#define rez resize
#define pb push_back
#define mkp make_pair
#define eb emplace_back
#define debug(...) fprintf (stderr, __VA_ARGS__)
#define Lep(i, l, r) for (int i = l; i < r; ++ i)
#define Rep(i, r, l) for (int i = r; i > l; -- i)
#define lep(i, l, r) for (int i = l; i <= r; ++ i)
#define rep(i, r, l) for (int i = r; i >= l; -- i)
int mod;
inline int mul (int x, int y) { return 1ll * x * y % mod; }
inline void sub (int &x, int y) { x -= y; if (x < 0) x += mod; }
inline void pls (int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int dec (int x, int y) { x -= y; if (x < 0) x += mod; return x; }
inline int add (int x, int y) { x += y; if (x >= mod) x -= mod; return x; }
inline int modpow (int x, ll y, int res = 1) {
for (y = (y + mod - 1) % (mod - 1); y; y >>= 1, x = mul (x, x)) if (y & 1) res = mul (x, res);
return res;
}
char _c; bool _f; template <class T> inline void IN (T & x) {
x = 0, _f = 0; while (_c = getchar (), ! isdigit (_c)) if (_c == '-') _f = 1;
while (isdigit (_c)) x = x * 10 + _c - '0', _c = getchar (); if (_f) x = -x;
}
template <class T> inline void chkmin (T & x, T y) { if (x > y) x = y; }
template <class T> inline void chkmax (T & x, T y) { if (x < y) x = y; }
const int N = 3e2 + 5;
int n, k, f[N][N], g[N][N], binom[N][N];
int main () {
IN (n), IN (k), IN (mod);
lep (i, 0, n) {
binom[i][0] = binom[i][i] = 1;
Lep (j, 1, i) binom[i][j] = add (binom[i - 1][j], binom[i - 1][j - 1]);
}
rep (i, k, 0) f[1][i] = 1, g[1][i] = add (g[1][i + 1], f[1][i]);
lep (i, 2, n + 1) rep (j, k, 0) {
Lep (t, 1, i) pls (f[i][j], mul (binom[i - 2][t - 1], mul (f[i - t][j], g[t][j + 1])));
g[i][j] = add (g[i][j + 1], f[i][j]);
}
printf ("%d\n", f[n + 1][0]);
return 0;
}
Submission Info
Submission Time
2021-09-26 12:33:46+0900
Task
E - Sequence Growing Hard
User
Qiuly
Language
C++ (GCC 9.2.1)
Score
1200
Code Size
1950 Byte
Status
AC
Exec Time
339 ms
Memory
4836 KiB
Compile Error
./Main.cpp: In function ‘void IN(T&)’:
./Main.cpp:35:2: warning: this ‘while’ clause does not guard... [-Wmisleading-indentation]
35 | while (isdigit (_c)) x = x * 10 + _c - '0', _c = getchar (); if (_f) x = -x;
| ^~~~~
./Main.cpp:35:63: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘while’
35 | while (isdigit (_c)) x = x * 10 + _c - '0', _c = getchar (); if (_f) x = -x;
| ^~
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
1200 / 1200
Status
Set Name
Test Cases
Sample
s1.txt, s2.txt, s3.txt
All
01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, s1.txt, s2.txt, s3.txt
Case Name
Status
Exec Time
Memory
01.txt
AC
336 ms
4836 KiB
02.txt
AC
294 ms
4604 KiB
03.txt
AC
192 ms
4416 KiB
04.txt
AC
2 ms
3584 KiB
05.txt
AC
253 ms
4672 KiB
06.txt
AC
8 ms
4776 KiB
07.txt
AC
2 ms
3712 KiB
08.txt
AC
294 ms
4528 KiB
09.txt
AC
311 ms
4560 KiB
10.txt
AC
185 ms
4348 KiB
11.txt
AC
132 ms
4476 KiB
12.txt
AC
2 ms
3584 KiB
13.txt
AC
2 ms
3528 KiB
14.txt
AC
339 ms
4540 KiB
15.txt
AC
41 ms
4760 KiB
16.txt
AC
225 ms
4420 KiB
17.txt
AC
2 ms
3692 KiB
18.txt
AC
259 ms
4592 KiB
19.txt
AC
324 ms
4600 KiB
20.txt
AC
80 ms
4584 KiB
21.txt
AC
10 ms
4668 KiB
22.txt
AC
245 ms
4788 KiB
23.txt
AC
292 ms
4684 KiB
24.txt
AC
5 ms
3720 KiB
25.txt
AC
14 ms
3872 KiB
26.txt
AC
282 ms
4500 KiB
27.txt
AC
9 ms
3644 KiB
28.txt
AC
68 ms
4740 KiB
29.txt
AC
236 ms
4568 KiB
30.txt
AC
11 ms
4084 KiB
31.txt
AC
283 ms
4660 KiB
32.txt
AC
328 ms
4676 KiB
s1.txt
AC
2 ms
3468 KiB
s2.txt
AC
2 ms
3684 KiB
s3.txt
AC
47 ms
4208 KiB