結果
問題 | No.2596 Christmas Eve (Heuristic ver.) |
ユーザー | hirayuu_yc |
提出日時 | 2023-11-28 13:40:16 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,193 ms / 1,224 ms |
コード長 | 3,267 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 82,524 KB |
スコア | 2,914,544 |
最終ジャッジ日時 | 2023-12-23 20:32:55 |
合計ジャッジ時間 | 155,204 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,150 ms
81,412 KB |
testcase_01 | AC | 1,151 ms
81,040 KB |
testcase_02 | AC | 1,150 ms
82,148 KB |
testcase_03 | AC | 1,149 ms
81,396 KB |
testcase_04 | AC | 1,150 ms
82,312 KB |
testcase_05 | AC | 1,151 ms
81,976 KB |
testcase_06 | AC | 1,150 ms
81,700 KB |
testcase_07 | AC | 1,149 ms
81,772 KB |
testcase_08 | AC | 1,150 ms
81,024 KB |
testcase_09 | AC | 1,151 ms
81,148 KB |
testcase_10 | AC | 1,150 ms
81,464 KB |
testcase_11 | AC | 1,150 ms
81,504 KB |
testcase_12 | AC | 1,150 ms
81,264 KB |
testcase_13 | AC | 1,151 ms
80,628 KB |
testcase_14 | AC | 1,150 ms
81,952 KB |
testcase_15 | AC | 1,149 ms
82,060 KB |
testcase_16 | AC | 1,152 ms
81,168 KB |
testcase_17 | AC | 1,149 ms
81,488 KB |
testcase_18 | AC | 1,150 ms
81,252 KB |
testcase_19 | AC | 1,150 ms
81,252 KB |
testcase_20 | AC | 1,150 ms
82,064 KB |
testcase_21 | AC | 1,150 ms
81,016 KB |
testcase_22 | AC | 1,151 ms
81,312 KB |
testcase_23 | AC | 1,150 ms
81,020 KB |
testcase_24 | AC | 1,150 ms
81,908 KB |
testcase_25 | AC | 1,151 ms
80,868 KB |
testcase_26 | AC | 1,150 ms
81,512 KB |
testcase_27 | AC | 1,151 ms
81,404 KB |
testcase_28 | AC | 1,151 ms
81,384 KB |
testcase_29 | AC | 1,150 ms
81,540 KB |
testcase_30 | AC | 1,151 ms
81,136 KB |
testcase_31 | AC | 1,149 ms
81,676 KB |
testcase_32 | AC | 1,150 ms
80,912 KB |
testcase_33 | AC | 1,150 ms
81,732 KB |
testcase_34 | AC | 1,150 ms
81,572 KB |
testcase_35 | AC | 1,150 ms
81,768 KB |
testcase_36 | AC | 1,149 ms
81,288 KB |
testcase_37 | AC | 1,150 ms
81,312 KB |
testcase_38 | AC | 1,150 ms
81,532 KB |
testcase_39 | AC | 1,152 ms
82,296 KB |
testcase_40 | AC | 1,150 ms
80,776 KB |
testcase_41 | AC | 1,150 ms
81,404 KB |
testcase_42 | AC | 1,151 ms
81,552 KB |
testcase_43 | AC | 1,150 ms
81,668 KB |
testcase_44 | AC | 1,152 ms
81,892 KB |
testcase_45 | AC | 1,150 ms
81,280 KB |
testcase_46 | AC | 1,151 ms
81,916 KB |
testcase_47 | AC | 1,151 ms
82,284 KB |
testcase_48 | AC | 1,150 ms
81,448 KB |
testcase_49 | AC | 1,150 ms
81,788 KB |
testcase_50 | AC | 1,150 ms
82,460 KB |
testcase_51 | AC | 1,150 ms
80,908 KB |
testcase_52 | AC | 1,151 ms
81,532 KB |
testcase_53 | AC | 1,151 ms
81,620 KB |
testcase_54 | AC | 1,152 ms
81,172 KB |
testcase_55 | AC | 1,150 ms
82,184 KB |
testcase_56 | AC | 1,152 ms
81,136 KB |
testcase_57 | AC | 1,151 ms
81,020 KB |
testcase_58 | AC | 1,151 ms
81,548 KB |
testcase_59 | AC | 1,150 ms
81,552 KB |
testcase_60 | AC | 1,150 ms
81,552 KB |
testcase_61 | AC | 1,151 ms
81,664 KB |
testcase_62 | AC | 1,149 ms
81,776 KB |
testcase_63 | AC | 1,150 ms
82,256 KB |
testcase_64 | AC | 1,150 ms
81,300 KB |
testcase_65 | AC | 1,149 ms
80,968 KB |
testcase_66 | AC | 1,151 ms
81,984 KB |
testcase_67 | AC | 1,150 ms
82,252 KB |
testcase_68 | AC | 1,150 ms
81,536 KB |
testcase_69 | AC | 1,151 ms
82,524 KB |
testcase_70 | AC | 1,150 ms
81,844 KB |
testcase_71 | AC | 1,150 ms
81,392 KB |
testcase_72 | AC | 1,150 ms
80,956 KB |
testcase_73 | AC | 1,150 ms
81,012 KB |
testcase_74 | AC | 1,150 ms
81,288 KB |
testcase_75 | AC | 1,151 ms
81,160 KB |
testcase_76 | AC | 1,151 ms
81,588 KB |
testcase_77 | AC | 1,151 ms
80,732 KB |
testcase_78 | AC | 1,150 ms
81,032 KB |
testcase_79 | AC | 1,151 ms
81,612 KB |
testcase_80 | AC | 1,151 ms
81,028 KB |
testcase_81 | AC | 1,150 ms
81,300 KB |
testcase_82 | AC | 1,152 ms
81,664 KB |
testcase_83 | AC | 1,150 ms
81,836 KB |
testcase_84 | AC | 1,149 ms
82,072 KB |
testcase_85 | AC | 1,150 ms
81,328 KB |
testcase_86 | AC | 1,150 ms
81,664 KB |
testcase_87 | AC | 1,150 ms
81,548 KB |
testcase_88 | AC | 1,150 ms
81,648 KB |
testcase_89 | AC | 1,149 ms
81,896 KB |
testcase_90 | AC | 1,149 ms
81,276 KB |
testcase_91 | AC | 1,150 ms
81,696 KB |
testcase_92 | AC | 1,151 ms
80,996 KB |
testcase_93 | AC | 1,150 ms
81,252 KB |
testcase_94 | AC | 1,150 ms
80,660 KB |
testcase_95 | AC | 1,149 ms
81,176 KB |
testcase_96 | AC | 1,151 ms
81,012 KB |
testcase_97 | AC | 1,150 ms
80,916 KB |
testcase_98 | AC | 1,150 ms
81,372 KB |
testcase_99 | AC | 1,166 ms
81,168 KB |
testcase_100 | AC | 1,193 ms
81,752 KB |
testcase_101 | AC | 1,154 ms
81,308 KB |
testcase_102 | AC | 1,150 ms
81,020 KB |
testcase_103 | AC | 1,150 ms
82,172 KB |
testcase_104 | AC | 1,152 ms
82,148 KB |
testcase_105 | AC | 1,150 ms
81,856 KB |
testcase_106 | AC | 1,151 ms
81,268 KB |
testcase_107 | AC | 1,151 ms
80,380 KB |
testcase_108 | AC | 1,150 ms
81,756 KB |
testcase_109 | AC | 1,150 ms
81,564 KB |
testcase_110 | AC | 1,150 ms
81,736 KB |
testcase_111 | AC | 1,150 ms
81,688 KB |
testcase_112 | AC | 1,151 ms
81,136 KB |
testcase_113 | AC | 1,150 ms
81,840 KB |
testcase_114 | AC | 1,151 ms
81,660 KB |
testcase_115 | AC | 1,150 ms
81,248 KB |
testcase_116 | AC | 1,150 ms
81,244 KB |
testcase_117 | AC | 1,150 ms
81,364 KB |
testcase_118 | AC | 1,150 ms
81,536 KB |
testcase_119 | AC | 1,151 ms
81,540 KB |
testcase_120 | AC | 1,150 ms
81,160 KB |
testcase_121 | AC | 1,152 ms
80,764 KB |
testcase_122 | AC | 1,150 ms
80,776 KB |
testcase_123 | AC | 1,149 ms
80,824 KB |
testcase_124 | AC | 1,150 ms
81,308 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: 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: tree[lf][0],tree[ri][0]=tree[ri][0],tree[lf][0] 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: tree[lf][2],tree[ri][2]=tree[ri][2],tree[lf][2] 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: tree[lf][1],tree[ri][1]=tree[ri][1],tree[lf][1] for i in tree: print(*(map(lambda x:x+1,i)))