import sys
input = sys.stdin.readline
t,n,k1,k2=list(map(int,input().split()))
m=[]
if t<=2:
sw=1
else:
sw=6
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
for j in range(nn+1):
for k in range(nn*nn//2+1-j):
if d[i][j][k+j]>d[i+1][j][k]+a:
d[i][j][k+j]=d[i+1][j][k]+a
if d[i+1][j][k]<d[i+1][j+1][k]:
d[i+1][j+1][k]=d[i+1][j][k]
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(n):
while j>0 and d[i][j-1][k]==d[i][j][k]:
j-=1
v[i]=j
k-=j
if j==0:
break
#print(*v)
for i in range(n):
for j in range(nn):
if v[i//sw]>j:
print("0 "*sw,end="")
else:
print("1 "*sw,end="")
print()
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
3028 KB |
K = 17 |
2 |
Execution timed out |
2077 ms |
36080 KB |
Time limit exceeded |
3 |
Execution timed out |
2080 ms |
39904 KB |
Time limit exceeded |
4 |
Execution timed out |
2078 ms |
40212 KB |
Time limit exceeded |
5 |
Execution timed out |
2076 ms |
39252 KB |
Time limit exceeded |
6 |
Execution timed out |
2082 ms |
44772 KB |
Time limit exceeded |
7 |
Execution timed out |
2083 ms |
41416 KB |
Time limit exceeded |
8 |
Execution timed out |
2101 ms |
44288 KB |
Time limit exceeded |
9 |
Execution timed out |
2036 ms |
39640 KB |
Time limit exceeded |
10 |
Execution timed out |
2084 ms |
40580 KB |
Time limit exceeded |