-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaac4p4.py
55 lines (53 loc) · 1.2 KB
/
aac4p4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import sys
input = sys.stdin.readline
n, m, s, f, l, r = [int(x) for x in input().split()]
throw = [int(x) for x in input().split()]
kM = 0
for i in range(m):
if throw[i] == f:
kM = i + 1
p = [[0] * m for _ in range(n)]
total = 0
if f != s and f not in throw:
print(-1)
sys.exit()
if r == 0:
if f != s:
print(-1)
else:
print(total)
[print(" ".join([str(x) for x in y])) for y in p]
sys.exit()
if kM != 0:
total += 1
p[s - 1][kM - 1] = 1
for i in range(1, n + 1):
if total >= l or i == s:
continue
p[i - 1][kM - 1] = 1
total += 1
for i in range(1, n + 1):
for j in range(1, kM):
if total >= l:
continue
assert p[i - 1][j - 1] == 0
p[i - 1][j - 1] = 1
total += 1
for i in range(1, n + 1):
if i == f:
continue
for j in range(kM + 1, m + 1):
if total >= l:
continue
assert p[i - 1][j - 1] == 0
p[i - 1][j - 1] = 1
total += 1
if total < l or total > r:
print(-1)
else:
s = 0
for i in p:
s += i.count(1)
assert s == total
print(total)
[print(" ".join([str(x) for x in y])) for y in p]