結果
問題 | No.2345 max(l,r) |
ユーザー | chineristAC |
提出日時 | 2023-06-09 23:41:25 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,699 bytes |
コンパイル時間 | 572 ms |
コンパイル使用メモリ | 87,364 KB |
実行使用メモリ | 136,408 KB |
最終ジャッジ日時 | 2023-08-30 14:49:34 |
合計ジャッジ時間 | 17,889 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 107 ms
81,496 KB |
testcase_01 | WA | - |
testcase_02 | AC | 195 ms
84,180 KB |
testcase_03 | AC | 196 ms
83,928 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 263 ms
86,856 KB |
testcase_13 | AC | 264 ms
86,772 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 167 ms
108,496 KB |
testcase_23 | AC | 168 ms
109,160 KB |
testcase_24 | AC | 128 ms
87,680 KB |
testcase_25 | AC | 138 ms
82,632 KB |
testcase_26 | AC | 136 ms
82,480 KB |
testcase_27 | AC | 138 ms
82,440 KB |
testcase_28 | AC | 137 ms
103,824 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 120 ms
90,348 KB |
testcase_36 | AC | 129 ms
91,260 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | AC | 324 ms
85,160 KB |
ソースコード
import sys from itertools import permutations input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) import random def cmb(n, r, mod): if ( r<0 or r>n ): return 0 return (g1[n] * g2[r] % mod) * g2[n-r] % mod mod = 998244353 N = 2*10**5 g1 = [1]*(N+1) g2 = [1]*(N+1) inverse = [1]*(N+1) for i in range( 2, N + 1 ): g1[i]=( ( g1[i-1] * i ) % mod ) inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod ) g2[i]=( (g2[i-1] * inverse[i]) % mod ) inverse[0]=0 for _ in range(int(input())): N,M = mi() A = li() A.sort() if N & 1 or A[0]!=N//2: k = N//2 if k < A[0]: print(0) continue small = [a for a in A if a <= k] if small[0]!=small[-1]: print(0) continue big = [a for a in A if k < a] dic = {a:0 for a in big} for a in big: dic[a] += 1 big = [(a,dic[a]) for a in dic] big.sort() L,R = 0,0 c = 0 res = 1 for a,t in big[::-1]: tmp_l = N-a-L tmp_r = N-a-R #print(tmp_l,tmp_r,t) if tmp_l == t and tmp_r == t: c += 1 res = 2 * res % mod L += t elif tmp_l == t or tmp_r == t: c += 1 L += t elif tmp_l+tmp_r == t and 0 < tmp_l and 0 < tmp_r: c += 2 L += tmp_l R += tmp_r res = res * cmb(t,tmp_l,mod) else: res = 0 c += 1 res = res * cmb(M,c,mod) % mod if max(L,R) == small[0]: print(res) else: print(0) continue else: dic = {a:0 for a in A} for a in A: dic[a] += 1 big = [(a,dic[a]) for a in dic] big.sort() L,R = 0,0 c = 0 res = 1 for a,t in big[::-1]: tmp_l = N-a-L tmp_r = N-a-R if tmp_l == t and tmp_r == t: c += 1 res = 2 * res % mod L += t elif tmp_l == t or tmp_r == t: c += 1 L += t elif tmp_l+tmp_r == t and 0 < tmp_l and 0 < tmp_r: c += 2 L += tmp_l R += tmp_r res = res * cmb(t,tmp_l,mod) else: res = 0 res = res * cmb(M,c,mod) % mod if L == N//2 and R == N//2: print(res) else: print(0) continue