• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Jun 5th, 2017 181 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import sys
2. import math
3. # Don't let the machines win. You are humanity's last hope...
4.
5. width = int(input())  # the number of cells on the X axis
6. height = int(input())  # the number of cells on the Y axis
7. line = []
8. for i in range(height):
9.     line.append(list(input()))
10.     #print(input())
11. # Write an action using print
12. # To debug: print("Debug messages...", file=sys.stderr)
13. #line = [[["0"],["0"],["0"]]]
15.
17.     if(line[y][x] == "0"):
18.                 answer += (str(x) + " " + str(y) + " ")#(str(i) + " " + str(j) + " ")
19.
20.                 if(line[y][x+1] == "0"):
21.                     answer += (str(x+1) + " " + str(y) + " ")#(str(i) + " " + str(j + 1) + " ")
22.                     #line[i][j+1] = "."
23.                 else:
24.                     answer += ("-1 -1 ")
25.
26.                 if(line[y+1][x] == "0"):
27.                     answer += (str(x) + " " + str(y+1) + ", ")#(str(i+1) + " " + str(j) + " ")
28.                     #line[i+1][j] = "."
29.                 else:
30.                     answer += ("-1 -1, ")
32.
34.     if(line[y][x] == "0"):
35.                 answer += (str(x) + " " + str(y) + " ")#(str(i) + " " + str(j) + " ")
36.                 answer += ("-1 -1 ")
37.
38.                 if(line[y+1][x] == "0"):
39.                     answer += (str(x) + " " + str(y+1) + ", ")#(str(i+1) + " " + str(j) + " ")
40.                     #line[i+1][j] = "."
41.                 else:
42.                     answer += ("-1 -1, ")
44.
46.     if(line[y][x] == "0"):
47.                 answer += (str(x) + " " + str(y) + " ")#(str(i) + " " + str(j) + " ")
48.
49.                 if(line[y][x+1] == "0"):
50.                     answer += (str(x+1) + " " + str(y) + " ")#(str(i) + " " + str(j + 1) + " ")
51.                     #line[i][j+1] = "."
52.                 else:
53.                     answer += ("-1 -1 ")
54.
55.                 answer += ("-1 -1, ")
57.
59.     if(line[y][x] == "0"):
60.                 answer += (str(x) + " " + str(y) + " ")#(str(i) + " " + str(j) + " ")
61.                 answer += ("-1 -1 ")
62.                 answer += ("-1 -1, ")
64.
65.
66. for y in range(height):
67.     for x in range(width):
68.         if(y < (height-1) and x < (width-1)):
70.         elif(x == (width-1) and y < (height-1)):
72.         elif(y == (height-1) and x < (width-1)):
74.         elif(y == (height-1) and x == (width-1)):