結果
問題 | No.5004 Room Assignment |
ユーザー | negibose2020 |
提出日時 | 2021-12-01 21:56:31 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 936 ms / 5,000 ms |
コード長 | 3,242 bytes |
コンパイル時間 | 221 ms |
実行使用メモリ | 105,760 KB |
スコア | 54,977,909 |
平均クエリ数 | 6423.78 |
最終ジャッジ日時 | 2021-12-01 21:58:02 |
合計ジャッジ時間 | 90,820 ms |
ジャッジサーバーID (参考情報) |
judge16 / judge10 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 798 ms
102,848 KB |
testcase_01 | AC | 852 ms
101,172 KB |
testcase_02 | AC | 810 ms
100,940 KB |
testcase_03 | AC | 855 ms
103,588 KB |
testcase_04 | AC | 813 ms
101,076 KB |
testcase_05 | AC | 862 ms
101,480 KB |
testcase_06 | AC | 840 ms
102,980 KB |
testcase_07 | AC | 842 ms
101,876 KB |
testcase_08 | AC | 792 ms
101,656 KB |
testcase_09 | AC | 875 ms
104,076 KB |
testcase_10 | AC | 798 ms
102,000 KB |
testcase_11 | AC | 843 ms
101,460 KB |
testcase_12 | AC | 858 ms
102,980 KB |
testcase_13 | AC | 875 ms
101,340 KB |
testcase_14 | AC | 870 ms
105,760 KB |
testcase_15 | AC | 836 ms
102,780 KB |
testcase_16 | AC | 793 ms
103,080 KB |
testcase_17 | AC | 850 ms
103,080 KB |
testcase_18 | AC | 815 ms
102,788 KB |
testcase_19 | AC | 844 ms
102,932 KB |
testcase_20 | AC | 816 ms
102,768 KB |
testcase_21 | AC | 855 ms
100,692 KB |
testcase_22 | AC | 843 ms
102,768 KB |
testcase_23 | AC | 859 ms
102,076 KB |
testcase_24 | AC | 798 ms
102,496 KB |
testcase_25 | AC | 836 ms
101,040 KB |
testcase_26 | AC | 858 ms
104,592 KB |
testcase_27 | AC | 805 ms
100,656 KB |
testcase_28 | AC | 840 ms
104,428 KB |
testcase_29 | AC | 831 ms
102,712 KB |
testcase_30 | AC | 927 ms
100,692 KB |
testcase_31 | AC | 839 ms
103,600 KB |
testcase_32 | AC | 851 ms
103,052 KB |
testcase_33 | AC | 816 ms
101,448 KB |
testcase_34 | AC | 837 ms
100,096 KB |
testcase_35 | AC | 808 ms
100,956 KB |
testcase_36 | AC | 832 ms
100,448 KB |
testcase_37 | AC | 827 ms
103,080 KB |
testcase_38 | AC | 863 ms
101,644 KB |
testcase_39 | AC | 848 ms
105,168 KB |
testcase_40 | AC | 846 ms
100,960 KB |
testcase_41 | AC | 825 ms
102,400 KB |
testcase_42 | AC | 829 ms
101,772 KB |
testcase_43 | AC | 816 ms
100,476 KB |
testcase_44 | AC | 797 ms
101,432 KB |
testcase_45 | AC | 840 ms
102,392 KB |
testcase_46 | AC | 817 ms
100,600 KB |
testcase_47 | AC | 821 ms
101,700 KB |
testcase_48 | AC | 886 ms
100,324 KB |
testcase_49 | AC | 936 ms
103,408 KB |
testcase_50 | AC | 832 ms
102,500 KB |
testcase_51 | AC | 828 ms
101,372 KB |
testcase_52 | AC | 867 ms
102,812 KB |
testcase_53 | AC | 867 ms
100,412 KB |
testcase_54 | AC | 837 ms
102,036 KB |
testcase_55 | AC | 847 ms
100,100 KB |
testcase_56 | AC | 856 ms
105,048 KB |
testcase_57 | AC | 798 ms
100,252 KB |
testcase_58 | AC | 838 ms
101,048 KB |
testcase_59 | AC | 821 ms
101,852 KB |
testcase_60 | AC | 849 ms
102,932 KB |
testcase_61 | AC | 808 ms
101,880 KB |
testcase_62 | AC | 859 ms
102,132 KB |
testcase_63 | AC | 816 ms
102,264 KB |
testcase_64 | AC | 800 ms
102,072 KB |
testcase_65 | AC | 850 ms
102,388 KB |
testcase_66 | AC | 815 ms
101,348 KB |
testcase_67 | AC | 832 ms
100,500 KB |
testcase_68 | AC | 814 ms
101,496 KB |
testcase_69 | AC | 864 ms
100,148 KB |
testcase_70 | AC | 809 ms
103,132 KB |
testcase_71 | AC | 866 ms
102,088 KB |
testcase_72 | AC | 784 ms
101,128 KB |
testcase_73 | AC | 817 ms
101,764 KB |
testcase_74 | AC | 837 ms
102,120 KB |
testcase_75 | AC | 807 ms
100,064 KB |
testcase_76 | AC | 823 ms
101,128 KB |
testcase_77 | AC | 800 ms
101,944 KB |
testcase_78 | AC | 840 ms
103,444 KB |
testcase_79 | AC | 808 ms
103,076 KB |
testcase_80 | AC | 818 ms
103,316 KB |
testcase_81 | AC | 835 ms
103,340 KB |
testcase_82 | AC | 852 ms
103,632 KB |
testcase_83 | AC | 826 ms
102,432 KB |
testcase_84 | AC | 844 ms
102,480 KB |
testcase_85 | AC | 836 ms
102,432 KB |
testcase_86 | AC | 827 ms
103,520 KB |
testcase_87 | AC | 833 ms
102,536 KB |
testcase_88 | AC | 823 ms
102,836 KB |
testcase_89 | AC | 810 ms
102,596 KB |
testcase_90 | AC | 863 ms
102,856 KB |
testcase_91 | AC | 839 ms
102,924 KB |
testcase_92 | AC | 820 ms
100,640 KB |
testcase_93 | AC | 793 ms
101,176 KB |
testcase_94 | AC | 791 ms
100,800 KB |
testcase_95 | AC | 858 ms
102,532 KB |
testcase_96 | AC | 845 ms
104,184 KB |
testcase_97 | AC | 840 ms
101,796 KB |
testcase_98 | AC | 810 ms
100,632 KB |
testcase_99 | AC | 825 ms
102,964 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 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 < 3: # uf.union(_t,pi) # t_ans.add(pi) # used = True 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()