
 Code Submission Evaluation System 
Login 
CSES  HIIT Open 2018HIIT Open 2018  Contest start:   20180526 11:00:00  Contest end:   20180526 16:00:00    

Task list  Submit code  Submissions  Messages  Scoreboard  Statistics
Show test data
Code
t = int(input())
for _ in range(t):
min_x = (1000, 1000)
min_y = (1000, 1000)
max_x = (1000, 1000)
max_y = (1000, 1000)
res = 4
for y in range(100):
c = input()
for x in range(100):
if c[x] == "1":
if x < min_x[1]:
min_x = (y, x)
if y < min_y[0]:
min_y = (y, x)
if x > max_x[1]:
max_x = (y, x)
if y > max_y[0]:
max_y = (y, x)
# print(min_x[1], min_y[0], max_x[1], max_y[0])
# print(min_x, min_y, max_x, max_y)
diff = 15
if abs(min_x[0]  min_y[0]) <= diff or abs(min_x[0]  max_y[0]) <= diff:
res = 3
if abs(max_x[0]  min_y[0]) <= diff or abs(max_x[0]  max_y[0]) <= diff:
res = 3
if abs(min_y[1]  min_x[1]) <= diff or abs(min_y[1]  max_x[1]) <= diff:
res = 3
if abs(max_y[1]  min_x[1]) <= diff or abs(max_y[1]  max_x[1]) <= diff:
res = 3
print(res)