結果
問題 | No.5004 Room Assignment |
ユーザー | negibose2020 |
提出日時 | 2021-12-01 21:24:46 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 3,052 bytes |
コンパイル時間 | 235 ms |
実行使用メモリ | 107,956 KB |
スコア | 26,413,459 |
平均クエリ数 | 4737.54 |
最終ジャッジ日時 | 2021-12-01 21:26:03 |
合計ジャッジ時間 | 75,287 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | AC | 800 ms
101,052 KB |
testcase_03 | AC | 831 ms
104,340 KB |
testcase_04 | RE | - |
testcase_05 | AC | 876 ms
102,792 KB |
testcase_06 | AC | 795 ms
102,964 KB |
testcase_07 | AC | 834 ms
103,104 KB |
testcase_08 | RE | - |
testcase_09 | AC | 826 ms
102,524 KB |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | AC | 780 ms
103,280 KB |
testcase_14 | AC | 839 ms
102,624 KB |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | AC | 861 ms
102,400 KB |
testcase_18 | RE | - |
testcase_19 | AC | 854 ms
104,868 KB |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | AC | 826 ms
101,288 KB |
testcase_26 | AC | 811 ms
102,220 KB |
testcase_27 | AC | 761 ms
101,188 KB |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | AC | 825 ms
103,488 KB |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | AC | 827 ms
104,168 KB |
testcase_38 | AC | 799 ms
101,772 KB |
testcase_39 | AC | 821 ms
102,712 KB |
testcase_40 | AC | 788 ms
101,244 KB |
testcase_41 | AC | 816 ms
101,720 KB |
testcase_42 | RE | - |
testcase_43 | AC | 806 ms
102,640 KB |
testcase_44 | RE | - |
testcase_45 | AC | 822 ms
101,632 KB |
testcase_46 | AC | 806 ms
102,212 KB |
testcase_47 | AC | 764 ms
100,916 KB |
testcase_48 | AC | 858 ms
101,612 KB |
testcase_49 | AC | 873 ms
102,988 KB |
testcase_50 | AC | 827 ms
101,884 KB |
testcase_51 | RE | - |
testcase_52 | RE | - |
testcase_53 | AC | 784 ms
101,444 KB |
testcase_54 | AC | 818 ms
101,928 KB |
testcase_55 | AC | 825 ms
103,004 KB |
testcase_56 | RE | - |
testcase_57 | RE | - |
testcase_58 | AC | 861 ms
104,192 KB |
testcase_59 | RE | - |
testcase_60 | AC | 808 ms
100,256 KB |
testcase_61 | AC | 779 ms
101,892 KB |
testcase_62 | AC | 738 ms
101,692 KB |
testcase_63 | RE | - |
testcase_64 | RE | - |
testcase_65 | AC | 795 ms
102,336 KB |
testcase_66 | RE | - |
testcase_67 | AC | 859 ms
104,104 KB |
testcase_68 | AC | 797 ms
102,168 KB |
testcase_69 | RE | - |
testcase_70 | RE | - |
testcase_71 | RE | - |
testcase_72 | RE | - |
testcase_73 | RE | - |
testcase_74 | RE | - |
testcase_75 | RE | - |
testcase_76 | RE | - |
testcase_77 | AC | 772 ms
102,248 KB |
testcase_78 | RE | - |
testcase_79 | RE | - |
testcase_80 | AC | 790 ms
101,792 KB |
testcase_81 | AC | 875 ms
102,312 KB |
testcase_82 | RE | - |
testcase_83 | RE | - |
testcase_84 | RE | - |
testcase_85 | AC | 752 ms
101,516 KB |
testcase_86 | RE | - |
testcase_87 | RE | - |
testcase_88 | RE | - |
testcase_89 | RE | - |
testcase_90 | AC | 823 ms
104,432 KB |
testcase_91 | AC | 757 ms
103,144 KB |
testcase_92 | AC | 774 ms
100,484 KB |
testcase_93 | AC | 779 ms
102,860 KB |
testcase_94 | RE | - |
testcase_95 | RE | - |
testcase_96 | AC | 742 ms
100,444 KB |
testcase_97 | AC | 807 ms
101,580 KB |
testcase_98 | AC | 814 ms
100,600 KB |
testcase_99 | AC | 791 ms
101,328 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,3600)) s.add((100000000,-1,3600)) pi=1 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 t_ans=set() for i in range(L[0]): # print(s) nowi=(L[i+1],pi,t) for e in s: if t - e[2] >400: s.discard(e) 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()