結果
問題 | No.5019 Hakai Project |
ユーザー | hirayuu_yc |
提出日時 | 2023-10-20 18:38:07 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,080 ms / 3,000 ms |
コード長 | 4,197 bytes |
コンパイル時間 | 154 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 79,024 KB |
スコア | 1,637,160,602 |
最終ジャッジ日時 | 2023-11-17 09:32:21 |
合計ジャッジ時間 | 53,063 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 967 ms
78,468 KB |
testcase_01 | AC | 919 ms
78,460 KB |
testcase_02 | AC | 937 ms
78,356 KB |
testcase_03 | AC | 819 ms
78,500 KB |
testcase_04 | AC | 986 ms
78,992 KB |
testcase_05 | AC | 919 ms
78,348 KB |
testcase_06 | AC | 851 ms
78,340 KB |
testcase_07 | AC | 1,016 ms
78,780 KB |
testcase_08 | AC | 946 ms
78,528 KB |
testcase_09 | AC | 915 ms
78,508 KB |
testcase_10 | AC | 867 ms
78,476 KB |
testcase_11 | AC | 911 ms
78,464 KB |
testcase_12 | AC | 1,017 ms
78,772 KB |
testcase_13 | AC | 898 ms
78,440 KB |
testcase_14 | AC | 945 ms
79,024 KB |
testcase_15 | AC | 886 ms
78,468 KB |
testcase_16 | AC | 932 ms
78,360 KB |
testcase_17 | AC | 870 ms
78,380 KB |
testcase_18 | AC | 972 ms
78,312 KB |
testcase_19 | AC | 983 ms
78,924 KB |
testcase_20 | AC | 978 ms
78,496 KB |
testcase_21 | AC | 828 ms
78,520 KB |
testcase_22 | AC | 902 ms
78,384 KB |
testcase_23 | AC | 884 ms
78,528 KB |
testcase_24 | AC | 1,030 ms
78,520 KB |
testcase_25 | AC | 959 ms
78,372 KB |
testcase_26 | AC | 966 ms
78,332 KB |
testcase_27 | AC | 845 ms
78,408 KB |
testcase_28 | AC | 899 ms
78,848 KB |
testcase_29 | AC | 786 ms
78,404 KB |
testcase_30 | AC | 936 ms
78,328 KB |
testcase_31 | AC | 963 ms
78,716 KB |
testcase_32 | AC | 1,080 ms
78,448 KB |
testcase_33 | AC | 948 ms
78,352 KB |
testcase_34 | AC | 916 ms
78,328 KB |
testcase_35 | AC | 900 ms
78,488 KB |
testcase_36 | AC | 937 ms
78,296 KB |
testcase_37 | AC | 925 ms
78,872 KB |
testcase_38 | AC | 900 ms
78,424 KB |
testcase_39 | AC | 938 ms
78,404 KB |
testcase_40 | AC | 1,002 ms
78,316 KB |
testcase_41 | AC | 982 ms
78,472 KB |
testcase_42 | AC | 1,075 ms
78,448 KB |
testcase_43 | AC | 976 ms
78,408 KB |
testcase_44 | AC | 953 ms
78,372 KB |
testcase_45 | AC | 944 ms
78,504 KB |
testcase_46 | AC | 903 ms
78,508 KB |
testcase_47 | AC | 938 ms
78,320 KB |
testcase_48 | AC | 901 ms
79,000 KB |
testcase_49 | AC | 1,012 ms
78,496 KB |
ソースコード
from copy import deepcopy N,M=map(int,input().split()) A=[] for i in range(N): A.append(list(input())) bomb=[] maxi=0 num=0 for i in range(M): C,L=map(int,input().split()) bomb.append([C,[]]) if maxi<L: maxi=L num=i for j in range(L): bomb[-1][-1].append(tuple(map(int,input().split()))) ap=deepcopy(A) x=-1 y=-1 near=998244353 for i in range(N): for j in range(N): if A[i][j]=="@": if near>i+j: near=i+j x=i y=j use=[] while True: maxi=0 xp=-1 yp=-1 for i in range(N): for j in range(N): cnt=0 for k,l in bomb[num][1]: if 0<=i+k<N and 0<=j+l<N: if A[i+k][j+l]!=".": cnt+=1 if cnt>maxi: maxi=cnt xp=i yp=j if xp==-1: break use.append((xp,yp)) for k,l in bomb[num][1]: if 0<=xp+k<N and 0<=yp+l<N: A[xp+k][yp+l]="." ans=[] for i in range(x): ans.append([1,"D"]) for i in range(y): ans.append([1,"R"]) for i in range(len(use)): ans.append([2,num+1]) used=set() for i in range(len(use)): go=-1 near=998244353 for j in range(len(use)): if j in used: continue if near>abs(x-use[j][0])+abs(y-use[j][1]): near=abs(x-use[j][0])+abs(y-use[j][1]) go=j for i in range(use[go][0]-x): ans.append([1,"D"]) for i in range(x-use[go][0]): ans.append([1,"U"]) for i in range(use[go][1]-y): ans.append([1,"R"]) for i in range(y-use[go][1]): ans.append([1,"L"]) x=use[go][0] y=use[go][1] ans.append([3,num+1]) used.add(go) a2=ans[:] A=deepcopy(ap) posx=0 posy=0 ans=[] for a in range(2): for b in range(2): lf=a*25 ri=25+lf up=(a^b)*25 dn=25+up use=[] x=-1 y=-1 near=998244353 for i in range(N): for j in range(N): if A[i][j]=="@": if near>abs(posx-i)+abs(posy-j): near=abs(posx-i)+abs(posy-j) x=i y=j if x==-1: print(len(a2)) for i in a2: print(*i) exit() for i in range(x-posx): ans.append([1,"D"]) for i in range(y-posy): ans.append([1,"R"]) for i in range(posx-x): ans.append([1,"U"]) for i in range(posy-y): ans.append([1,"L"]) while True: maxi=0 xp=-1 yp=-1 for i in range(up,dn): for j in range(lf,ri): cnt=0 for k,l in bomb[num][1]: if up<=i+k<dn and lf<=j+l<ri: if A[i+k][j+l]!=".": cnt+=1 if cnt>maxi: maxi=cnt xp=i yp=j if xp==-1: break use.append((xp,yp)) for k,l in bomb[num][1]: if 0<=xp+k<N and 0<=yp+l<N: A[xp+k][yp+l]="." for i in range(len(use)): ans.append([2,num+1]) used=set() for i in range(len(use)): go=-1 near=998244353 for j in range(len(use)): if j in used: continue if near>abs(x-use[j][0])+abs(y-use[j][1]): near=abs(x-use[j][0])+abs(y-use[j][1]) go=j for i in range(use[go][0]-x): ans.append([1,"D"]) for i in range(x-use[go][0]): ans.append([1,"U"]) for i in range(use[go][1]-y): ans.append([1,"R"]) for i in range(y-use[go][1]): ans.append([1,"L"]) x=use[go][0] y=use[go][1] ans.append([3,num+1]) used.add(go) posx=x posy=y print(len(ans)) for i in ans: print(*i)