結果
問題 | No.2336 Do you like typical problems? |
ユーザー | titia |
提出日時 | 2023-10-04 05:12:59 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,111 bytes |
コンパイル時間 | 757 ms |
コンパイル使用メモリ | 86,836 KB |
実行使用メモリ | 170,996 KB |
最終ジャッジ日時 | 2023-10-04 05:13:19 |
合計ジャッジ時間 | 19,610 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 94 ms
89,848 KB |
testcase_01 | AC | 95 ms
89,804 KB |
testcase_02 | AC | 96 ms
89,820 KB |
testcase_03 | AC | 97 ms
89,920 KB |
testcase_04 | AC | 95 ms
90,004 KB |
testcase_05 | AC | 101 ms
89,980 KB |
testcase_06 | AC | 98 ms
90,012 KB |
testcase_07 | AC | 94 ms
90,236 KB |
testcase_08 | AC | 146 ms
92,496 KB |
testcase_09 | AC | 133 ms
92,344 KB |
testcase_10 | AC | 136 ms
92,600 KB |
testcase_11 | AC | 138 ms
92,460 KB |
testcase_12 | AC | 137 ms
92,500 KB |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | AC | 971 ms
157,776 KB |
testcase_19 | AC | 959 ms
155,660 KB |
testcase_20 | AC | 1,606 ms
170,892 KB |
ソースコード
import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from operator import itemgetter mod=998244353 # 高速ベキ乗 def fast_pow(x,y,mod): ANS=1 while y>0: if y%2==1: ANS=ANS*x%mod y-=1 if y>0: x=x*x%mod y//=2 return ANS N=int(input()) LIST=[list(map(int,input().split())) for i in range(N)] Q=[] for b,c in LIST: Q.append((b,c-b+1,1)) Q.append((c+1,c-b+1,2)) Q.sort(key=itemgetter(1)) Q.sort(key=itemgetter(0)) now1=0 ANS1=0 for i in range(len(Q)): x,length,com=Q[i] if com==1: now1+=fast_pow(length,mod-2,mod) ANS1-=fast_pow(length,mod-2,mod) ANS1%=mod else: now1-=fast_pow(length,mod-2,mod) now1%=mod if i+1<len(Q) and x!=Q[i+1][0]: z=Q[i+1][0] # [x,z)の間を考え、答えに加算。 ANS1+=now1*now1%mod*(z-x)%mod ANS1%=mod ANS2=(N*(N-1)//2-ANS1*fast_pow(2,mod-2,mod))%mod F=[1] for i in range(1,200020): F.append(F[-1]*i%mod) print(ANS2*F[N]*fast_pow(2,mod-2,mod)%mod)