結果

問題 No.2652 [Cherry 6th Tune N] Δρονε χιρχλινγ
ユーザー mkawa2mkawa2
提出日時 2024-02-23 22:42:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 446 ms / 2,000 ms
コード長 1,174 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 116,324 KB
最終ジャッジ日時 2024-02-23 22:43:21
合計ジャッジ時間 38,952 ms
ジャッジサーバーID
(参考情報)
judge15 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
55,860 KB
testcase_01 AC 371 ms
79,628 KB
testcase_02 AC 344 ms
79,504 KB
testcase_03 AC 363 ms
79,756 KB
testcase_04 AC 393 ms
98,324 KB
testcase_05 AC 399 ms
100,676 KB
testcase_06 AC 427 ms
101,740 KB
testcase_07 AC 440 ms
106,408 KB
testcase_08 AC 435 ms
106,292 KB
testcase_09 AC 429 ms
106,340 KB
testcase_10 AC 406 ms
106,348 KB
testcase_11 AC 431 ms
106,868 KB
testcase_12 AC 443 ms
105,824 KB
testcase_13 AC 443 ms
107,984 KB
testcase_14 AC 422 ms
115,900 KB
testcase_15 AC 419 ms
113,852 KB
testcase_16 AC 430 ms
105,668 KB
testcase_17 AC 411 ms
110,644 KB
testcase_18 AC 419 ms
109,964 KB
testcase_19 AC 429 ms
107,092 KB
testcase_20 AC 423 ms
111,844 KB
testcase_21 AC 405 ms
113,252 KB
testcase_22 AC 434 ms
113,252 KB
testcase_23 AC 409 ms
112,996 KB
testcase_24 AC 419 ms
111,972 KB
testcase_25 AC 419 ms
113,124 KB
testcase_26 AC 418 ms
113,252 KB
testcase_27 AC 411 ms
111,204 KB
testcase_28 AC 425 ms
111,844 KB
testcase_29 AC 444 ms
111,204 KB
testcase_30 AC 433 ms
112,740 KB
testcase_31 AC 422 ms
111,844 KB
testcase_32 AC 436 ms
112,996 KB
testcase_33 AC 415 ms
113,252 KB
testcase_34 AC 407 ms
113,124 KB
testcase_35 AC 445 ms
112,100 KB
testcase_36 AC 411 ms
113,252 KB
testcase_37 AC 418 ms
111,716 KB
testcase_38 AC 446 ms
111,716 KB
testcase_39 AC 415 ms
113,252 KB
testcase_40 AC 307 ms
116,324 KB
testcase_41 AC 368 ms
116,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 62)

# md = 10**9+7
md = 998244353

from collections import defaultdict

def solve():
    n,L=LI()
    xy=LLI(n)
    h = L//round(n**0.5)
    i2xy=defaultdict(list)
    for x,y in xy:
        i=x//h
        i2xy[i].append((x,y))
    ans=[]
    rev=0
    for i in sorted(i2xy):
        i2xy[i].sort(key=lambda x:x[1],reverse=rev)
        rev^=1
        ans+=i2xy[i]

    print(len(ans))
    for x,y in ans:print(x,y)

for _ in range(II()):solve()
0