結果
問題 | No.5004 Room Assignment |
ユーザー | aqua_tenhou |
提出日時 | 2021-12-01 20:49:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 608 ms / 5,000 ms |
コード長 | 2,446 bytes |
コンパイル時間 | 241 ms |
実行使用メモリ | 105,112 KB |
スコア | 2,774,712 |
平均クエリ数 | 8999.00 |
最終ジャッジ日時 | 2021-12-01 20:50:06 |
合計ジャッジ時間 | 60,463 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 544 ms
102,304 KB |
testcase_01 | AC | 528 ms
101,732 KB |
testcase_02 | AC | 542 ms
102,032 KB |
testcase_03 | AC | 514 ms
101,588 KB |
testcase_04 | AC | 522 ms
102,200 KB |
testcase_05 | AC | 575 ms
101,176 KB |
testcase_06 | AC | 534 ms
100,624 KB |
testcase_07 | AC | 528 ms
99,804 KB |
testcase_08 | AC | 522 ms
101,512 KB |
testcase_09 | AC | 516 ms
99,916 KB |
testcase_10 | AC | 477 ms
99,348 KB |
testcase_11 | AC | 509 ms
101,788 KB |
testcase_12 | AC | 608 ms
105,112 KB |
testcase_13 | AC | 561 ms
100,932 KB |
testcase_14 | AC | 489 ms
99,700 KB |
testcase_15 | AC | 545 ms
101,044 KB |
testcase_16 | AC | 569 ms
101,632 KB |
testcase_17 | AC | 513 ms
102,224 KB |
testcase_18 | AC | 551 ms
102,184 KB |
testcase_19 | AC | 548 ms
99,664 KB |
testcase_20 | AC | 530 ms
101,708 KB |
testcase_21 | AC | 496 ms
99,532 KB |
testcase_22 | AC | 538 ms
102,300 KB |
testcase_23 | AC | 533 ms
102,412 KB |
testcase_24 | AC | 492 ms
99,568 KB |
testcase_25 | AC | 511 ms
101,248 KB |
testcase_26 | AC | 554 ms
101,524 KB |
testcase_27 | AC | 506 ms
100,240 KB |
testcase_28 | AC | 543 ms
100,476 KB |
testcase_29 | AC | 532 ms
101,272 KB |
testcase_30 | AC | 544 ms
100,456 KB |
testcase_31 | AC | 498 ms
101,544 KB |
testcase_32 | AC | 514 ms
101,088 KB |
testcase_33 | AC | 536 ms
99,420 KB |
testcase_34 | AC | 509 ms
101,636 KB |
testcase_35 | AC | 531 ms
101,548 KB |
testcase_36 | AC | 538 ms
99,360 KB |
testcase_37 | AC | 529 ms
102,312 KB |
testcase_38 | AC | 561 ms
99,752 KB |
testcase_39 | AC | 542 ms
100,820 KB |
testcase_40 | AC | 500 ms
100,184 KB |
testcase_41 | AC | 556 ms
101,852 KB |
testcase_42 | AC | 505 ms
101,132 KB |
testcase_43 | AC | 504 ms
101,460 KB |
testcase_44 | AC | 527 ms
102,016 KB |
testcase_45 | AC | 575 ms
102,692 KB |
testcase_46 | AC | 545 ms
102,488 KB |
testcase_47 | AC | 538 ms
101,036 KB |
testcase_48 | AC | 542 ms
101,296 KB |
testcase_49 | AC | 500 ms
99,964 KB |
testcase_50 | AC | 514 ms
100,176 KB |
testcase_51 | AC | 528 ms
100,444 KB |
testcase_52 | AC | 507 ms
100,164 KB |
testcase_53 | AC | 514 ms
100,192 KB |
testcase_54 | AC | 516 ms
100,572 KB |
testcase_55 | AC | 576 ms
102,672 KB |
testcase_56 | AC | 536 ms
101,276 KB |
testcase_57 | AC | 522 ms
101,964 KB |
testcase_58 | AC | 513 ms
101,808 KB |
testcase_59 | AC | 539 ms
101,212 KB |
testcase_60 | AC | 522 ms
101,284 KB |
testcase_61 | AC | 544 ms
100,252 KB |
testcase_62 | AC | 529 ms
100,448 KB |
testcase_63 | AC | 521 ms
101,664 KB |
testcase_64 | AC | 538 ms
101,784 KB |
testcase_65 | AC | 548 ms
101,372 KB |
testcase_66 | AC | 532 ms
102,716 KB |
testcase_67 | AC | 526 ms
101,644 KB |
testcase_68 | AC | 512 ms
100,104 KB |
testcase_69 | AC | 553 ms
102,504 KB |
testcase_70 | AC | 558 ms
101,372 KB |
testcase_71 | AC | 534 ms
100,712 KB |
testcase_72 | AC | 509 ms
102,888 KB |
testcase_73 | AC | 538 ms
101,320 KB |
testcase_74 | AC | 528 ms
101,108 KB |
testcase_75 | AC | 561 ms
100,924 KB |
testcase_76 | AC | 529 ms
101,232 KB |
testcase_77 | AC | 507 ms
101,016 KB |
testcase_78 | AC | 531 ms
102,084 KB |
testcase_79 | AC | 522 ms
101,452 KB |
testcase_80 | AC | 494 ms
100,604 KB |
testcase_81 | AC | 547 ms
101,888 KB |
testcase_82 | AC | 495 ms
100,564 KB |
testcase_83 | AC | 509 ms
99,656 KB |
testcase_84 | AC | 545 ms
100,824 KB |
testcase_85 | AC | 536 ms
103,964 KB |
testcase_86 | AC | 524 ms
99,540 KB |
testcase_87 | AC | 508 ms
101,356 KB |
testcase_88 | AC | 535 ms
101,492 KB |
testcase_89 | AC | 531 ms
100,996 KB |
testcase_90 | AC | 537 ms
101,124 KB |
testcase_91 | AC | 489 ms
99,512 KB |
testcase_92 | AC | 509 ms
100,704 KB |
testcase_93 | AC | 534 ms
101,472 KB |
testcase_94 | AC | 526 ms
102,528 KB |
testcase_95 | AC | 532 ms
101,628 KB |
testcase_96 | AC | 523 ms
100,556 KB |
testcase_97 | AC | 503 ms
102,256 KB |
testcase_98 | AC | 519 ms
100,028 KB |
testcase_99 | AC | 519 ms
99,996 KB |
ソースコード
import sys from collections import deque, defaultdict import heapq import copy ###################################################################### #UnionFind class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n self.group = n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x self.group -= 1 def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return self.group def all_group_members(self): return {r: self.members(r) for r in self.roots()} def __str__(self): return ' '.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) ###################################################################### DEBUG = 0 if __name__ != "__main__": DEBUG = 1 import DebugLib as dl def MyInput(): global DEBUG if DEBUG: return dl.DebugInput() else: return input() def MyPrint(*arg, **keys): global DEBUG if DEBUG: return dl.DebugPrint(*arg, **keys) else: return print(*arg, **keys) ###################################################################### def InputInfo(): ar = list(map(int,MyInput().split())) n = ar[0] s = ar[1:] return n,s def OutputAns(): MyPrint(len(outInfo)) for ar in outInfo: MyPrint(*ar) if not DEBUG: sys.stdout.flush() N = 5400 T, R = map(int,MyInput().split()) uf = UnionFind(N+1) q = [] idx = 1 nowidx = 1 for t in range(T): n, s = InputInfo() outInfo = [] for x in s: if idx == 1: idx += 1 continue while R <= uf.size(nowidx): nowidx += 1 uf.union(idx, nowidx) outInfo.append([idx, nowidx]) idx += 1 OutputAns()