結果

問題 No.5004 Room Assignment
ユーザー titiatitia
提出日時 2021-12-01 04:06:41
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 500 ms / 5,000 ms
コード長 1,440 bytes
コンパイル時間 313 ms
実行使用メモリ 99,112 KB
スコア 75,320,400
平均クエリ数 7650.00
最終ジャッジ日時 2021-12-01 04:07:39
合計ジャッジ時間 52,692 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
純コード判定しない問題か言語
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 463 ms
97,840 KB
testcase_01 AC 479 ms
97,412 KB
testcase_02 AC 448 ms
97,688 KB
testcase_03 AC 457 ms
98,000 KB
testcase_04 AC 488 ms
97,936 KB
testcase_05 AC 449 ms
98,036 KB
testcase_06 AC 435 ms
98,340 KB
testcase_07 AC 477 ms
98,400 KB
testcase_08 AC 465 ms
98,372 KB
testcase_09 AC 436 ms
97,660 KB
testcase_10 AC 446 ms
97,812 KB
testcase_11 AC 450 ms
97,272 KB
testcase_12 AC 458 ms
96,956 KB
testcase_13 AC 461 ms
98,236 KB
testcase_14 AC 454 ms
97,260 KB
testcase_15 AC 454 ms
96,796 KB
testcase_16 AC 463 ms
97,364 KB
testcase_17 AC 442 ms
97,564 KB
testcase_18 AC 448 ms
97,668 KB
testcase_19 AC 445 ms
97,092 KB
testcase_20 AC 476 ms
96,872 KB
testcase_21 AC 465 ms
98,644 KB
testcase_22 AC 455 ms
97,796 KB
testcase_23 AC 444 ms
97,096 KB
testcase_24 AC 469 ms
97,792 KB
testcase_25 AC 451 ms
97,588 KB
testcase_26 AC 438 ms
97,300 KB
testcase_27 AC 438 ms
97,872 KB
testcase_28 AC 464 ms
96,904 KB
testcase_29 AC 437 ms
96,760 KB
testcase_30 AC 463 ms
97,384 KB
testcase_31 AC 442 ms
96,944 KB
testcase_32 AC 480 ms
96,652 KB
testcase_33 AC 459 ms
97,544 KB
testcase_34 AC 438 ms
98,288 KB
testcase_35 AC 460 ms
97,728 KB
testcase_36 AC 469 ms
97,524 KB
testcase_37 AC 449 ms
98,764 KB
testcase_38 AC 445 ms
97,244 KB
testcase_39 AC 456 ms
97,596 KB
testcase_40 AC 471 ms
99,092 KB
testcase_41 AC 445 ms
97,912 KB
testcase_42 AC 449 ms
97,580 KB
testcase_43 AC 457 ms
97,580 KB
testcase_44 AC 476 ms
98,676 KB
testcase_45 AC 445 ms
97,504 KB
testcase_46 AC 468 ms
98,408 KB
testcase_47 AC 453 ms
97,468 KB
testcase_48 AC 477 ms
98,104 KB
testcase_49 AC 445 ms
97,076 KB
testcase_50 AC 459 ms
97,888 KB
testcase_51 AC 443 ms
97,320 KB
testcase_52 AC 487 ms
97,924 KB
testcase_53 AC 454 ms
97,204 KB
testcase_54 AC 473 ms
97,932 KB
testcase_55 AC 463 ms
97,156 KB
testcase_56 AC 500 ms
98,652 KB
testcase_57 AC 455 ms
99,112 KB
testcase_58 AC 452 ms
97,868 KB
testcase_59 AC 428 ms
97,220 KB
testcase_60 AC 476 ms
97,452 KB
testcase_61 AC 459 ms
97,868 KB
testcase_62 AC 449 ms
97,312 KB
testcase_63 AC 443 ms
97,408 KB
testcase_64 AC 491 ms
97,720 KB
testcase_65 AC 448 ms
97,460 KB
testcase_66 AC 467 ms
96,956 KB
testcase_67 AC 454 ms
97,756 KB
testcase_68 AC 469 ms
97,780 KB
testcase_69 AC 469 ms
97,528 KB
testcase_70 AC 446 ms
97,536 KB
testcase_71 AC 459 ms
98,352 KB
testcase_72 AC 497 ms
98,288 KB
testcase_73 AC 462 ms
97,880 KB
testcase_74 AC 461 ms
98,536 KB
testcase_75 AC 451 ms
96,948 KB
testcase_76 AC 481 ms
97,784 KB
testcase_77 AC 458 ms
97,284 KB
testcase_78 AC 444 ms
97,712 KB
testcase_79 AC 459 ms
97,112 KB
testcase_80 AC 454 ms
97,908 KB
testcase_81 AC 453 ms
97,924 KB
testcase_82 AC 466 ms
97,312 KB
testcase_83 AC 455 ms
97,680 KB
testcase_84 AC 470 ms
97,292 KB
testcase_85 AC 465 ms
97,824 KB
testcase_86 AC 450 ms
97,716 KB
testcase_87 AC 474 ms
97,504 KB
testcase_88 AC 457 ms
97,908 KB
testcase_89 AC 472 ms
97,804 KB
testcase_90 AC 458 ms
97,696 KB
testcase_91 AC 459 ms
96,840 KB
testcase_92 AC 445 ms
97,756 KB
testcase_93 AC 454 ms
97,308 KB
testcase_94 AC 461 ms
97,040 KB
testcase_95 AC 465 ms
97,520 KB
testcase_96 AC 442 ms
97,276 KB
testcase_97 AC 446 ms
97,792 KB
testcase_98 AC 465 ms
98,752 KB
testcase_99 AC 484 ms
97,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from operator import itemgetter

T,R=map(int,input().split())

A=[]
player=1

for turn in range(T):
    p=list(map(int,input().split()))

    for x in p[1:]:
        A.append((x,player,turn))
        player+=1

    A.sort(key=itemgetter(0))

    ANS=[]

    while len(A)>=4:

        for i in range(len(A)):
            if A[i][2]<turn-10:
                SA=1<<30
                MININD=-1

                for j in range(i-3,i+1):
                    if j>=0 and j+3<len(A):
                        x,y,z,w=A[j][0],A[j+1][0],A[j+2][0],A[j+3][0]
                        k=max(x,y,z,w)-min(x,y,z,w)

                        if k<SA:
                            SA=k
                            MININD=j
                            
                ANS.append((A[MININD][1],A[MININD+1][1]))
                ANS.append((A[MININD+1][1],A[MININD+2][1]))
                ANS.append((A[MININD+2][1],A[MININD+3][1]))

                A=A[:MININD]+A[MININD+4:]
                break

        else:
            break

    if turn==T-1:
        while len(A)>=4:
            ANS.append((A[0][1],A[1][1]))
            ANS.append((A[1][1],A[2][1]))
            ANS.append((A[2][1],A[3][1]))

            A=A[4:]

        if len(A)>=2:
            for i in range(len(A)-1):
                ANS.append(A[i][1],A[i+1][1])

    print(len(ANS),flush=True)
    for x,y in ANS:
        print(x,y,flush=True)
            
0