Submission #40569324
Source Code Expand
P,H,W,K = 998244353,*gets.split.map(&:to_i)
Ck = lambda{|x,p,r|
num,dnm = [1,1],[1,1]
2.upto(x){|n|
num << num[-1]*n%p
dnm << p - dnm[p%n]*(p/n)%p # 謎
}
1.upto(dnm.size-1){|n|
dnm[n] = dnm[n-1]*dnm[n]%p # 謎
}
next (0..x).map{|n|
n<r ? 0 : num[n]*dnm[r]*dnm[n-r]%p
}
}.call H*W,P,K
p (H*W%P*Ck[H*W]-(1..H).sum{|h|
(1..W).sum{|w|
Ck[(h-1)*W]+Ck[(H-h)*W]+Ck[H*(w-1)]+Ck[H*(W-w)]-Ck[(h-1)*(w-1)]-Ck[(h-1)*(W-w)]-Ck[(H-h)*(w-1)]-Ck[(H-h)*(W-w)]
}
})*Ck[H*W].pow(P-2,P)%P
Submission Info
| Submission Time | |
|---|---|
| Task | F - Minimum Bounding Box 2 |
| User | ds14050 |
| Language | Ruby (2.7.1) |
| Score | 500 |
| Code Size | 508 Byte |
| Status | AC |
| Exec Time | 812 ms |
| Memory | 37892 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
| All | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_01.txt | AC | 56 ms | 14160 KiB |
| 00_sample_02.txt | AC | 58 ms | 14156 KiB |
| 00_sample_03.txt | AC | 90 ms | 15628 KiB |
| 01_test_01.txt | AC | 57 ms | 14212 KiB |
| 01_test_02.txt | AC | 58 ms | 14224 KiB |
| 01_test_03.txt | AC | 572 ms | 37468 KiB |
| 01_test_04.txt | AC | 794 ms | 37892 KiB |
| 01_test_05.txt | AC | 812 ms | 37728 KiB |
| 01_test_06.txt | AC | 791 ms | 37736 KiB |
| 01_test_07.txt | AC | 695 ms | 36112 KiB |
| 01_test_08.txt | AC | 655 ms | 33668 KiB |
| 01_test_09.txt | AC | 529 ms | 35072 KiB |
| 01_test_10.txt | AC | 643 ms | 37264 KiB |
| 01_test_11.txt | AC | 584 ms | 35868 KiB |
| 01_test_12.txt | AC | 328 ms | 23584 KiB |
| 01_test_13.txt | AC | 532 ms | 30312 KiB |
| 01_test_14.txt | AC | 287 ms | 22448 KiB |
| 01_test_15.txt | AC | 392 ms | 25912 KiB |
| 01_test_16.txt | AC | 222 ms | 20160 KiB |
| 01_test_17.txt | AC | 357 ms | 25044 KiB |