Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- f1 = open('input.txt')
- f2 = open('output.txt', 'w')
- n, m = map(int, f1.readline().split())
- x, y = map(int, f1.readline().split())
- colour = int(f1.readline())
- a = []
- for i in range (n):
- a.append([])
- a[i] = list(map(int, f1.readline().split()))
- if (a[x][y] == colour):
- f2.write(str(0) + '\n')
- for x in a:
- for y in x:
- f2.write(str(y) + ' ')
- f2.write('\n')
- q = []
- was = []
- dx = [0, 1, 0, -1]
- dy = [-1, 0, 1, 0]
- q.append((x, y))
- while (len(q)):
- p = q.pop(0)
- x = p[0]
- y = p[1]
- was[x][y] = 1
- for i in range(4):
- if not(was[x + dx[i]][y + dy[i]]):
- if (a[x + dx[i]][y + dy[i]] ==)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement