結果
問題 | No.5004 Room Assignment |
ユーザー | negibose2020 |
提出日時 | 2021-12-02 00:18:30 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,354 ms / 5,000 ms |
コード長 | 4,147 bytes |
コンパイル時間 | 382 ms |
実行使用メモリ | 105,964 KB |
スコア | 122,181,685 |
平均クエリ数 | 14790.99 |
最終ジャッジ日時 | 2021-12-02 00:21:43 |
合計ジャッジ時間 | 182,951 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,664 ms
102,912 KB |
testcase_01 | AC | 1,663 ms
105,904 KB |
testcase_02 | AC | 1,733 ms
103,920 KB |
testcase_03 | AC | 1,694 ms
104,112 KB |
testcase_04 | AC | 1,792 ms
102,592 KB |
testcase_05 | AC | 2,354 ms
101,624 KB |
testcase_06 | AC | 1,715 ms
102,612 KB |
testcase_07 | AC | 1,668 ms
105,540 KB |
testcase_08 | AC | 1,657 ms
104,736 KB |
testcase_09 | AC | 1,750 ms
104,460 KB |
testcase_10 | AC | 1,600 ms
102,648 KB |
testcase_11 | AC | 1,727 ms
101,876 KB |
testcase_12 | AC | 1,694 ms
104,836 KB |
testcase_13 | AC | 1,698 ms
103,060 KB |
testcase_14 | AC | 1,710 ms
101,812 KB |
testcase_15 | AC | 1,735 ms
103,824 KB |
testcase_16 | AC | 1,777 ms
103,508 KB |
testcase_17 | AC | 2,214 ms
103,132 KB |
testcase_18 | AC | 1,653 ms
105,228 KB |
testcase_19 | AC | 1,862 ms
103,712 KB |
testcase_20 | AC | 1,795 ms
101,596 KB |
testcase_21 | AC | 1,720 ms
102,648 KB |
testcase_22 | AC | 1,745 ms
101,716 KB |
testcase_23 | AC | 2,200 ms
103,664 KB |
testcase_24 | AC | 1,756 ms
105,092 KB |
testcase_25 | AC | 1,637 ms
101,352 KB |
testcase_26 | AC | 1,618 ms
103,896 KB |
testcase_27 | AC | 1,697 ms
103,112 KB |
testcase_28 | AC | 1,693 ms
104,036 KB |
testcase_29 | AC | 1,696 ms
103,316 KB |
testcase_30 | AC | 1,787 ms
103,252 KB |
testcase_31 | AC | 1,881 ms
101,580 KB |
testcase_32 | AC | 1,654 ms
104,164 KB |
testcase_33 | AC | 1,594 ms
102,652 KB |
testcase_34 | AC | 1,675 ms
103,608 KB |
testcase_35 | AC | 1,768 ms
102,704 KB |
testcase_36 | AC | 1,726 ms
105,224 KB |
testcase_37 | AC | 1,691 ms
103,164 KB |
testcase_38 | AC | 1,616 ms
102,068 KB |
testcase_39 | AC | 1,729 ms
102,464 KB |
testcase_40 | AC | 1,645 ms
101,688 KB |
testcase_41 | AC | 1,759 ms
102,472 KB |
testcase_42 | AC | 1,648 ms
101,976 KB |
testcase_43 | AC | 2,149 ms
100,268 KB |
testcase_44 | AC | 1,650 ms
103,228 KB |
testcase_45 | AC | 1,736 ms
103,504 KB |
testcase_46 | AC | 2,245 ms
102,588 KB |
testcase_47 | AC | 2,222 ms
103,136 KB |
testcase_48 | AC | 1,641 ms
103,860 KB |
testcase_49 | AC | 1,752 ms
102,328 KB |
testcase_50 | AC | 1,614 ms
102,944 KB |
testcase_51 | AC | 1,641 ms
104,280 KB |
testcase_52 | AC | 1,764 ms
103,812 KB |
testcase_53 | AC | 1,719 ms
102,444 KB |
testcase_54 | AC | 1,686 ms
102,768 KB |
testcase_55 | AC | 2,258 ms
102,784 KB |
testcase_56 | AC | 1,830 ms
103,816 KB |
testcase_57 | AC | 1,675 ms
102,984 KB |
testcase_58 | AC | 1,743 ms
104,156 KB |
testcase_59 | AC | 1,561 ms
102,744 KB |
testcase_60 | AC | 1,715 ms
103,584 KB |
testcase_61 | AC | 1,716 ms
102,672 KB |
testcase_62 | AC | 1,601 ms
102,428 KB |
testcase_63 | AC | 1,669 ms
101,524 KB |
testcase_64 | AC | 1,827 ms
101,636 KB |
testcase_65 | AC | 1,733 ms
102,880 KB |
testcase_66 | AC | 2,311 ms
105,456 KB |
testcase_67 | AC | 1,731 ms
102,844 KB |
testcase_68 | AC | 1,606 ms
103,132 KB |
testcase_69 | AC | 1,642 ms
103,248 KB |
testcase_70 | AC | 1,780 ms
102,656 KB |
testcase_71 | AC | 1,772 ms
103,676 KB |
testcase_72 | AC | 2,247 ms
102,652 KB |
testcase_73 | AC | 1,735 ms
101,184 KB |
testcase_74 | AC | 1,708 ms
104,796 KB |
testcase_75 | AC | 1,621 ms
103,476 KB |
testcase_76 | AC | 1,684 ms
102,916 KB |
testcase_77 | AC | 1,700 ms
102,560 KB |
testcase_78 | AC | 1,610 ms
102,088 KB |
testcase_79 | AC | 1,772 ms
102,924 KB |
testcase_80 | AC | 1,604 ms
102,652 KB |
testcase_81 | AC | 1,704 ms
102,916 KB |
testcase_82 | AC | 1,715 ms
102,256 KB |
testcase_83 | AC | 1,762 ms
104,464 KB |
testcase_84 | AC | 1,686 ms
102,764 KB |
testcase_85 | AC | 1,766 ms
103,540 KB |
testcase_86 | AC | 1,702 ms
103,280 KB |
testcase_87 | AC | 1,650 ms
102,384 KB |
testcase_88 | AC | 1,648 ms
104,860 KB |
testcase_89 | AC | 1,724 ms
103,812 KB |
testcase_90 | AC | 1,741 ms
101,492 KB |
testcase_91 | AC | 1,666 ms
103,452 KB |
testcase_92 | AC | 1,664 ms
104,044 KB |
testcase_93 | AC | 1,683 ms
103,380 KB |
testcase_94 | AC | 1,628 ms
103,768 KB |
testcase_95 | AC | 1,694 ms
103,484 KB |
testcase_96 | AC | 1,732 ms
105,964 KB |
testcase_97 | AC | 2,212 ms
103,036 KB |
testcase_98 | AC | 1,565 ms
103,352 KB |
testcase_99 | AC | 1,634 ms
102,544 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) tick=[-1]*(N+1) s=set() # スキル値, プレイヤーi, 出現チック s.add((-10000000,-1,-1)) s.add((100000000,-1,-1)) pi=1 t_ans=set() import bisect while t<3600 : nowtime=time.perf_counter() L=list(map(int,input().split())) # if nowtime - stime >4.85: # t+=1 # print(0) # sys.stdout.flush() # continue for e in list(s): if e == (-10000000,-1,-1) or e ==(100000000,-1,-1): continue else: if t - e[2] >250: s.discard(e) for i in range(L[0]): # print(s) nowi = (L[i+1],pi,t) p[pi] = L[i+1] tick[pi] = t sorteds=sorted(list(s)) target=bisect.bisect_right(sorteds,nowi) used=False for _t in list(t_ans): if abs(p[pi] - p[_t]) < 5: sz=len(uf.members(_t)) if sz < 4: uf.union(_t, pi) t_ans.add(pi) used = True break if abs(sorteds[target-1][0] - L[i+1])<5: sz1 = len(uf.members(sorteds[target-1][1])) sz2 = len(uf.members(pi)) if sz1 + sz2 <= 4: 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: sz1 = len(uf.members(sorteds[target][1])) sz2 = len(uf.members(pi)) if sz1 + sz2 <= 4: 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 list(t_ans): m=uf.members(ans) if len(m)>=4: mls=[] for i in range(1,4):#len(m)) : mls.append([m[0],m[i]]) t_ans.discard(m[0]) t_ans.discard(m[i]) ans4print_num+=1 ans4print.append(mls) else: min_tick=10000000000 for i in range (len(m)): min_tick = min(min_tick, tick[m[i]]) if min_tick < t - 100 : mls = [] for i in range (1,len(m)): mls.append([m[0],m[i]]) t_ans.discard(m[0]) t_ans.discard(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()