結果
問題 | No.2696 Sign Creation |
ユーザー | katonyonko |
提出日時 | 2024-08-10 12:08:30 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,845 bytes |
コンパイル時間 | 591 ms |
コンパイル使用メモリ | 82,280 KB |
実行使用メモリ | 176,248 KB |
最終ジャッジ日時 | 2024-08-10 12:08:39 |
合計ジャッジ時間 | 8,780 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
56,576 KB |
testcase_01 | AC | 63 ms
56,764 KB |
testcase_02 | AC | 44 ms
56,852 KB |
testcase_03 | AC | 40 ms
56,476 KB |
testcase_04 | AC | 40 ms
56,448 KB |
testcase_05 | AC | 41 ms
55,560 KB |
testcase_06 | AC | 40 ms
56,492 KB |
testcase_07 | AC | 40 ms
55,856 KB |
testcase_08 | AC | 142 ms
79,492 KB |
testcase_09 | AC | 41 ms
55,564 KB |
testcase_10 | AC | 123 ms
78,984 KB |
testcase_11 | AC | 42 ms
57,100 KB |
testcase_12 | AC | 41 ms
56,516 KB |
testcase_13 | AC | 435 ms
110,656 KB |
testcase_14 | AC | 274 ms
105,020 KB |
testcase_15 | AC | 247 ms
101,772 KB |
testcase_16 | AC | 401 ms
108,040 KB |
testcase_17 | AC | 40 ms
56,360 KB |
testcase_18 | AC | 195 ms
85,236 KB |
testcase_19 | AC | 252 ms
100,684 KB |
testcase_20 | AC | 50 ms
65,156 KB |
testcase_21 | AC | 260 ms
99,332 KB |
testcase_22 | AC | 153 ms
82,884 KB |
testcase_23 | AC | 259 ms
95,012 KB |
testcase_24 | AC | 288 ms
95,120 KB |
testcase_25 | AC | 251 ms
105,716 KB |
testcase_26 | AC | 78 ms
76,972 KB |
testcase_27 | AC | 126 ms
90,992 KB |
testcase_28 | AC | 132 ms
93,060 KB |
testcase_29 | AC | 52 ms
68,632 KB |
testcase_30 | AC | 59 ms
70,776 KB |
testcase_31 | AC | 1,184 ms
176,248 KB |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | AC | 47 ms
65,176 KB |
testcase_35 | AC | 40 ms
55,240 KB |
testcase_36 | AC | 38 ms
56,264 KB |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | AC | 39 ms
55,892 KB |
testcase_40 | AC | 39 ms
56,936 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 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)