結果
問題 | No.5004 Room Assignment |
ユーザー | negibose2020 |
提出日時 | 2021-12-01 22:37:46 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,130 ms / 5,000 ms |
コード長 | 3,539 bytes |
コンパイル時間 | 1,062 ms |
実行使用メモリ | 110,840 KB |
スコア | 49,271,488 |
平均クエリ数 | 7715.43 |
最終ジャッジ日時 | 2021-12-01 22:39:33 |
合計ジャッジ時間 | 107,335 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 971 ms
101,560 KB |
testcase_01 | AC | 986 ms
102,472 KB |
testcase_02 | AC | 988 ms
102,424 KB |
testcase_03 | AC | 947 ms
105,928 KB |
testcase_04 | AC | 957 ms
101,740 KB |
testcase_05 | AC | 1,040 ms
104,168 KB |
testcase_06 | AC | 1,124 ms
103,748 KB |
testcase_07 | AC | 970 ms
102,696 KB |
testcase_08 | AC | 927 ms
102,192 KB |
testcase_09 | AC | 967 ms
104,596 KB |
testcase_10 | AC | 961 ms
103,384 KB |
testcase_11 | AC | 953 ms
103,952 KB |
testcase_12 | AC | 1,008 ms
105,460 KB |
testcase_13 | AC | 1,018 ms
104,772 KB |
testcase_14 | AC | 979 ms
102,948 KB |
testcase_15 | AC | 999 ms
105,440 KB |
testcase_16 | AC | 1,000 ms
103,648 KB |
testcase_17 | AC | 967 ms
102,392 KB |
testcase_18 | AC | 1,032 ms
107,452 KB |
testcase_19 | AC | 932 ms
102,056 KB |
testcase_20 | AC | 1,089 ms
103,796 KB |
testcase_21 | AC | 948 ms
103,712 KB |
testcase_22 | AC | 952 ms
102,224 KB |
testcase_23 | AC | 1,059 ms
105,720 KB |
testcase_24 | AC | 955 ms
104,140 KB |
testcase_25 | AC | 937 ms
100,952 KB |
testcase_26 | AC | 950 ms
102,084 KB |
testcase_27 | AC | 981 ms
104,868 KB |
testcase_28 | AC | 1,130 ms
105,756 KB |
testcase_29 | AC | 1,072 ms
104,744 KB |
testcase_30 | AC | 985 ms
104,428 KB |
testcase_31 | AC | 1,020 ms
107,812 KB |
testcase_32 | AC | 997 ms
104,624 KB |
testcase_33 | AC | 1,029 ms
106,604 KB |
testcase_34 | AC | 1,002 ms
102,864 KB |
testcase_35 | AC | 992 ms
104,384 KB |
testcase_36 | AC | 1,019 ms
105,300 KB |
testcase_37 | AC | 933 ms
102,768 KB |
testcase_38 | AC | 1,014 ms
105,564 KB |
testcase_39 | AC | 993 ms
103,332 KB |
testcase_40 | AC | 979 ms
104,916 KB |
testcase_41 | AC | 953 ms
102,760 KB |
testcase_42 | AC | 927 ms
100,924 KB |
testcase_43 | AC | 990 ms
105,948 KB |
testcase_44 | AC | 1,000 ms
104,728 KB |
testcase_45 | AC | 978 ms
103,028 KB |
testcase_46 | AC | 993 ms
104,856 KB |
testcase_47 | AC | 967 ms
102,312 KB |
testcase_48 | AC | 970 ms
103,412 KB |
testcase_49 | AC | 1,046 ms
104,532 KB |
testcase_50 | AC | 955 ms
102,548 KB |
testcase_51 | AC | 1,014 ms
105,376 KB |
testcase_52 | AC | 990 ms
103,188 KB |
testcase_53 | AC | 950 ms
103,968 KB |
testcase_54 | AC | 1,048 ms
107,056 KB |
testcase_55 | AC | 1,088 ms
102,968 KB |
testcase_56 | AC | 1,122 ms
104,788 KB |
testcase_57 | AC | 960 ms
102,820 KB |
testcase_58 | AC | 944 ms
102,660 KB |
testcase_59 | AC | 1,027 ms
104,192 KB |
testcase_60 | AC | 954 ms
103,444 KB |
testcase_61 | AC | 961 ms
104,200 KB |
testcase_62 | AC | 989 ms
105,380 KB |
testcase_63 | AC | 976 ms
101,780 KB |
testcase_64 | AC | 989 ms
105,984 KB |
testcase_65 | AC | 948 ms
101,352 KB |
testcase_66 | AC | 994 ms
104,188 KB |
testcase_67 | AC | 1,006 ms
103,956 KB |
testcase_68 | AC | 999 ms
103,800 KB |
testcase_69 | AC | 926 ms
102,268 KB |
testcase_70 | AC | 1,110 ms
103,192 KB |
testcase_71 | AC | 1,010 ms
105,540 KB |
testcase_72 | AC | 1,075 ms
104,612 KB |
testcase_73 | AC | 956 ms
102,924 KB |
testcase_74 | AC | 951 ms
104,872 KB |
testcase_75 | AC | 1,006 ms
104,160 KB |
testcase_76 | AC | 968 ms
105,056 KB |
testcase_77 | AC | 976 ms
101,920 KB |
testcase_78 | AC | 995 ms
104,720 KB |
testcase_79 | AC | 990 ms
104,696 KB |
testcase_80 | AC | 965 ms
102,700 KB |
testcase_81 | AC | 950 ms
103,552 KB |
testcase_82 | AC | 974 ms
103,960 KB |
testcase_83 | AC | 941 ms
103,004 KB |
testcase_84 | AC | 989 ms
104,644 KB |
testcase_85 | AC | 903 ms
101,936 KB |
testcase_86 | AC | 1,101 ms
110,840 KB |
testcase_87 | AC | 934 ms
102,052 KB |
testcase_88 | AC | 975 ms
103,520 KB |
testcase_89 | AC | 1,016 ms
103,768 KB |
testcase_90 | AC | 938 ms
101,332 KB |
testcase_91 | AC | 936 ms
103,132 KB |
testcase_92 | AC | 920 ms
101,220 KB |
testcase_93 | AC | 954 ms
102,156 KB |
testcase_94 | AC | 1,003 ms
104,104 KB |
testcase_95 | AC | 992 ms
102,832 KB |
testcase_96 | AC | 966 ms
103,132 KB |
testcase_97 | AC | 931 ms
101,864 KB |
testcase_98 | AC | 965 ms
104,300 KB |
testcase_99 | AC | 1,075 ms
106,180 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() 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] >150: s.discard(e) t_ans=set() for i in range(L[0]): # print(s) nowi=(L[i+1],pi,t) p[pi]=L[i+1] sorteds=sorted(list(s)) target=bisect.bisect_right(sorteds,nowi) used=False for _t in list(t_ans): if abs(p[pi] - p[_t]) < 8: 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])<10: 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])<10: 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 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()