Lang:Python2
Edit12345678910111213141516171819202122232425262728293031import sysfrom sets import Settimes = 0X = 0Y = 0def cal_hash(X, Y):return X * 1001 + Ydef work():line = raw_input()times = int(line)S = Set()count = 0for i in range(times):line = raw_input()line = input()X = int(line.split()[0])Y = int(line.split()[1])count += 1dir = Set()dir.add(cal_hash(X, Y-1))dir.add(cal_hash(X, Y+1))dir.add(cal_hash(X-1, Y))dir.add(cal_hash(X+1, Y))count -= len(S & dir)S.add(cal_hash(X, Y))print countif __name__ == "__main__":