結果

問題 No.5010 Better Mo's Algorithm is Needed!! (Unweighted)
ユーザー titia
提出日時 2022-12-17 02:44:25
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,021 ms / 5,000 ms
コード長 610 bytes
コンパイル時間 466 ms
実行使用メモリ 66,140 KB
スコア 15,647,672,150
最終ジャッジ日時 2022-12-17 02:47:11
合計ジャッジ時間 161,584 ms
ジャッジサーバーID
(参考情報)
judge15 / judge16
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 120
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from operator import itemgetter

N,Q,WT,ST=map(int,input().split())
W=list(map(int,input().split()))
LR=[list(map(int,input().split()))+[i+1] for i in range(Q)]

LR.sort(key=itemgetter(0))

LIST=[[] for i in range(1000)]

for x,y,ind in LR:
    LIST[x//400].append((y,ind))

ANS=[]

count=0
for i in range(1000):
    if LIST[i]==[]:
        continue
    if count%2==0:
        LIST[i].sort(key=itemgetter(0))
    else:
        LIST[i].sort(key=itemgetter(0),reverse=True)
        
    for _,ind in LIST[i]:
        ANS.append(ind)

    count+=1

print(*ANS)
        
    
0