結果

問題 No.2652 [Cherry 6th Tune N] Δρονε χιρχλινγ
ユーザー detteiuu
提出日時 2024-11-29 01:52:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 826 ms / 2,000 ms
コード長 559 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 82,380 KB
実行使用メモリ 131,888 KB
最終ジャッジ日時 2024-11-29 01:53:33
合計ジャッジ時間 48,280 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

for _ in range(T):
    N, L = map(int, input().split())
    XY = [list(map(int, input().split())) for _ in range(N)]
    XY.sort(key=lambda x:x[1])
    RANGE = int(N**0.5)+1
    qS = [[] for _ in range(N//RANGE+1)]
    for i in range(N):
        X, Y = XY[i]
        qS[i//RANGE].append((X, Y))
    for i in range(N//RANGE+1):
        qS[i].sort(key=lambda x:x[0], reverse=i%2)
    ans = []
    for i in range(N//RANGE+1):
        for x, y in qS[i]:
            ans.append((x, y))
    print(len(ans))
    for x, y in ans:
        print(x, y)
0