結果
問題 | No.5004 Room Assignment |
ユーザー | negibose2020 |
提出日時 | 2021-12-01 20:51:39 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,940 bytes |
コンパイル時間 | 334 ms |
実行使用メモリ | 23,628 KB |
スコア | 27,457,122 |
平均クエリ数 | 5054.98 |
最終ジャッジ日時 | 2021-12-01 20:58:24 |
合計ジャッジ時間 | 404,249 ms |
ジャッジサーバーID (参考情報) |
judge16 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3,945 ms
23,336 KB |
testcase_01 | AC | 3,943 ms
23,232 KB |
testcase_02 | AC | 3,948 ms
23,304 KB |
testcase_03 | AC | 3,952 ms
23,308 KB |
testcase_04 | AC | 3,950 ms
23,316 KB |
testcase_05 | AC | 3,950 ms
23,300 KB |
testcase_06 | AC | 3,948 ms
23,372 KB |
testcase_07 | AC | 3,943 ms
23,268 KB |
testcase_08 | AC | 3,943 ms
23,284 KB |
testcase_09 | AC | 3,948 ms
23,328 KB |
testcase_10 | AC | 3,943 ms
23,244 KB |
testcase_11 | AC | 3,946 ms
23,312 KB |
testcase_12 | AC | 3,948 ms
23,248 KB |
testcase_13 | AC | 3,948 ms
23,216 KB |
testcase_14 | AC | 3,953 ms
23,300 KB |
testcase_15 | WA | - |
testcase_16 | AC | 3,949 ms
23,324 KB |
testcase_17 | AC | 3,950 ms
23,208 KB |
testcase_18 | AC | 3,945 ms
23,224 KB |
testcase_19 | AC | 3,948 ms
23,168 KB |
testcase_20 | AC | 3,946 ms
23,308 KB |
testcase_21 | AC | 3,947 ms
23,380 KB |
testcase_22 | AC | 3,946 ms
23,276 KB |
testcase_23 | AC | 3,945 ms
23,128 KB |
testcase_24 | AC | 3,951 ms
23,324 KB |
testcase_25 | AC | 3,948 ms
23,484 KB |
testcase_26 | AC | 3,946 ms
23,100 KB |
testcase_27 | AC | 3,950 ms
23,252 KB |
testcase_28 | AC | 3,944 ms
23,256 KB |
testcase_29 | AC | 3,944 ms
23,264 KB |
testcase_30 | AC | 3,950 ms
23,264 KB |
testcase_31 | WA | - |
testcase_32 | AC | 3,943 ms
23,264 KB |
testcase_33 | AC | 3,950 ms
23,140 KB |
testcase_34 | AC | 3,944 ms
23,296 KB |
testcase_35 | AC | 3,948 ms
23,352 KB |
testcase_36 | AC | 3,951 ms
23,308 KB |
testcase_37 | AC | 3,946 ms
23,564 KB |
testcase_38 | AC | 3,945 ms
23,420 KB |
testcase_39 | AC | 3,952 ms
23,484 KB |
testcase_40 | AC | 3,958 ms
23,232 KB |
testcase_41 | AC | 3,952 ms
23,628 KB |
testcase_42 | AC | 3,944 ms
23,548 KB |
testcase_43 | AC | 3,947 ms
23,252 KB |
testcase_44 | AC | 3,946 ms
23,392 KB |
testcase_45 | AC | 3,949 ms
23,460 KB |
testcase_46 | AC | 3,946 ms
23,372 KB |
testcase_47 | AC | 3,946 ms
23,292 KB |
testcase_48 | AC | 3,947 ms
23,236 KB |
testcase_49 | AC | 3,946 ms
23,508 KB |
testcase_50 | AC | 3,947 ms
23,232 KB |
testcase_51 | AC | 3,944 ms
23,128 KB |
testcase_52 | AC | 3,948 ms
23,312 KB |
testcase_53 | AC | 3,950 ms
23,304 KB |
testcase_54 | AC | 3,946 ms
23,304 KB |
testcase_55 | AC | 3,949 ms
23,276 KB |
testcase_56 | AC | 3,948 ms
23,528 KB |
testcase_57 | AC | 3,946 ms
23,356 KB |
testcase_58 | AC | 3,947 ms
23,188 KB |
testcase_59 | AC | 3,944 ms
23,140 KB |
testcase_60 | AC | 3,948 ms
23,460 KB |
testcase_61 | AC | 3,947 ms
23,396 KB |
testcase_62 | AC | 3,946 ms
23,280 KB |
testcase_63 | AC | 3,947 ms
23,292 KB |
testcase_64 | AC | 3,947 ms
23,224 KB |
testcase_65 | AC | 3,946 ms
23,464 KB |
testcase_66 | AC | 3,946 ms
23,324 KB |
testcase_67 | AC | 3,946 ms
23,280 KB |
testcase_68 | AC | 3,950 ms
23,384 KB |
testcase_69 | AC | 3,952 ms
23,280 KB |
testcase_70 | AC | 3,950 ms
23,452 KB |
testcase_71 | AC | 3,946 ms
23,364 KB |
testcase_72 | AC | 3,945 ms
23,236 KB |
testcase_73 | AC | 3,947 ms
23,320 KB |
testcase_74 | AC | 3,952 ms
23,336 KB |
testcase_75 | AC | 3,944 ms
23,352 KB |
testcase_76 | AC | 3,944 ms
23,260 KB |
testcase_77 | AC | 3,947 ms
23,336 KB |
testcase_78 | AC | 3,944 ms
23,276 KB |
testcase_79 | AC | 3,949 ms
23,300 KB |
testcase_80 | AC | 3,945 ms
23,212 KB |
testcase_81 | AC | 3,954 ms
23,312 KB |
testcase_82 | AC | 3,948 ms
23,524 KB |
testcase_83 | AC | 3,946 ms
23,428 KB |
testcase_84 | AC | 3,949 ms
23,240 KB |
testcase_85 | AC | 3,945 ms
23,256 KB |
testcase_86 | AC | 3,945 ms
23,276 KB |
testcase_87 | AC | 3,949 ms
23,232 KB |
testcase_88 | AC | 3,948 ms
23,344 KB |
testcase_89 | AC | 3,946 ms
23,332 KB |
testcase_90 | WA | - |
testcase_91 | AC | 3,943 ms
23,336 KB |
testcase_92 | AC | 3,947 ms
23,364 KB |
testcase_93 | AC | 3,945 ms
23,284 KB |
testcase_94 | AC | 3,949 ms
23,292 KB |
testcase_95 | AC | 3,948 ms
23,336 KB |
testcase_96 | AC | 3,949 ms
23,220 KB |
testcase_97 | AC | 3,942 ms
23,252 KB |
testcase_98 | AC | 3,944 ms
23,272 KB |
testcase_99 | AC | 3,949 ms
23,316 KB |
ソースコード
from collections import defaultdict import sys import time class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * 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 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 len(self.roots()) def all_group_members(self): group_members = defaultdict(list) for member in range(self.n): group_members[self.find(member)].append(member) return group_members def __str__(self): return '\n'.join(f'{r}: {m}' for r, m in self.all_group_members().items()) stime=time.perf_counter() T,R=map(int,input().split()) t=0 N=5400 uf=UnionFind(N+1) p=[-1]*(N+1) s=set() # スキル値, プレイヤーi, 出現チック s.add((-10000000,-1,-1)) s.add((100000000,-1,-1)) pi=1 import bisect while t<3600 : nowtime=time.perf_counter() if nowtime - stime >3.9: print(0) t+=1 continue L=list(map(int,input().split())) t_ans=set() for i in range(L[0]): # print(s) nowi=(L[i+1],pi,t) sorteds=sorted(list(s)) target=bisect.bisect_right(sorteds,nowi) used=False if abs(sorteds[target-1][0] - L[i+1])<5: sz=len(uf.members(sorteds[target-1][1])) if sz<3: uf.union(pi,sorteds[target-1][1]) t_ans.add(pi) used = True s.discard(sorteds[target-1]) if abs(sorteds[target][0] - L[i+1])<5: sz=len(uf.members(sorteds[target][1])) if sz<3: uf.union(pi,sorteds[target][1]) t_ans.add(pi) used = True s.discard(sorteds[target]) if used == False: s.add(nowi) pi+=1 t+=1 # print (t_ans) ans4print=[] ans4print_num=0 for ans in t_ans: m=uf.members(ans) mls=[] for i in range(1,len(m)) : mls.append([m[0],m[i]]) ans4print_num+=1 ans4print.append(mls) print(ans4print_num) sys.stdout.flush() for i in range (len(ans4print)): for e in ans4print[i]: print(*e) sys.stdout.flush()