Submission #1548728


Source Code Expand

Copy
def LIS(L):
  """数列L→最大増加部分列の長さ
  計算量はN^2"""
  res=0
  dp=[1]*N#最後がa[i] となるような最長の増加部分列の長さ
  for i in range(N):
    for j in range(i):
      if L[j]<L[i]:
        dp[i]=max(dp[i],dp[j]+1)
    res=max(res,dp[i])
  return res
 
import math 
x1,y1,x2,y2=map(int,input().split())
N=int(input())
W=abs(x2-x1)
H=abs(y2-y1)
xsgn=2*(x2>x1)-1
ysgn=2*(y2>y1)-1
XY=[]
for i in range(N):
  x,y=map(int,input().split())
  if (x-x1)*(x-x2)<=0 and (y-y1)*(y-y2)<=0:
    XY+=[[xsgn*(x-x1),ysgn*(y-y1)]]
N=len(XY)
short=20-5*math.pi
long=10*math.pi-20
straight=100*(W+H)
 
XY.sort()
Y = [y for x,y in XY]
 
fountain=LIS(Y)
 
if fountain<min(W,H)+1:
  print(straight-short*fountain)
else:
  print(straight-short*(fountain-1)+long)

Submission Info

Submission Time
Task C - Fountain Walk
User wkb89_
Language Python3 (3.4.3)
Score 0
Code Size 822 Byte
Status
Exec Time 2106 ms
Memory 40224 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 0 / 900 sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt, subtask_1_26.txt, subtask_1_27.txt, subtask_1_28.txt, subtask_1_29.txt, subtask_1_30.txt, subtask_1_31.txt, subtask_1_32.txt, subtask_1_33.txt, subtask_1_34.txt, subtask_1_35.txt, subtask_1_36.txt, subtask_1_37.txt, subtask_1_38.txt, subtask_1_39.txt, subtask_1_40.txt, subtask_1_41.txt
Case Name Status Exec Time Memory
sample_01.txt 17 ms 3064 KB
sample_02.txt 17 ms 3064 KB
sample_03.txt 17 ms 3064 KB
subtask_1_01.txt 17 ms 3064 KB
subtask_1_02.txt 17 ms 3064 KB
subtask_1_03.txt 17 ms 3064 KB
subtask_1_04.txt 17 ms 3064 KB
subtask_1_05.txt 17 ms 3064 KB
subtask_1_06.txt 17 ms 3064 KB
subtask_1_07.txt 17 ms 3064 KB
subtask_1_08.txt 17 ms 3064 KB
subtask_1_09.txt 205 ms 3064 KB
subtask_1_10.txt 419 ms 3064 KB
subtask_1_11.txt 122 ms 3064 KB
subtask_1_12.txt 2106 ms 40140 KB
subtask_1_13.txt 464 ms 3064 KB
subtask_1_14.txt 221 ms 3064 KB
subtask_1_15.txt 116 ms 3064 KB
subtask_1_16.txt 2106 ms 40140 KB
subtask_1_17.txt 373 ms 3064 KB
subtask_1_18.txt 304 ms 3064 KB
subtask_1_19.txt 528 ms 3188 KB
subtask_1_20.txt 2106 ms 40224 KB
subtask_1_21.txt 2106 ms 40164 KB
subtask_1_22.txt 2106 ms 40148 KB
subtask_1_23.txt 2106 ms 40172 KB
subtask_1_24.txt 17 ms 3064 KB
subtask_1_25.txt 17 ms 3064 KB
subtask_1_26.txt 18 ms 3064 KB
subtask_1_27.txt 17 ms 3064 KB
subtask_1_28.txt 2104 ms 4296 KB
subtask_1_29.txt 2104 ms 4052 KB
subtask_1_30.txt 2106 ms 40152 KB
subtask_1_31.txt 2106 ms 39372 KB
subtask_1_32.txt 2106 ms 39448 KB
subtask_1_33.txt 2106 ms 39520 KB
subtask_1_34.txt 2106 ms 39392 KB
subtask_1_35.txt 2106 ms 39584 KB
subtask_1_36.txt 2106 ms 39404 KB
subtask_1_37.txt 2106 ms 39484 KB
subtask_1_38.txt 2106 ms 39576 KB
subtask_1_39.txt 2106 ms 39564 KB
subtask_1_40.txt 2106 ms 39584 KB
subtask_1_41.txt 2106 ms 39400 KB