結果
問題 | No.2696 Sign Creation |
ユーザー | katonyonko |
提出日時 | 2024-08-10 12:11:00 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,225 ms / 2,500 ms |
コード長 | 2,868 bytes |
コンパイル時間 | 289 ms |
コンパイル使用メモリ | 82,160 KB |
実行使用メモリ | 176,632 KB |
最終ジャッジ日時 | 2024-08-10 12:11:09 |
合計ジャッジ時間 | 7,984 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
55,444 KB |
testcase_01 | AC | 48 ms
55,424 KB |
testcase_02 | AC | 46 ms
55,424 KB |
testcase_03 | AC | 44 ms
55,808 KB |
testcase_04 | AC | 46 ms
55,680 KB |
testcase_05 | AC | 44 ms
55,552 KB |
testcase_06 | AC | 43 ms
55,552 KB |
testcase_07 | AC | 49 ms
55,808 KB |
testcase_08 | AC | 150 ms
79,612 KB |
testcase_09 | AC | 47 ms
55,552 KB |
testcase_10 | AC | 129 ms
79,224 KB |
testcase_11 | AC | 44 ms
55,424 KB |
testcase_12 | AC | 47 ms
55,424 KB |
testcase_13 | AC | 436 ms
110,400 KB |
testcase_14 | AC | 306 ms
105,060 KB |
testcase_15 | AC | 274 ms
101,908 KB |
testcase_16 | AC | 420 ms
108,060 KB |
testcase_17 | AC | 44 ms
56,064 KB |
testcase_18 | AC | 178 ms
85,360 KB |
testcase_19 | AC | 276 ms
100,944 KB |
testcase_20 | AC | 55 ms
64,640 KB |
testcase_21 | AC | 276 ms
99,348 KB |
testcase_22 | AC | 177 ms
83,136 KB |
testcase_23 | AC | 282 ms
94,840 KB |
testcase_24 | AC | 284 ms
95,244 KB |
testcase_25 | AC | 268 ms
105,756 KB |
testcase_26 | AC | 101 ms
77,056 KB |
testcase_27 | AC | 132 ms
91,392 KB |
testcase_28 | AC | 142 ms
92,948 KB |
testcase_29 | AC | 62 ms
67,328 KB |
testcase_30 | AC | 65 ms
69,248 KB |
testcase_31 | AC | 1,225 ms
176,632 KB |
testcase_32 | AC | 43 ms
55,692 KB |
testcase_33 | AC | 44 ms
55,560 KB |
testcase_34 | AC | 51 ms
64,128 KB |
testcase_35 | AC | 47 ms
55,552 KB |
testcase_36 | AC | 45 ms
55,168 KB |
testcase_37 | AC | 46 ms
55,424 KB |
testcase_38 | AC | 44 ms
55,296 KB |
testcase_39 | AC | 46 ms
55,552 KB |
testcase_40 | AC | 45 ms
55,672 KB |
ソースコード
import io import sys from collections import defaultdict, deque, Counter from itertools import permutations, combinations, accumulate from heapq import heappush, heappop from bisect import bisect_right, bisect_left from math import gcd import math from sys import stdout _INPUT = """\ 6 10 10 5 2 1 4 2 3 3 3 6 3 6 2 10 10 2 2 3 3 6 3 1 5 4 4 1 1 1 2 1 3 1 4 """ def input(): return sys.stdin.readline()[:-1] def solve(test): H,W,N,D=map(int,input().split()) A=[list(map(int,input().split())) for _ in range(N)] B=[A[i][0]*10**6+A[i][1] for i in range(N)] C={B[i]:i for i in range(N)} G=[[] for _ in range(N)] for i in range(N): for j in range(-D,D+1): for k in range(-(D-abs(j)),(D-abs(j))+1): if (j==0 and k==0) or A[i][0]+j<=0 or A[i][0]+j>H or A[i][1]+k<=0 or A[i][1]+k>W: continue if (A[i][0]+j)*10**6+A[i][1]+k in C: G[i].append(C[(A[i][0]+j)*10**6+A[i][1]+k]) d=defaultdict(int) for i in range(N): if len(G[i])==0: for j in range(-D,D+1): for k in range(-(D-abs(j)),(D-abs(j))+1): if (j==0 and k==0) or A[i][0]+j<=0 or A[i][0]+j>H or A[i][1]+k<=0 or A[i][1]+k>W: continue d[(A[i][0]+j)*10**6+A[i][1]+k]=1 inf=10**9 depth=[inf]*N now=0 for i in range(N): if depth[i]!=inf or len(G[i])==0: continue tmp=set() depth[i]=now Q=deque([i]) while Q: v=Q.popleft() for j in range(-D,D+1): for k in range(-(D-abs(j)),(D-abs(j))+1): if (j==0 and k==0) or A[v][0]+j<=0 or A[v][0]+j>H or A[v][1]+k<=0 or A[v][1]+k>W: continue tmp.add((A[v][0]+j)*10**6+A[v][1]+k) for u in G[v]: if depth[u]==inf: depth[u]=now Q.append(u) now+=1 for x in tmp: if x in d: d[x]-=1 else: d[x]=0 if H*W>100*N: flg=1 else: flg=0 for i in range(1,H+1): for j in range(1,W+1): if i*10**6+j not in d: flg=1 break if len(d)==0: d[0]=0 if flg==1: print(now+min(min(d.values()),0),now+max(max(d.values()),0)) else: print(now+min(d.values()),now+max(d.values())) def random_input(): from random import randint,shuffle N=randint(1,10) M=randint(1,N) A=list(range(1,M+1))+[randint(1,M) for _ in range(N-M)] shuffle(A) return (" ".join(map(str, [N,M]))+"\n"+" ".join(map(str, A))+"\n")*3 def simple_solve(): return [] def main(test): if test==0: solve(0) elif test==1: sys.stdin = io.StringIO(_INPUT) case_no=int(input()) for _ in range(case_no): solve(0) else: for i in range(1000): sys.stdin = io.StringIO(random_input()) x=solve(1) y=simple_solve() if x!=y: print(i,x,y) print(*[line for line in sys.stdin],sep='') break #0:提出用、1:与えられたテスト用、2:ストレステスト用 main(0)