結果
問題 | No.5004 Room Assignment |
ユーザー | negibose2020 |
提出日時 | 2021-12-01 22:15:18 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 983 ms / 5,000 ms |
コード長 | 3,449 bytes |
コンパイル時間 | 229 ms |
実行使用メモリ | 106,588 KB |
スコア | 55,003,033 |
平均クエリ数 | 6421.51 |
最終ジャッジ日時 | 2021-12-01 22:16:51 |
合計ジャッジ時間 | 92,067 ms |
ジャッジサーバーID (参考情報) |
judge16 / judge15 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 876 ms
103,528 KB |
testcase_01 | AC | 840 ms
106,588 KB |
testcase_02 | AC | 858 ms
102,768 KB |
testcase_03 | AC | 849 ms
106,148 KB |
testcase_04 | AC | 834 ms
101,120 KB |
testcase_05 | AC | 834 ms
102,832 KB |
testcase_06 | AC | 846 ms
102,508 KB |
testcase_07 | AC | 848 ms
103,588 KB |
testcase_08 | AC | 837 ms
103,652 KB |
testcase_09 | AC | 828 ms
102,736 KB |
testcase_10 | AC | 848 ms
102,556 KB |
testcase_11 | AC | 859 ms
102,428 KB |
testcase_12 | AC | 821 ms
103,392 KB |
testcase_13 | AC | 846 ms
102,728 KB |
testcase_14 | AC | 829 ms
100,668 KB |
testcase_15 | AC | 856 ms
101,012 KB |
testcase_16 | AC | 878 ms
103,936 KB |
testcase_17 | AC | 859 ms
102,484 KB |
testcase_18 | AC | 812 ms
102,996 KB |
testcase_19 | AC | 802 ms
100,780 KB |
testcase_20 | AC | 867 ms
103,580 KB |
testcase_21 | AC | 860 ms
102,952 KB |
testcase_22 | AC | 789 ms
100,108 KB |
testcase_23 | AC | 857 ms
102,180 KB |
testcase_24 | AC | 812 ms
102,612 KB |
testcase_25 | AC | 897 ms
102,696 KB |
testcase_26 | AC | 860 ms
104,168 KB |
testcase_27 | AC | 848 ms
103,948 KB |
testcase_28 | AC | 807 ms
103,180 KB |
testcase_29 | AC | 848 ms
101,548 KB |
testcase_30 | AC | 911 ms
103,864 KB |
testcase_31 | AC | 858 ms
101,500 KB |
testcase_32 | AC | 897 ms
105,428 KB |
testcase_33 | AC | 838 ms
101,844 KB |
testcase_34 | AC | 810 ms
100,808 KB |
testcase_35 | AC | 824 ms
101,984 KB |
testcase_36 | AC | 797 ms
100,340 KB |
testcase_37 | AC | 889 ms
102,244 KB |
testcase_38 | AC | 831 ms
103,656 KB |
testcase_39 | AC | 853 ms
103,360 KB |
testcase_40 | AC | 866 ms
102,380 KB |
testcase_41 | AC | 802 ms
100,068 KB |
testcase_42 | AC | 793 ms
102,460 KB |
testcase_43 | AC | 836 ms
102,724 KB |
testcase_44 | AC | 804 ms
101,416 KB |
testcase_45 | AC | 845 ms
104,564 KB |
testcase_46 | AC | 857 ms
102,988 KB |
testcase_47 | AC | 836 ms
101,932 KB |
testcase_48 | AC | 983 ms
103,460 KB |
testcase_49 | AC | 930 ms
103,760 KB |
testcase_50 | AC | 867 ms
101,940 KB |
testcase_51 | AC | 808 ms
101,148 KB |
testcase_52 | AC | 885 ms
105,320 KB |
testcase_53 | AC | 796 ms
103,160 KB |
testcase_54 | AC | 802 ms
100,708 KB |
testcase_55 | AC | 877 ms
105,176 KB |
testcase_56 | AC | 832 ms
104,904 KB |
testcase_57 | AC | 867 ms
103,552 KB |
testcase_58 | AC | 907 ms
104,600 KB |
testcase_59 | AC | 846 ms
103,728 KB |
testcase_60 | AC | 818 ms
102,232 KB |
testcase_61 | AC | 838 ms
102,052 KB |
testcase_62 | AC | 853 ms
103,156 KB |
testcase_63 | AC | 828 ms
102,696 KB |
testcase_64 | AC | 859 ms
104,224 KB |
testcase_65 | AC | 843 ms
103,472 KB |
testcase_66 | AC | 844 ms
103,400 KB |
testcase_67 | AC | 852 ms
103,676 KB |
testcase_68 | AC | 890 ms
102,808 KB |
testcase_69 | AC | 849 ms
101,512 KB |
testcase_70 | AC | 792 ms
100,816 KB |
testcase_71 | AC | 872 ms
104,904 KB |
testcase_72 | AC | 819 ms
102,324 KB |
testcase_73 | AC | 805 ms
103,064 KB |
testcase_74 | AC | 846 ms
105,816 KB |
testcase_75 | AC | 854 ms
103,324 KB |
testcase_76 | AC | 847 ms
104,152 KB |
testcase_77 | AC | 856 ms
105,712 KB |
testcase_78 | AC | 828 ms
105,944 KB |
testcase_79 | AC | 897 ms
105,336 KB |
testcase_80 | AC | 827 ms
101,976 KB |
testcase_81 | AC | 855 ms
101,344 KB |
testcase_82 | AC | 856 ms
104,828 KB |
testcase_83 | AC | 821 ms
101,828 KB |
testcase_84 | AC | 846 ms
102,388 KB |
testcase_85 | AC | 825 ms
103,304 KB |
testcase_86 | AC | 815 ms
102,772 KB |
testcase_87 | AC | 845 ms
103,216 KB |
testcase_88 | AC | 872 ms
105,000 KB |
testcase_89 | AC | 826 ms
102,652 KB |
testcase_90 | AC | 874 ms
104,400 KB |
testcase_91 | AC | 891 ms
105,132 KB |
testcase_92 | AC | 838 ms
101,604 KB |
testcase_93 | AC | 832 ms
102,704 KB |
testcase_94 | AC | 813 ms
102,244 KB |
testcase_95 | AC | 813 ms
102,548 KB |
testcase_96 | AC | 831 ms
101,836 KB |
testcase_97 | AC | 860 ms
104,764 KB |
testcase_98 | AC | 821 ms
101,724 KB |
testcase_99 | AC | 824 ms
101,572 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] >200: 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]) < 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: sz=len(uf.members(sorteds[target-1][1])) if sz<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: sz=len(uf.members(sorteds[target][1])) if sz<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()