結果

問題 No.2197 Same Dish
ユーザー HydruHydru
提出日時 2023-01-20 21:55:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 415 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 87,376 KB
実行使用メモリ 86,408 KB
最終ジャッジ日時 2023-09-05 14:12:46
合計ジャッジ時間 4,579 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,132 KB
testcase_01 AC 78 ms
71,140 KB
testcase_02 AC 77 ms
71,032 KB
testcase_03 AC 78 ms
71,416 KB
testcase_04 AC 77 ms
71,472 KB
testcase_05 AC 76 ms
71,040 KB
testcase_06 AC 78 ms
71,360 KB
testcase_07 AC 79 ms
71,248 KB
testcase_08 AC 78 ms
71,036 KB
testcase_09 AC 80 ms
71,296 KB
testcase_10 AC 77 ms
71,260 KB
testcase_11 AC 79 ms
71,452 KB
testcase_12 AC 78 ms
71,176 KB
testcase_13 AC 120 ms
77,476 KB
testcase_14 AC 181 ms
83,564 KB
testcase_15 AC 191 ms
85,272 KB
testcase_16 AC 163 ms
83,272 KB
testcase_17 AC 156 ms
82,208 KB
testcase_18 AC 193 ms
85,756 KB
testcase_19 AC 189 ms
85,280 KB
testcase_20 AC 190 ms
85,044 KB
testcase_21 AC 186 ms
84,292 KB
testcase_22 AC 191 ms
86,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=998244353

n,k=map(int,input().split())

L=[]
R=[]

for i in range(n):
    l,r=map(int,input().split())
    L.append(l)
    R.append(r)

L.sort(reverse=True)
R.sort(reverse=True)

r_ans=1
n_c=0

while(L):
    l=L.pop()
    r=R.pop()

    if l<r:
        r_ans*=k-n_c
        r_ans%=mod
        n_c+=1
        R.append(r)

    else:
        n_c-=1
        L.append(l)

ans=pow(k,n,mod)-r_ans
ans%=mod

print(ans)
0