結果

問題 No.2336 Do you like typical problems?
ユーザー hir355hir355
提出日時 2023-06-02 22:08:49
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,217 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 269,120 KB
最終ジャッジ日時 2023-08-28 03:42:34
合計ジャッジ時間 19,290 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,372 KB
testcase_01 AC 74 ms
71,240 KB
testcase_02 AC 73 ms
71,336 KB
testcase_03 AC 72 ms
71,640 KB
testcase_04 AC 73 ms
71,304 KB
testcase_05 AC 72 ms
71,408 KB
testcase_06 AC 73 ms
71,660 KB
testcase_07 AC 73 ms
71,388 KB
testcase_08 AC 146 ms
78,796 KB
testcase_09 AC 145 ms
78,680 KB
testcase_10 AC 145 ms
79,192 KB
testcase_11 AC 143 ms
78,576 KB
testcase_12 AC 144 ms
78,896 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 AC 935 ms
94,600 KB
testcase_19 AC 960 ms
94,424 KB
testcase_20 AC 1,818 ms
268,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import factorial
compress = lambda arr: {e: i for i, e in enumerate(sorted(set(arr)))}
compress2 = lambda arr: {i: e for i, e in enumerate(sorted(set(arr)))}
MOD = 998244353
n = int(input())
b = [0] * n
c = [0] * n
l = []
for i in range(n):
    b[i], c[i] = map(int, input().split())
    b[i] -= 1
    l.append(b[i])
    l.append(c[i])
cp = compress(l)
cp2 = compress2(l)
# ans = 0
# for j in range(n):
#     for k in range(j + 1, n):
#         ans += (1 - max(0, min(c[j] - b[j], c[k] - b[k], c[j] - b[k], c[k] - b[j]) + 1) * pow((c[j] - b[j] + 1) * (c[k] - b[k] + 1), MOD - 2, MOD)) * f % MOD

ans = 0
m = len(cp)
w = [0] * m
x = [0] * m
y = [0] * m
for j in range(n):
    w[cp[b[j]]] += 1
    w[cp[c[j]]] -= 1
    x[cp[b[j]]] += pow(c[j] - b[j], MOD - 2, MOD)
    x[cp[c[j]]] -= pow(c[j] - b[j], MOD - 2, MOD)
    y[cp[b[j]]] += pow((c[j] - b[j]) ** 2, MOD - 2, MOD)
    y[cp[c[j]]] -= pow((c[j] - b[j]) ** 2, MOD - 2, MOD)
s0 = 0
s = 0
s2 = 0
f = 1
for i in range(n - 2):
    f *= (i + 1)
    f %= MOD
for j in range(m - 1):
    s0 += w[j]
    s += x[j]
    s2 += y[j]
    ans += (s ** 2 - s2) * pow(2, MOD - 2, MOD) * (cp2[j + 1] - cp2[j])
print(((n * (n - 1) // 2 - ans) * n * (n - 1) // 2) * f % MOD)
0