# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
632373 |
2022-08-19T22:00:22 Z |
karolb2011 |
Coins (LMIO19_monetos) |
Python 3 |
|
1438 ms |
262144 KB |
import sys
input = sys.stdin.readline
t,n,k1,k2=list(map(int,input().split()))
m=[]
if t<=2:
sw=1
else:
sw=3
nn=n//sw
ssw=sw*sw
mm=[[0 for i in range(nn)]for j in range(nn)]
for i in range(n):
mx=list(map(int,input().split()))
for j in range(n):
mm[i//sw][j//sw]+=mx[j]
d=[[[1000000 for _ in range(nn*nn//2+1)]for _ in range(nn+2)]for _ in range(nn+1)]
d[nn][0][0]=0
for i in reversed(range(nn)):
a=0
di=d[i]
dip=d[i+1]
for j in range(nn+1):
dij=di[j]
dipj=dip[j]
dipjp=dip[j+1]
ma=nn*nn//2+1-j*(i+1)
mi=max(0,nn*nn//2-(i+1)*nn)
for k in range(mi,ma):
dk=dipj[k]
if dij[k+j]>dk+a:
dij[k+j]=dk+a
if dipjp[k]>dk:
dipjp[k]=dk
if j<nn:
a+=mm[i][j]
v=[0 for _ in range(nn)]
k=nn*nn//2
dm=1000000
for j in range(nn+1):
if d[0][j][k]<dm:
dm=d[0][j][k]
jj=j
j=jj
for i in range(nn):
if i>0:
while j>0 and d[i][j-1][k]==d[i][j][k]:
j-=1
v[i]=j
k-=j
if j==0:
break
for i in range(n):
ss=""
for j in range(nn):
if v[i//sw]>j:
ss+="0 "*sw
else:
ss+="1 "*sw
ss+="\n"
sys.stdout.write(ss)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
3020 KB |
K = 17 |
2 |
Correct |
662 ms |
34708 KB |
K = 576 |
3 |
Runtime error |
1438 ms |
262144 KB |
Execution killed with signal 9 |
4 |
Runtime error |
1432 ms |
262144 KB |
Execution killed with signal 9 |
5 |
Runtime error |
1431 ms |
262144 KB |
Execution killed with signal 9 |
6 |
Runtime error |
1404 ms |
262144 KB |
Execution killed with signal 9 |
7 |
Runtime error |
1378 ms |
262144 KB |
Execution killed with signal 9 |
8 |
Runtime error |
1388 ms |
262144 KB |
Execution killed with signal 9 |
9 |
Runtime error |
1403 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Runtime error |
1392 ms |
262144 KB |
Execution killed with signal 9 |