結果

問題 No.2336 Do you like typical problems?
ユーザー ニックネームニックネーム
提出日時 2023-06-02 23:24:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 712 bytes
コンパイル時間 496 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 127,056 KB
最終ジャッジ日時 2023-08-28 05:56:40
合計ジャッジ時間 5,107 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,424 KB
testcase_01 AC 16 ms
8,040 KB
testcase_02 AC 16 ms
7,916 KB
testcase_03 AC 16 ms
7,868 KB
testcase_04 AC 15 ms
7,976 KB
testcase_05 AC 15 ms
8,020 KB
testcase_06 AC 16 ms
7,876 KB
testcase_07 AC 16 ms
8,032 KB
testcase_08 AC 42 ms
9,064 KB
testcase_09 AC 41 ms
9,092 KB
testcase_10 AC 42 ms
9,056 KB
testcase_11 AC 42 ms
9,164 KB
testcase_12 AC 42 ms
9,152 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input()); mod = 998244353
bc = [tuple(map(int,input().split())) for _ in range(n)]
itov = set()
for b,c in bc: itov.add(b); itov.add(c+1)
itov = sorted(itov); m = len(itov)
vtoi = {v:i+1 for i,v in enumerate(itov)}
imos1 = [0]*(m+1); imos2=  [0]*(m+1)
for b,c in bc:
    rev1 = pow(c-b+1,mod-2,mod); rev2 = rev1**2%mod
    imos1[vtoi[b]] += rev1; imos2[vtoi[b]] += rev2
    imos1[vtoi[c+1]] -= rev1; imos2[vtoi[c+1]] -= rev2
for i in range(m):
    imos1[i+1] = sum(imos1[i:i+2])%mod
    imos2[i+1] = sum(imos2[i:i+2])%mod
two = pow(2,mod-2,mod); ans = n*(n-1)//2
for i in range(1,m): ans = (ans-(imos1[i]**2-imos2[i])%mod*two%mod*(itov[i]-itov[i-1]))%mod
for i in range(3,n+1): ans = ans*i%mod
print(ans)
0