QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#99886 | #6193. Junk Problem | zhoukangyang | AC ✓ | 3ms | 3672kb | C++17 | 2.2kb | 2023-04-23 22:40:19 | 2023-04-23 22:40:23 |
Judging History
answer
#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define vi vector <int>
#define sz(a) ((int) (a).size())
#define me(f, x) memset(f, x, sizeof(f))
#define uint unsigned int
#define ull unsigned long long
#define bs bitset < N >
using namespace std;
const int N = 507, mod = 998244353;
int qpow(int x, int y = mod - 2) {
int res = 1;
for(; y; x = (ll) x * x % mod, y >>= 1) if(y & 1) res = (ll) res * x % mod;
return res;
}
int fac[N], ifac[N], inv[N];
void init(int x) {
fac[0] = ifac[0] = inv[1] = 1;
L(i, 2, x) inv[i] = (ll) (mod - mod / i) * inv[mod % i] % mod;
L(i, 1, x) fac[i] = (ll) fac[i - 1] * i % mod, ifac[i] = (ll) ifac[i - 1] * inv[i] % mod;
}
int C(int x, int y) {
return x < y || y < 0 ? 0 : (ll) fac[x] * ifac[y] % mod * ifac[x - y] % mod;
}
int f[N][N];
int det(int m) {
int ns = 1;
L(i, 1, m) {
int cs = 0;
L(j, i, m) if(f[j][i]) {
cs = j;
break;
}
if(!cs) return 0;
if(cs != i) ns = mod - ns, swap(f[i], f[cs]);
ns = (ll) ns * f[i][i] % mod;
int Iv = qpow(f[i][i]);
L(j, i, m) f[i][j] = (ll) f[i][j] * Iv % mod;
L(j, i + 1, m) R(k, m, i)
(f[j][k] += mod - (ll) f[i][k] * f[j][i] % mod) %= mod;
}
return ns;
}
int n, m, l, k;
int a[N], b[N], x[N], y[N];
inline int way(int x, int y) {
return C(x + y, x);
}
int aX[N], aY[N];
int bX[N], bY[N];
int main() {
ios :: sync_with_stdio(false);
cin.tie(0); cout.tie(0);
init(500);
cin >> n >> m >> l >> k;
L(i, 1, l) {
cin >> a[i];
}
L(i, 1, l) {
cin >> b[i];
}
L(i, 1, k) {
cin >> x[i] >> y[i];
}
L(i, 1, l) {
aX[i] = 1, aY[i] = a[i];
bX[i] = n, bY[i] = b[i];
}
L(i, 1, k) {
aX[i + l] = x[i], aY[i + l] = y[i];
bX[i + l] = x[i], bY[i + l] = y[i] + 1;
}
L(i, 1, k + l) {
L(j, 1, k + l) {
int w = way(bX[j] - aX[i], bY[j] - aY[i]);
if(j > l) {
w = (ll) w * (mod - 1) % mod;
}
(f[i][j] += w) %= mod;
}
}
L(i, l + 1, k + l) {
(f[i][i] += 1) %= mod;
}
// L(i, 1, k + l) {
// L(j, 1, k + l) {
// cout << f[i][j] << ' ';
// }
// cout << endl;
// }
// cout << endl;
cout << det(k + l) << '\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3572kb
input:
2 2 1 2 2 1 1 1 2 1
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 2ms
memory: 3360kb
input:
3 4 2 1 1 4 1 4 2 2
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 2ms
memory: 3584kb
input:
10 10 3 4 1 2 3 8 9 10 2 3 2 5 4 6 7 8
output:
388035318
result:
ok 1 number(s): "388035318"
Test #4:
score: 0
Accepted
time: 2ms
memory: 3460kb
input:
10 10 5 0 1 2 3 4 8 4 6 8 9 10
output:
534075044
result:
ok 1 number(s): "534075044"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3588kb
input:
10 10 5 10 1 2 3 6 9 6 7 8 9 10 5 7 1 7 8 8 8 1 9 2 9 7 10 1 7 2 6 7 6 1
output:
113105350
result:
ok 1 number(s): "113105350"
Test #6:
score: 0
Accepted
time: 2ms
memory: 3516kb
input:
10 10 5 20 1 2 4 6 8 1 3 4 6 8 9 6 6 5 9 8 2 9 7 6 9 3 8 3 5 4 3 8 4 5 5 9 3 3 4 2 4 8 8 5 10 7 1 8 7 3 5 2 1 5
output:
312012
result:
ok 1 number(s): "312012"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
10 10 5 30 1 3 5 6 8 6 7 8 9 10 9 9 8 7 4 8 10 6 3 9 9 6 7 1 1 5 5 4 2 9 7 5 3 3 8 2 2 5 1 9 6 2 8 5 6 5 8 9 3 7 3 1 10 2 4 3 2 2 6 9 7 3 7 8 1 7 4 1 4 6
output:
720108525
result:
ok 1 number(s): "720108525"
Test #8:
score: 0
Accepted
time: 2ms
memory: 3560kb
input:
10 10 1 0 1 3
output:
55
result:
ok 1 number(s): "55"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
10 10 2 10 2 6 5 6 8 1 9 3 3 7 9 8 7 8 7 1 2 4 8 7 5 5 6 9
output:
0
result:
ok 1 number(s): "0"
Test #10:
score: 0
Accepted
time: 2ms
memory: 3556kb
input:
10 10 3 20 3 4 5 4 6 9 2 3 3 2 1 9 7 5 10 7 6 9 3 4 5 1 1 6 5 6 8 4 10 1 5 3 7 7 4 7 9 6 10 5 3 6 5 8 8 8
output:
0
result:
ok 1 number(s): "0"
Test #11:
score: 0
Accepted
time: 2ms
memory: 3468kb
input:
10 10 4 30 1 2 3 4 5 6 7 9 10 1 8 1 1 2 5 7 2 3 10 8 7 9 5 3 6 2 9 9 9 1 2 7 10 4 4 4 4 8 7 7 6 7 7 1 4 2 5 1 9 6 9 3 2 9 3 9 3 7 3 5 7 4 1 4 1 9 8 5
output:
0
result:
ok 1 number(s): "0"
Test #12:
score: 0
Accepted
time: 2ms
memory: 3468kb
input:
10 10 6 30 3 4 5 6 7 8 5 6 7 8 9 10 3 4 10 8 9 6 6 5 6 9 1 9 2 4 10 6 7 4 7 6 6 7 3 8 7 2 5 5 1 1 2 1 8 1 4 3 8 6 5 9 2 6 8 4 1 7 5 2 3 2 1 4 2 8 8 9 6 1 4 5
output:
0
result:
ok 1 number(s): "0"
Test #13:
score: 0
Accepted
time: 2ms
memory: 3540kb
input:
10 10 7 30 1 2 3 4 5 9 10 2 3 4 7 8 9 10 9 3 10 4 2 3 2 8 5 3 2 6 1 4 7 1 6 4 3 5 6 9 10 2 4 6 5 6 7 6 4 3 8 7 6 6 9 5 8 4 7 4 1 8 5 8 3 7 9 8 7 8 8 1 3 3 10 6 8 9
output:
58415340
result:
ok 1 number(s): "58415340"
Test #14:
score: 0
Accepted
time: 2ms
memory: 3512kb
input:
10 10 4 20 1 2 5 7 5 7 8 10 10 3 3 2 10 6 9 7 9 4 1 4 8 6 6 3 7 5 3 8 2 3 4 6 6 8 7 8 3 6 8 8 6 6 4 2 4 9 1 1
output:
212921229
result:
ok 1 number(s): "212921229"
Test #15:
score: 0
Accepted
time: 2ms
memory: 3572kb
input:
10 10 6 20 1 2 4 7 8 9 3 4 5 8 9 10 3 5 6 5 4 5 6 1 1 8 8 8 2 5 4 9 6 3 4 2 4 7 5 2 9 7 3 8 2 2 9 4 7 6 1 4 8 5 2 7
output:
215578944
result:
ok 1 number(s): "215578944"
Test #16:
score: 0
Accepted
time: 2ms
memory: 3448kb
input:
100 10 6 20 1 2 3 4 6 7 2 4 5 6 7 9 17 6 46 9 76 2 75 4 27 6 22 4 5 1 33 7 78 1 38 7 83 9 32 5 97 3 25 8 90 3 50 7 87 1 61 3 39 1 28 9
output:
266132935
result:
ok 1 number(s): "266132935"
Test #17:
score: 0
Accepted
time: 2ms
memory: 3444kb
input:
100 10 5 20 1 2 3 4 5 2 5 6 8 9 73 2 56 8 57 9 60 3 5 8 74 3 92 2 72 9 17 4 61 8 41 7 88 8 91 4 52 7 50 4 94 9 64 7 27 6 14 7 4 2
output:
558957370
result:
ok 1 number(s): "558957370"
Test #18:
score: 0
Accepted
time: 2ms
memory: 3456kb
input:
100 10 3 20 6 7 9 6 9 10 90 4 72 2 19 1 19 9 64 3 85 3 66 7 66 5 19 6 84 5 16 1 55 6 74 4 31 3 73 4 52 2 32 9 87 2 4 8 70 2
output:
0
result:
ok 1 number(s): "0"
Test #19:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
100 10 4 30 2 5 6 7 2 6 8 9 52 1 26 6 39 8 44 9 38 5 11 9 47 3 46 5 42 9 14 2 65 7 68 5 44 1 20 2 42 7 12 4 6 8 73 5 87 2 17 2 28 8 100 4 25 1 3 1 8 2 12 6 36 3 3 3 86 1 95 7
output:
803776201
result:
ok 1 number(s): "803776201"
Test #20:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
100 10 5 50 1 2 3 4 5 2 3 8 9 10 8 1 45 7 69 9 85 6 51 8 40 2 85 4 67 7 65 3 28 7 98 7 94 3 47 5 50 3 44 3 76 8 50 9 48 7 81 9 16 4 70 5 22 3 80 3 22 6 33 3 57 2 4 5 6 5 18 9 74 5 11 5 14 2 3 4 3 1 68 4 37 5 93 7 42 8 78 6 71 2 27 7 57 7 96 6 69 1 30 2 9 6 39 8 54 8 2 3 78 4
output:
463426103
result:
ok 1 number(s): "463426103"
Test #21:
score: 0
Accepted
time: 2ms
memory: 3484kb
input:
100 10 6 50 3 4 5 6 8 9 5 6 7 8 9 10 56 1 39 8 84 6 4 4 66 6 88 8 95 8 24 9 78 2 54 5 85 1 3 4 81 5 36 6 69 9 47 1 60 2 26 9 68 9 8 3 13 2 31 3 25 2 72 3 88 3 81 9 97 1 67 1 90 4 86 6 74 8 56 7 50 6 94 5 67 5 49 3 42 7 42 5 53 7 87 1 80 3 12 6 96 6 58 7 15 9 46 7 89 3 17 6 71 6 6 5
output:
123434985
result:
ok 1 number(s): "123434985"
Test #22:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
10 100 3 50 14 20 52 44 57 68 1 24 8 43 2 26 6 57 5 56 3 85 2 3 10 80 4 18 9 30 6 6 5 3 4 91 5 50 9 37 4 66 10 10 9 7 7 15 7 46 4 15 2 68 9 50 8 39 5 5 8 64 9 4 5 79 8 59 9 19 10 23 7 19 8 6 5 38 8 92 6 93 5 94 1 21 6 85 5 71 4 60 9 23 3 61 2 76 4 21 8 82 6 99 9 55 3 96 9 64
output:
0
result:
ok 1 number(s): "0"
Test #23:
score: 0
Accepted
time: 2ms
memory: 3504kb
input:
10 100 5 50 12 14 45 50 54 20 24 68 80 88 5 37 10 43 5 86 1 18 6 40 2 83 8 64 6 97 4 31 2 59 3 63 6 17 1 57 5 92 4 9 3 96 9 88 6 71 8 93 10 32 2 32 2 3 6 60 5 57 8 86 4 23 4 40 7 84 10 51 8 83 5 10 8 75 5 44 7 43 1 65 10 20 1 15 3 71 1 30 2 98 8 14 1 92 5 69 10 53 8 48 4 43 3 92 6 74 5 41 3 67
output:
0
result:
ok 1 number(s): "0"
Test #24:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
10 100 7 50 11 13 21 32 35 67 89 41 56 70 75 90 91 92 3 49 8 39 5 39 1 66 7 15 5 73 8 22 6 24 7 40 1 87 6 28 6 30 3 14 9 40 2 77 5 24 1 63 7 29 6 73 4 19 8 63 10 88 6 56 7 70 7 79 4 56 3 96 2 79 5 85 3 39 7 35 3 35 6 87 1 48 10 38 1 42 3 53 4 60 1 12 9 94 9 4 8 50 9 62 10 60 4 50 7 23 3 81 4 98 2 57...
output:
0
result:
ok 1 number(s): "0"
Test #25:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
100 100 10 50 4 11 20 24 33 37 38 57 60 71 42 47 48 62 68 80 84 87 91 95 28 22 49 40 89 44 72 33 66 29 99 80 38 92 18 80 36 73 63 26 65 31 48 52 84 6 34 95 37 80 3 94 23 40 37 84 42 75 33 49 97 13 37 19 57 92 78 5 92 89 82 49 23 36 95 85 64 23 86 88 97 51 50 55 51 53 66 67 100 95 54 39 50 34 23 32 9...
output:
0
result:
ok 1 number(s): "0"
Test #26:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
100 100 20 50 1 2 9 11 12 15 17 18 20 22 25 34 45 52 56 59 67 71 78 83 23 25 29 35 37 38 53 61 67 68 69 77 80 81 82 85 87 91 95 96 100 15 13 38 42 54 11 31 28 31 14 56 17 5 51 46 59 40 5 72 24 41 100 77 42 70 81 96 3 27 60 9 21 36 40 90 99 51 59 57 51 63 96 29 6 17 23 41 3 45 5 4 84 22 21 63 19 6 59...
output:
0
result:
ok 1 number(s): "0"
Test #27:
score: 0
Accepted
time: 1ms
memory: 3524kb
input:
100 100 30 50 6 9 10 11 14 16 17 18 19 20 21 22 24 25 26 28 30 31 32 39 48 51 58 63 64 65 67 73 78 82 33 34 38 40 42 50 52 53 54 56 60 62 64 68 70 71 74 80 81 84 86 87 88 89 90 95 97 98 99 100 77 7 74 44 83 60 58 21 91 40 30 37 97 9 84 19 78 11 46 23 90 54 40 94 3 46 24 93 65 73 16 34 24 36 40 88 57...
output:
0
result:
ok 1 number(s): "0"
Test #28:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
100 100 40 50 1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 22 26 27 30 33 34 37 38 39 44 45 50 53 54 56 57 62 63 65 66 67 71 77 78 16 19 20 32 33 35 39 41 47 48 52 53 56 61 62 64 65 66 69 70 72 74 75 76 77 78 81 82 83 84 86 87 88 89 90 96 97 98 99 100 57 4 43 42 36 70 93 11 49 46 41 17 76 14 4 92 92 88 7...
output:
696316238
result:
ok 1 number(s): "696316238"
Test #29:
score: 0
Accepted
time: 1ms
memory: 3560kb
input:
100 100 50 50 4 5 6 7 9 10 11 12 13 14 15 16 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 35 39 40 41 44 45 46 49 50 51 52 53 57 60 64 66 73 77 78 80 82 92 98 23 26 29 33 35 36 39 41 42 47 48 49 54 55 56 57 58 59 60 61 62 63 64 66 68 70 71 72 73 74 76 77 79 81 82 83 84 88 89 90 91 92 93 94 95 96 97 ...
output:
0
result:
ok 1 number(s): "0"
Test #30:
score: 0
Accepted
time: 1ms
memory: 3560kb
input:
100 100 50 50 1 2 3 4 5 6 7 8 9 10 11 12 13 14 17 18 19 20 21 22 25 26 28 29 31 32 33 36 37 38 39 40 41 42 43 44 45 46 47 50 57 59 62 63 64 65 70 71 77 78 4 6 10 13 29 32 37 41 43 44 46 47 52 53 55 58 62 63 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 83 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...
output:
55822359
result:
ok 1 number(s): "55822359"
Test #31:
score: 0
Accepted
time: 3ms
memory: 3672kb
input:
100 100 50 50 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 28 29 31 32 34 35 36 37 38 39 40 41 47 48 49 50 51 52 53 55 60 65 67 68 20 24 28 31 33 35 40 45 46 54 55 56 57 58 59 61 62 63 66 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
268820259
result:
ok 1 number(s): "268820259"
Test #32:
score: 0
Accepted
time: 3ms
memory: 3592kb
input:
100 100 50 50 1 2 3 4 5 6 7 8 9 10 11 12 13 15 16 20 21 22 23 24 25 27 28 29 30 31 32 33 34 35 36 37 38 41 42 43 46 51 52 55 56 57 58 59 60 63 66 69 80 91 7 18 23 25 26 36 37 38 40 44 47 48 51 54 55 60 63 64 65 66 67 69 70 71 72 73 75 77 78 79 80 81 82 83 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99...
output:
252789512
result:
ok 1 number(s): "252789512"
Test #33:
score: 0
Accepted
time: 3ms
memory: 3520kb
input:
100 100 50 50 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 17 19 20 21 22 23 25 26 27 28 29 30 31 32 35 39 40 41 42 44 46 47 51 52 53 57 58 59 64 66 69 78 79 85 86 18 23 28 30 31 32 33 34 35 38 42 43 47 49 53 55 58 61 63 64 65 66 68 70 71 74 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
604525399
result:
ok 1 number(s): "604525399"