結果
問題 | No.2596 Christmas Eve (Heuristic ver.) |
ユーザー | hirayuu_yc |
提出日時 | 2023-11-28 14:12:55 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,157 ms / 1,224 ms |
コード長 | 5,494 bytes |
コンパイル時間 | 551 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 83,908 KB |
スコア | 3,219,108 |
最終ジャッジ日時 | 2023-12-23 20:34:27 |
合計ジャッジ時間 | 155,493 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,150 ms
81,884 KB |
testcase_01 | AC | 1,151 ms
82,164 KB |
testcase_02 | AC | 1,150 ms
81,332 KB |
testcase_03 | AC | 1,150 ms
82,028 KB |
testcase_04 | AC | 1,149 ms
83,472 KB |
testcase_05 | AC | 1,150 ms
81,904 KB |
testcase_06 | AC | 1,151 ms
81,924 KB |
testcase_07 | AC | 1,152 ms
82,628 KB |
testcase_08 | AC | 1,152 ms
81,372 KB |
testcase_09 | AC | 1,149 ms
82,840 KB |
testcase_10 | AC | 1,149 ms
82,588 KB |
testcase_11 | AC | 1,152 ms
82,296 KB |
testcase_12 | AC | 1,150 ms
81,744 KB |
testcase_13 | AC | 1,150 ms
81,816 KB |
testcase_14 | AC | 1,150 ms
82,308 KB |
testcase_15 | AC | 1,149 ms
81,868 KB |
testcase_16 | AC | 1,152 ms
82,464 KB |
testcase_17 | AC | 1,150 ms
82,664 KB |
testcase_18 | AC | 1,151 ms
81,120 KB |
testcase_19 | AC | 1,150 ms
81,928 KB |
testcase_20 | AC | 1,150 ms
82,924 KB |
testcase_21 | AC | 1,150 ms
81,812 KB |
testcase_22 | AC | 1,151 ms
81,744 KB |
testcase_23 | AC | 1,151 ms
81,384 KB |
testcase_24 | AC | 1,150 ms
81,784 KB |
testcase_25 | AC | 1,152 ms
81,912 KB |
testcase_26 | AC | 1,151 ms
82,040 KB |
testcase_27 | AC | 1,150 ms
82,036 KB |
testcase_28 | AC | 1,151 ms
83,116 KB |
testcase_29 | AC | 1,151 ms
82,032 KB |
testcase_30 | AC | 1,150 ms
82,132 KB |
testcase_31 | AC | 1,149 ms
81,196 KB |
testcase_32 | AC | 1,150 ms
82,300 KB |
testcase_33 | AC | 1,149 ms
81,376 KB |
testcase_34 | AC | 1,151 ms
81,416 KB |
testcase_35 | AC | 1,150 ms
82,228 KB |
testcase_36 | AC | 1,150 ms
81,828 KB |
testcase_37 | AC | 1,149 ms
81,952 KB |
testcase_38 | AC | 1,150 ms
81,788 KB |
testcase_39 | AC | 1,150 ms
82,552 KB |
testcase_40 | AC | 1,150 ms
81,788 KB |
testcase_41 | AC | 1,156 ms
82,128 KB |
testcase_42 | AC | 1,157 ms
81,532 KB |
testcase_43 | AC | 1,155 ms
81,876 KB |
testcase_44 | AC | 1,152 ms
82,904 KB |
testcase_45 | AC | 1,150 ms
81,480 KB |
testcase_46 | AC | 1,151 ms
82,596 KB |
testcase_47 | AC | 1,151 ms
82,132 KB |
testcase_48 | AC | 1,152 ms
82,140 KB |
testcase_49 | AC | 1,151 ms
81,908 KB |
testcase_50 | AC | 1,150 ms
83,336 KB |
testcase_51 | AC | 1,151 ms
82,944 KB |
testcase_52 | AC | 1,152 ms
82,324 KB |
testcase_53 | AC | 1,151 ms
81,760 KB |
testcase_54 | AC | 1,152 ms
80,996 KB |
testcase_55 | AC | 1,151 ms
82,368 KB |
testcase_56 | AC | 1,150 ms
82,140 KB |
testcase_57 | AC | 1,152 ms
82,020 KB |
testcase_58 | AC | 1,152 ms
82,388 KB |
testcase_59 | AC | 1,151 ms
82,104 KB |
testcase_60 | AC | 1,151 ms
82,012 KB |
testcase_61 | AC | 1,151 ms
82,376 KB |
testcase_62 | AC | 1,150 ms
82,076 KB |
testcase_63 | AC | 1,150 ms
82,912 KB |
testcase_64 | AC | 1,152 ms
81,324 KB |
testcase_65 | AC | 1,150 ms
82,000 KB |
testcase_66 | AC | 1,151 ms
81,996 KB |
testcase_67 | AC | 1,151 ms
82,552 KB |
testcase_68 | AC | 1,150 ms
82,316 KB |
testcase_69 | AC | 1,151 ms
81,768 KB |
testcase_70 | AC | 1,151 ms
83,208 KB |
testcase_71 | AC | 1,150 ms
82,120 KB |
testcase_72 | AC | 1,151 ms
81,032 KB |
testcase_73 | AC | 1,151 ms
81,264 KB |
testcase_74 | AC | 1,151 ms
82,132 KB |
testcase_75 | AC | 1,150 ms
82,948 KB |
testcase_76 | AC | 1,152 ms
82,036 KB |
testcase_77 | AC | 1,151 ms
82,444 KB |
testcase_78 | AC | 1,150 ms
81,964 KB |
testcase_79 | AC | 1,151 ms
81,872 KB |
testcase_80 | AC | 1,152 ms
82,240 KB |
testcase_81 | AC | 1,150 ms
82,044 KB |
testcase_82 | AC | 1,152 ms
82,148 KB |
testcase_83 | AC | 1,150 ms
82,164 KB |
testcase_84 | AC | 1,150 ms
81,616 KB |
testcase_85 | AC | 1,149 ms
81,844 KB |
testcase_86 | AC | 1,151 ms
81,820 KB |
testcase_87 | AC | 1,150 ms
83,564 KB |
testcase_88 | AC | 1,152 ms
83,908 KB |
testcase_89 | AC | 1,150 ms
82,628 KB |
testcase_90 | AC | 1,151 ms
81,908 KB |
testcase_91 | AC | 1,152 ms
81,920 KB |
testcase_92 | AC | 1,152 ms
81,640 KB |
testcase_93 | AC | 1,151 ms
81,812 KB |
testcase_94 | AC | 1,151 ms
81,464 KB |
testcase_95 | AC | 1,150 ms
82,436 KB |
testcase_96 | AC | 1,151 ms
82,000 KB |
testcase_97 | AC | 1,150 ms
81,916 KB |
testcase_98 | AC | 1,150 ms
82,996 KB |
testcase_99 | AC | 1,150 ms
82,152 KB |
testcase_100 | AC | 1,154 ms
82,960 KB |
testcase_101 | AC | 1,151 ms
82,424 KB |
testcase_102 | AC | 1,150 ms
81,476 KB |
testcase_103 | AC | 1,148 ms
81,912 KB |
testcase_104 | AC | 1,152 ms
82,540 KB |
testcase_105 | AC | 1,151 ms
82,308 KB |
testcase_106 | AC | 1,152 ms
81,692 KB |
testcase_107 | AC | 1,151 ms
81,760 KB |
testcase_108 | AC | 1,152 ms
82,300 KB |
testcase_109 | AC | 1,154 ms
82,360 KB |
testcase_110 | AC | 1,150 ms
82,060 KB |
testcase_111 | AC | 1,150 ms
81,576 KB |
testcase_112 | AC | 1,151 ms
81,420 KB |
testcase_113 | AC | 1,151 ms
81,776 KB |
testcase_114 | AC | 1,150 ms
81,632 KB |
testcase_115 | AC | 1,151 ms
82,700 KB |
testcase_116 | AC | 1,152 ms
81,512 KB |
testcase_117 | AC | 1,153 ms
82,124 KB |
testcase_118 | AC | 1,151 ms
82,088 KB |
testcase_119 | AC | 1,151 ms
82,464 KB |
testcase_120 | AC | 1,152 ms
81,944 KB |
testcase_121 | AC | 1,150 ms
81,976 KB |
testcase_122 | AC | 1,151 ms
81,684 KB |
testcase_123 | AC | 1,150 ms
82,072 KB |
testcase_124 | AC | 1,152 ms
81,924 KB |
ソースコード
import random import time def isvalid(tree): return e[tree[3]]<a[tree[0]] and a[tree[0]]<c[tree[1]] and a[tree[0]]<c[tree[2]] def high(tree): return b[tree[0]]+d[tree[1]]+d[tree[2]]+f[tree[3]] def row_score(trees): global mini_pos,maxi_pos mini=40000 maxi=0 cnt=0 for i in trees: now=high(i) if now<mini: mini=now mini_pos=cnt if now>maxi: maxi=now maxi_pos=cnt cnt+=1 return maxi-mini def score(trees): wa=0 use=[] for i in trees: use.append(high(i)) wa+=use[-1] ret=0 for i in use: ret+=((i*N)-wa)**2 return ret st=time.time() N,M=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) d=list(map(int,input().split())) e=list(map(int,input().split())) f=list(map(int,input().split())) tip=list(zip(a,b,range(N))) center=list(zip(c,d,range(N*2))) stem=list(zip(e,f,range(N))) tip.sort(reverse=True) center.sort(reverse=True) stem.sort(reverse=True) tip_stock=set(range(N)) center_stock=set(range(N*2)) stem_stock=set(range(N*2)) tree=[] for i in range(M): while stem[-1][0]>=tip[-1][0]: tip.pop() while tip[-1][0]>=center[-1][0]: center.pop() tree.append([tip[-1][2],center[-1][2],center[-2][2],stem[-1][2]]) tip_stock.discard(tip[-1][2]) center_stock.discard(center[-1][2]) center_stock.discard(center[-2][2]) stem_stock.discard(stem[-1][2]) center.pop() center.pop() tip.pop() stem.pop() tip_stock=list(tip_stock) center_stock=list(center_stock) stem_stock=list(stem_stock) mini_pos=-1 maxi_pos=-1 now=row_score(tree) while time.time()-st<1.1: befmi=mini_pos befma=maxi_pos if random.random()<1: if random.random()<0.5: lf=mini_pos else: lf=maxi_pos ri=random.randint(0,M-1) if lf==ri: ri=(ri+1)%M if random.random()<0.25: tree[lf][0],tree[ri][0]=tree[ri][0],tree[lf][0] if not(isvalid(tree[lf]) and isvalid(tree[ri])): tree[lf][0],tree[ri][0]=tree[ri][0],tree[lf][0] else: sc=row_score(tree) if sc>now: maxi_pos=befma mini_pos=befmi tree[lf][0],tree[ri][0]=tree[ri][0],tree[lf][0] else: now=sc elif random.random()<0.3333: tree[lf][2],tree[ri][2]=tree[ri][2],tree[lf][2] if not(isvalid(tree[lf]) and isvalid(tree[ri])): tree[lf][2],tree[ri][2]=tree[ri][2],tree[lf][2] else: sc=row_score(tree) if sc>now: maxi_pos=befma mini_pos=befmi tree[lf][2],tree[ri][2]=tree[ri][2],tree[lf][2] else: now=sc else: if random.random()<0.5: tree[lf][1],tree[lf][2]=tree[lf][2],tree[lf][1] if random.random()<0.5: tree[ri][1],tree[ri][2]=tree[ri][2],tree[ri][1] tree[lf][1],tree[ri][1]=tree[ri][1],tree[lf][1] if not(isvalid(tree[lf]) and isvalid(tree[ri])): tree[lf][1],tree[ri][1]=tree[ri][1],tree[lf][1] else: sc=row_score(tree) if sc>now: maxi_pos=befma mini_pos=befmi tree[lf][1],tree[ri][1]=tree[ri][1],tree[lf][1] else: now=sc else: if random.random()<0.5: lf=mini_pos else: lf=maxi_pos if random.random()<0.25: pos=random.randint(0,len(tip_stock)) tree[lf][0],tip_stock[pos]=tip_stock[pos],tree[lf][0] if not(isvalid(tree[lf])): tree[lf][0],tip_stock[pos]=tip_stock[pos],tree[lf][0] else: sc=row_score(tree) if sc>now: maxi_pos=befma mini_pos=befmi tree[lf][0],tip_stock[pos]=tip_stock[pos],tree[lf][0] else: now=sc elif random.random()<0.33333: pos=random.randint(0,len(stem_stock)) tree[lf][3],stem_stock[pos]=stem_stock[pos],tree[lf][3] if not(isvalid(tree[lf])): tree[lf][3],stem_stock[pos]=stem_stock[pos],tree[lf][3] else: sc=row_score(tree) if sc>now: maxi_pos=befma mini_pos=befmi tree[lf][3],stem_stock[pos]=stem_stock[pos],tree[lf][3] else: now=sc else: if random.random()<0.5: tree[lf][1],tree[lf][2]=tree[lf][2],tree[lf][1] pos=random.randint(0,len(center_stock)) tree[lf][2],center_stock[pos]=center_stock[pos],tree[lf][2] if not(isvalid(tree[lf])): tree[lf][2],center_stock[pos]=center_stock[pos],tree[lf][2] else: sc=row_score(tree) if sc>now: maxi_pos=befma mini_pos=befmi tree[lf][2],center_stock[pos]=center_stock[pos],tree[lf][2] else: now=sc #print(row_score(tree)) for i in tree: print(*(map(lambda x:x+1,i)))