Task: | Grid paths |
Sender: | aalto2024l_007 |
Submission time: | 2024-11-20 17:04:11 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | ACCEPTED | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | ACCEPTED | 0.00 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | ACCEPTED | 0.00 s | details |
#9 | ACCEPTED | 0.00 s | details |
#10 | ACCEPTED | 0.00 s | details |
#11 | ACCEPTED | 0.00 s | details |
#12 | ACCEPTED | 0.00 s | details |
#13 | ACCEPTED | 0.00 s | details |
#14 | ACCEPTED | 0.00 s | details |
#15 | ACCEPTED | 0.00 s | details |
#16 | ACCEPTED | 0.00 s | details |
#17 | ACCEPTED | 0.00 s | details |
#18 | ACCEPTED | 0.00 s | details |
#19 | ACCEPTED | 0.00 s | details |
#20 | ACCEPTED | 0.00 s | details |
#21 | ACCEPTED | 0.00 s | details |
#22 | ACCEPTED | 0.00 s | details |
#23 | ACCEPTED | 0.00 s | details |
#24 | ACCEPTED | 0.00 s | details |
#25 | ACCEPTED | 0.00 s | details |
#26 | ACCEPTED | 0.00 s | details |
#27 | ACCEPTED | 0.00 s | details |
#28 | ACCEPTED | 0.00 s | details |
#29 | ACCEPTED | 0.00 s | details |
#30 | ACCEPTED | 0.00 s | details |
#31 | ACCEPTED | 0.00 s | details |
#32 | ACCEPTED | 0.00 s | details |
#33 | ACCEPTED | 0.00 s | details |
#34 | ACCEPTED | 0.00 s | details |
#35 | ACCEPTED | 0.00 s | details |
#36 | ACCEPTED | 0.00 s | details |
#37 | ACCEPTED | 0.00 s | details |
#38 | ACCEPTED | 0.00 s | details |
#39 | ACCEPTED | 0.00 s | details |
#40 | ACCEPTED | 0.00 s | details |
#41 | ACCEPTED | 0.00 s | details |
#42 | ACCEPTED | 0.00 s | details |
#43 | ACCEPTED | 0.00 s | details |
#44 | ACCEPTED | 0.00 s | details |
#45 | ACCEPTED | 0.00 s | details |
#46 | ACCEPTED | 0.00 s | details |
#47 | ACCEPTED | 0.00 s | details |
#48 | ACCEPTED | 0.00 s | details |
#49 | ACCEPTED | 0.00 s | details |
#50 | ACCEPTED | 0.00 s | details |
#51 | ACCEPTED | 0.00 s | details |
#52 | ACCEPTED | 0.00 s | details |
#53 | ACCEPTED | 0.01 s | details |
#54 | ACCEPTED | 0.01 s | details |
#55 | ACCEPTED | 0.01 s | details |
#56 | ACCEPTED | 0.01 s | details |
#57 | ACCEPTED | 0.01 s | details |
#58 | ACCEPTED | 0.01 s | details |
#59 | ACCEPTED | 0.01 s | details |
#60 | ACCEPTED | 0.01 s | details |
#61 | ACCEPTED | 0.01 s | details |
#62 | ACCEPTED | 0.01 s | details |
#63 | ACCEPTED | 0.01 s | details |
#64 | ACCEPTED | 0.01 s | details |
#65 | ACCEPTED | 0.01 s | details |
#66 | ACCEPTED | 0.01 s | details |
#67 | ACCEPTED | 0.01 s | details |
#68 | ACCEPTED | 0.01 s | details |
#69 | ACCEPTED | 0.01 s | details |
#70 | ACCEPTED | 0.01 s | details |
#71 | ACCEPTED | 0.01 s | details |
#72 | ACCEPTED | 0.01 s | details |
#73 | ACCEPTED | 0.01 s | details |
#74 | ACCEPTED | 0.00 s | details |
#75 | ACCEPTED | 0.01 s | details |
#76 | ACCEPTED | 0.01 s | details |
#77 | ACCEPTED | 0.01 s | details |
#78 | ACCEPTED | 0.01 s | details |
#79 | ACCEPTED | 0.01 s | details |
#80 | ACCEPTED | 0.01 s | details |
#81 | ACCEPTED | 0.01 s | details |
#82 | ACCEPTED | 0.01 s | details |
#83 | ACCEPTED | 0.01 s | details |
#84 | ACCEPTED | 0.01 s | details |
#85 | ACCEPTED | 0.01 s | details |
#86 | ACCEPTED | 0.01 s | details |
#87 | ACCEPTED | 0.01 s | details |
#88 | ACCEPTED | 0.01 s | details |
#89 | ACCEPTED | 0.01 s | details |
#90 | ACCEPTED | 0.01 s | details |
#91 | ACCEPTED | 0.01 s | details |
#92 | ACCEPTED | 0.01 s | details |
#93 | ACCEPTED | 0.01 s | details |
#94 | ACCEPTED | 0.01 s | details |
#95 | ACCEPTED | 0.01 s | details |
#96 | ACCEPTED | 0.01 s | details |
#97 | ACCEPTED | 0.01 s | details |
#98 | ACCEPTED | 0.01 s | details |
#99 | ACCEPTED | 0.01 s | details |
#100 | ACCEPTED | 0.01 s | details |
#101 | ACCEPTED | 0.01 s | details |
#102 | ACCEPTED | 0.01 s | details |
Code
#include <iostream> #include <vector> #include <array> #include <string> #include <algorithm> #include <numeric> #include <unordered_map> #include <unordered_set> #include <set> #include <queue> #include <climits> #include <cmath> #include <functional> #include <type_traits> #include <fstream> #include <bitset> #include <complex> #include <iomanip> #include <ext/pb_ds/assoc_container.hpp> // gcc only template<typename T> using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, std::less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; #define int long long using namespace std; #define cross(x, y) (((x)*conj(y)).imag()) #define sign(v) ((0 < (v)) - ((v) < 0)) int p(int a, int b, int m) { if (b == 0) return 1; else if (b % 2 == 0) { int r = p(a, b/2, m); return (r*r) % m; } else return (p(a, b-1, m)*a) % m; } int gdc(int a, int b) { if (b == 0) return a; return gdc(b, a%b); } int nCr(int n, int r, int mod) { int res = 1; for (int i = 0; i < r; i++) { res *= (n-i); res *= p(i+1, mod-2, mod); } return res; } int mod = 998244353; vector<int> nums; void solve() { int x, y, z; cin >> x >> y >> z; int n = x + y + z; int fact = 1; nums.resize(n+1); nums[0] = 1; for (int i = 1; i <= n; i++) { nums[i] = nums[i-1] * i; nums[i] %= mod; fact %= mod; } //int a = fact[n] * p((fact[n-x]*fact[x]) % mod, mod - 2, mod); //int a = fact[n] * p((fact[n-y]*fact[x]) % mod, mod - 2, mod); //int a = fact[n] * p((fact[n-z]*fact[x]) % mod, mod - 2, mod); int res = nums[n]; int dem = (((nums[z] * nums[x])%mod) * nums[y])%mod; int res2 = res * p(dem, mod-2, mod); res2 %= mod; cout << res2; } signed main() { ios::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; for (int i = 0; i < t; i++) { solve(); //cout.flush(); } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 1 1 |
correct output |
---|
6 |
user output |
---|
6 |
Test 2
Verdict: ACCEPTED
input |
---|
1 2 2 |
correct output |
---|
30 |
user output |
---|
30 |
Test 3
Verdict: ACCEPTED
input |
---|
2 2 2 |
correct output |
---|
90 |
user output |
---|
90 |
Test 4
Verdict: ACCEPTED
input |
---|
1 3 2 |
correct output |
---|
60 |
user output |
---|
60 |
Test 5
Verdict: ACCEPTED
input |
---|
1 0 0 |
correct output |
---|
1 |
user output |
---|
1 |
Test 6
Verdict: ACCEPTED
input |
---|
2 0 3 |
correct output |
---|
10 |
user output |
---|
10 |
Test 7
Verdict: ACCEPTED
input |
---|
4 4 2 |
correct output |
---|
3150 |
user output |
---|
3150 |
Test 8
Verdict: ACCEPTED
input |
---|
1 0 4 |
correct output |
---|
5 |
user output |
---|
5 |
Test 9
Verdict: ACCEPTED
input |
---|
5 5 1 |
correct output |
---|
2772 |
user output |
---|
2772 |
Test 10
Verdict: ACCEPTED
input |
---|
0 1 4 |
correct output |
---|
5 |
user output |
---|
5 |
Test 11
Verdict: ACCEPTED
input |
---|
5 0 5 |
correct output |
---|
252 |
user output |
---|
252 |
Test 12
Verdict: ACCEPTED
input |
---|
0 2 3 |
correct output |
---|
10 |
user output |
---|
10 |
Test 13
Verdict: ACCEPTED
input |
---|
6 6 7 |
correct output |
---|
46558512 |
user output |
---|
46558512 |
Test 14
Verdict: ACCEPTED
input |
---|
4 10 7 |
correct output |
---|
116396280 |
user output |
---|
116396280 |
Test 15
Verdict: ACCEPTED
input |
---|
4 2 0 |
correct output |
---|
15 |
user output |
---|
15 |
Test 16
Verdict: ACCEPTED
input |
---|
6 0 7 |
correct output |
---|
1716 |
user output |
---|
1716 |
Test 17
Verdict: ACCEPTED
input |
---|
10 9 6 |
correct output |
---|
388234152 |
user output |
---|
388234152 |
Test 18
Verdict: ACCEPTED
input |
---|
2 0 9 |
correct output |
---|
55 |
user output |
---|
55 |
Test 19
Verdict: ACCEPTED
input |
---|
9 10 3 |
correct output |
---|
142262120 |
user output |
---|
142262120 |
Test 20
Verdict: ACCEPTED
input |
---|
0 2 8 |
correct output |
---|
45 |
user output |
---|
45 |
Test 21
Verdict: ACCEPTED
input |
---|
9 0 10 |
correct output |
---|
92378 |
user output |
---|
92378 |
Test 22
Verdict: ACCEPTED
input |
---|
0 4 5 |
correct output |
---|
126 |
user output |
---|
126 |
Test 23
Verdict: ACCEPTED
input |
---|
77 30 2 |
correct output |
---|
207933206 |
user output |
---|
207933206 |
Test 24
Verdict: ACCEPTED
input |
---|
18 6 1 |
correct output |
---|
3364900 |
user output |
---|
3364900 |
Test 25
Verdict: ACCEPTED
input |
---|
15 45 74 |
correct output |
---|
53128847 |
user output |
---|
53128847 |
Test 26
Verdict: ACCEPTED
input |
---|
78 61 23 |
correct output |
---|
501316289 |
user output |
---|
501316289 |
Test 27
Verdict: ACCEPTED
input |
---|
51 93 78 |
correct output |
---|
126313894 |
user output |
---|
126313894 |
Test 28
Verdict: ACCEPTED
input |
---|
85 82 18 |
correct output |
---|
531313357 |
user output |
---|
531313357 |
Test 29
Verdict: ACCEPTED
input |
---|
22 32 52 |
correct output |
---|
837184390 |
user output |
---|
837184390 |
Test 30
Verdict: ACCEPTED
input |
---|
29 18 53 |
correct output |
---|
62578813 |
user output |
---|
62578813 |
Test 31
Verdict: ACCEPTED
input |
---|
65 7 51 |
correct output |
---|
422701975 |
user output |
---|
422701975 |
Test 32
Verdict: ACCEPTED
input |
---|
9 43 76 |
correct output |
---|
83791842 |
user output |
---|
83791842 |
Test 33
Verdict: ACCEPTED
input |
---|
588 888 898 |
correct output |
---|
503848334 |
user output |
---|
503848334 |
Test 34
Verdict: ACCEPTED
input |
---|
48 800 289 |
correct output |
---|
155056270 |
user output |
---|
155056270 |
Test 35
Verdict: ACCEPTED
input |
---|
208 702 482 |
correct output |
---|
539442446 |
user output |
---|
539442446 |
Test 36
Verdict: ACCEPTED
input |
---|
517 669 947 |
correct output |
---|
637353246 |
user output |
---|
637353246 |
Test 37
Verdict: ACCEPTED
input |
---|
960 294 700 |
correct output |
---|
342937256 |
user output |
---|
342937256 |
Test 38
Verdict: ACCEPTED
input |
---|
870 696 582 |
correct output |
---|
616260310 |
user output |
---|
616260310 |
Test 39
Verdict: ACCEPTED
input |
---|
308 713 519 |
correct output |
---|
33883838 |
user output |
---|
33883838 |
Test 40
Verdict: ACCEPTED
input |
---|
426 481 815 |
correct output |
---|
556824158 |
user output |
---|
556824158 |
Test 41
Verdict: ACCEPTED
input |
---|
729 170 561 |
correct output |
---|
509492253 |
user output |
---|
509492253 |
Test 42
Verdict: ACCEPTED
input |
---|
864 801 285 |
correct output |
---|
364315381 |
user output |
---|
364315381 |
Test 43
Verdict: ACCEPTED
input |
---|
6442 9170 3807 |
correct output |
---|
786529613 |
user output |
---|
786529613 |
Test 44
Verdict: ACCEPTED
input |
---|
2860 289 9582 |
correct output |
---|
685493194 |
user output |
---|
685493194 |
Test 45
Verdict: ACCEPTED
input |
---|
8589 596 3727 |
correct output |
---|
760680556 |
user output |
---|
760680556 |
Test 46
Verdict: ACCEPTED
input |
---|
2485 6897 4500 |
correct output |
---|
940772711 |
user output |
---|
940772711 |
Test 47
Verdict: ACCEPTED
input |
---|
385 1957 7801 |
correct output |
---|
857634324 |
user output |
---|
857634324 |
Test 48
Verdict: ACCEPTED
input |
---|
4581 4498 3083 |
correct output |
---|
434838551 |
user output |
---|
434838551 |
Test 49
Verdict: ACCEPTED
input |
---|
7285 876 6016 |
correct output |
---|
542143311 |
user output |
---|
542143311 |
Test 50
Verdict: ACCEPTED
input |
---|
9445 1392 4641 |
correct output |
---|
71990254 |
user output |
---|
71990254 |
Test 51
Verdict: ACCEPTED
input |
---|
3848 8971 8597 |
correct output |
---|
894107749 |
user output |
---|
894107749 |
Test 52
Verdict: ACCEPTED
input |
---|
5469 56 7979 |
correct output |
---|
530063189 |
user output |
---|
530063189 |
Test 53
Verdict: ACCEPTED
input |
---|
40769 64401 5536 |
correct output |
---|
835170422 |
user output |
---|
835170422 |
Test 54
Verdict: ACCEPTED
input |
---|
25092 68058 4609 |
correct output |
---|
774058420 |
user output |
---|
774058420 |
Test 55
Verdict: ACCEPTED
input |
---|
37454 79655 95072 |
correct output |
---|
146618336 |
user output |
---|
146618336 |
Test 56
Verdict: ACCEPTED
input |
---|
11505 49686 60907 |
correct output |
---|
460903426 |
user output |
---|
460903426 |
Test 57
Verdict: ACCEPTED
input |
---|
83485 43254 10479 |
correct output |
---|
365702907 |
user output |
---|
365702907 |
Test 58
Verdict: ACCEPTED
input |
---|
98902 30454 54955 |
correct output |
---|
137657373 |
user output |
---|
137657373 |
Test 59
Verdict: ACCEPTED
input |
---|
78384 25805 63484 |
correct output |
---|
364221017 |
user output |
---|
364221017 |
Test 60
Verdict: ACCEPTED
input |
---|
11349 85177 97449 |
correct output |
---|
878820672 |
user output |
---|
878820672 |
Test 61
Verdict: ACCEPTED
input |
---|
1749 42649 89158 |
correct output |
---|
568752540 |
user output |
---|
568752540 |
Test 62
Verdict: ACCEPTED
input |
---|
30096 47374 24706 |
correct output |
---|
829354422 |
user output |
---|
829354422 |
Test 63
Verdict: ACCEPTED
input |
---|
54882 59285 71520 |
correct output |
---|
623675666 |
user output |
---|
623675666 |
Test 64
Verdict: ACCEPTED
input |
---|
41702 99720 72033 |
correct output |
---|
277561895 |
user output |
---|
277561895 |
Test 65
Verdict: ACCEPTED
input |
---|
43600 18508 2592 |
correct output |
---|
412985183 |
user output |
---|
412985183 |
Test 66
Verdict: ACCEPTED
input |
---|
55080 7072 70815 |
correct output |
---|
652841102 |
user output |
---|
652841102 |
Test 67
Verdict: ACCEPTED
input |
---|
96704 90063 54724 |
correct output |
---|
774619311 |
user output |
---|
774619311 |
Test 68
Verdict: ACCEPTED
input |
---|
22199 5518 87074 |
correct output |
---|
696743124 |
user output |
---|
696743124 |
Test 69
Verdict: ACCEPTED
input |
---|
89287 94749 33198 |
correct output |
---|
584345165 |
user output |
---|
584345165 |
Test 70
Verdict: ACCEPTED
input |
---|
7630 22734 77993 |
correct output |
---|
570604316 |
user output |
---|
570604316 |
Test 71
Verdict: ACCEPTED
input |
---|
87344 1111 96855 |
correct output |
---|
17915653 |
user output |
---|
17915653 |
Test 72
Verdict: ACCEPTED
input |
---|
1037 36446 50188 |
correct output |
---|
856454369 |
user output |
---|
856454369 |
Test 73
Verdict: ACCEPTED
input |
---|
77133 29876 2075 |
correct output |
---|
954243600 |
user output |
---|
954243600 |
Test 74
Verdict: ACCEPTED
input |
---|
18027 6830 1947 |
correct output |
---|
317560580 |
user output |
---|
317560580 |
Test 75
Verdict: ACCEPTED
input |
---|
15416 44622 74006 |
correct output |
---|
58145749 |
user output |
---|
58145749 |
Test 76
Verdict: ACCEPTED
input |
---|
77771 60735 23754 |
correct output |
---|
506483665 |
user output |
---|
506483665 |
Test 77
Verdict: ACCEPTED
input |
---|
51395 92190 77317 |
correct output |
---|
162293324 |
user output |
---|
162293324 |
Test 78
Verdict: ACCEPTED
input |
---|
84883 81359 17889 |
correct output |
---|
756622374 |
user output |
---|
756622374 |
Test 79
Verdict: ACCEPTED
input |
---|
22329 32666 52317 |
correct output |
---|
340258046 |
user output |
---|
340258046 |
Test 80
Verdict: ACCEPTED
input |
---|
29466 18178 53059 |
correct output |
---|
198540032 |
user output |
---|
198540032 |
Test 81
Verdict: ACCEPTED
input |
---|
65038 7601 50546 |
correct output |
---|
977669993 |
user output |
---|
977669993 |
Test 82
Verdict: ACCEPTED
input |
---|
9753 43047 76126 |
correct output |
---|
980244494 |
user output |
---|
980244494 |
Test 83
Verdict: ACCEPTED
input |
---|
58814 88742 89772 |
correct output |
---|
967086349 |
user output |
---|
967086349 |
Test 84
Verdict: ACCEPTED
input |
---|
4872 79928 28911 |
correct output |
---|
451336611 |
user output |
---|
451336611 |
Test 85
Verdict: ACCEPTED
input |
---|
20846 70197 48168 |
correct output |
---|
813382933 |
user output |
---|
813382933 |
Test 86
Verdict: ACCEPTED
input |
---|
51730 66910 94697 |
correct output |
---|
68361808 |
user output |
---|
68361808 |
Test 87
Verdict: ACCEPTED
input |
---|
96003 29443 69952 |
correct output |
---|
85060141 |
user output |
---|
85060141 |
Test 88
Verdict: ACCEPTED
input |
---|
87013 69607 58228 |
correct output |
---|
663549762 |
user output |
---|
663549762 |
Test 89
Verdict: ACCEPTED
input |
---|
30793 71312 51939 |
correct output |
---|
819595366 |
user output |
---|
819595366 |
Test 90
Verdict: ACCEPTED
input |
---|
42572 48080 81459 |
correct output |
---|
545882121 |
user output |
---|
545882121 |
Test 91
Verdict: ACCEPTED
input |
---|
72902 17082 56124 |
correct output |
---|
753823906 |
user output |
---|
753823906 |
Test 92
Verdict: ACCEPTED
input |
---|
86377 80054 28491 |
correct output |
---|
760419142 |
user output |
---|
760419142 |
Test 93
Verdict: ACCEPTED
input |
---|
64415 91699 38075 |
correct output |
---|
939685526 |
user output |
---|
939685526 |
Test 94
Verdict: ACCEPTED
input |
---|
28605 2899 95812 |
correct output |
---|
886982112 |
user output |
---|
886982112 |
Test 95
Verdict: ACCEPTED
input |
---|
85890 5965 37271 |
correct output |
---|
830797537 |
user output |
---|
830797537 |
Test 96
Verdict: ACCEPTED
input |
---|
24851 68969 44998 |
correct output |
---|
785235517 |
user output |
---|
785235517 |
Test 97
Verdict: ACCEPTED
input |
---|
3856 19576 78011 |
correct output |
---|
586779888 |
user output |
---|
586779888 |
Test 98
Verdict: ACCEPTED
input |
---|
45806 44980 30835 |
correct output |
---|
61814992 |
user output |
---|
61814992 |
Test 99
Verdict: ACCEPTED
input |
---|
72851 8764 60162 |
correct output |
---|
423877809 |
user output |
---|
423877809 |
Test 100
Verdict: ACCEPTED
input |
---|
94451 13922 46410 |
correct output |
---|
534902695 |
user output |
---|
534902695 |
Test 101
Verdict: ACCEPTED
input |
---|
38477 89702 85972 |
correct output |
---|
149142997 |
user output |
---|
149142997 |
Test 102
Verdict: ACCEPTED
input |
---|
54689 566 79791 |
correct output |
---|
121698401 |
user output |
---|
121698401 |