結果

問題 No.2652 [Cherry 6th Tune N] Δρονε χιρχλινγ
ユーザー titia
提出日時 2024-02-28 03:09:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 365 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 83,072 KB
実行使用メモリ 124,548 KB
最終ジャッジ日時 2024-09-29 12:17:35
合計ジャッジ時間 32,381 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from operator import itemgetter

T=int(input())
for tests in range(T):
    N,L=map(int,input().split())
    P=[list(map(int,input().split())) for i in range(N)]

    c=L/(N**(1/2))

    LIST=[[] for i in range(int(L/c+3))]

    for x,y in P:
        LIST[int(x/c)].append((x,y))

    ANS=[]

    for i in range(len(LIST)):
        LIST[i].sort(key=itemgetter(1))

        if i%2==1:
            LIST[i].reverse()

        for x,y in LIST[i]:
            ANS.append((x,y))

    print(len(ANS)+1)

    for x,y in ANS:
        print(x,y)

    print(*ANS[0])
0