node_ids
listlengths 4
1.4k
| edge_index
listlengths 1
2.22k
| text
listlengths 4
1.4k
| source
stringlengths 14
427k
|
---|---|---|---|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
18,
4,
13,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13
] |
[
[
43,
2
],
[
43,
11
],
[
46,
13
],
[
17,
16
],
[
41,
19
],
[
37,
21
],
[
38,
30
],
[
47,
30
],
[
41,
33
],
[
44,
34
],
[
37,
38
],
[
43,
41
],
[
43,
44
],
[
46,
47
]
] |
[
"#!/usr/bin/env python3\n\nH, W = map(int, input().split())\ncnt = 0\nfor i in range(H):\n cnt += input().count('#')\n\nif cnt == H+W-1: print('Possible')\nelse: print('Impossible')\n",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"cnt = 0",
"cnt",
"0",
"for i in range(H):\n cnt += input().count('#')",
"i",
"range(H)",
"range",
"H",
"cnt += input().count('#')",
"cnt",
"input().count('#')",
"().count",
"()",
"input",
"count",
"'#'",
"if cnt == H+W-1: print('Possible')\nelse: print('Impossible')",
"cnt == H+W-1",
"cnt",
"H+W-1",
"H+W",
"H",
"W",
"1",
"cnt += input().count('#')",
"input().count('#')",
"cnt",
"H, W = map(int, input().split())",
"map(int, input().split())",
"H",
"W = map(int, input().split())",
"map(int, input().split())",
"W",
"cnt = 0",
"0",
"cnt"
] |
#!/usr/bin/env python3
H, W = map(int, input().split())
cnt = 0
for i in range(H):
cnt += input().count('#')
if cnt == H+W-1: print('Possible')
else: print('Impossible')
|
[
7,
15,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
18,
4,
13,
13,
17,
4,
13,
8,
2,
13,
2,
2,
13,
13,
17,
17,
17,
10,
18,
13,
10,
4,
13,
10,
18,
13,
10,
4,
13,
10,
18,
13,
10,
4,
13
] |
[
[
74,
4
],
[
68,
13
],
[
62,
22
],
[
77,
31
],
[
69,
38
],
[
77,
40
],
[
71,
42
],
[
75,
46
],
[
72,
53
],
[
66,
56
],
[
78,
57
],
[
62,
63
],
[
77,
66
],
[
68,
69
],
[
71,
72
],
[
74,
75
],
[
77,
78
]
] |
[
"import sys\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nH, W = map(int, readline().split())\nn = read().count(b'#')\nprint('Possible' if n == H + W - 1 else 'Impossible')",
"import sys",
"sys",
"read = sys.stdin.buffer.read",
"read",
"sys.stdin.buffer.read",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"read",
"readline = sys.stdin.buffer.readline",
"readline",
"sys.stdin.buffer.readline",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readline",
"readlines = sys.stdin.buffer.readlines",
"readlines",
"sys.stdin.buffer.readlines",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readlines",
"H, W = map(int, readline().split())",
"H",
"map(int, readline().split())",
"map",
"int",
"readline().split()",
"().split",
"()",
"readline",
"split",
"W",
"n = read().count(b'#')",
"n",
"read().count(b'#')",
"().count",
"()",
"read",
"count",
"b'#'",
"print('Possible' if n == H + W - 1 else 'Impossible')",
"print",
"'Possible' if n == H + W - 1 else 'Impossible'",
"n == H + W - 1",
"n",
"H + W - 1",
"H + W",
"H",
"W",
"1",
"'Possible'",
"'Impossible'",
"readlines = sys.stdin.buffer.readlines",
"sys.stdin.buffer.readlines",
"readlines",
"H, W = map(int, readline().split())",
"map(int, readline().split())",
"H",
"readline = sys.stdin.buffer.readline",
"sys.stdin.buffer.readline",
"readline",
"n = read().count(b'#')",
"read().count(b'#')",
"n",
"read = sys.stdin.buffer.read",
"sys.stdin.buffer.read",
"read",
"W = map(int, readline().split())",
"map(int, readline().split())",
"W"
] |
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
H, W = map(int, readline().split())
n = read().count(b'#')
print('Possible' if n == H + W - 1 else 'Impossible')
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
4,
13,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
39,
13,
10,
17,
13
] |
[
[
70,
2
],
[
70,
11
],
[
76,
13
],
[
17,
16
],
[
71,
19
],
[
77,
22
],
[
73,
29
],
[
33,
32
],
[
71,
35
],
[
38,
37
],
[
68,
40
],
[
77,
45
],
[
32,
46
],
[
37,
47
],
[
79,
50
],
[
80,
54
],
[
74,
54
],
[
71,
57
],
[
68,
58
],
[
70,
68
],
[
70,
71
],
[
73,
74
],
[
76,
77
],
[
79,
80
]
] |
[
"h,w = map(int,input().split())\ns = []\nfor i in range(h):\n s.append(list(input()))\nans = 0\nfor i in range(h):\n for j in range(w):\n if s[i][j] == \"#\":\n ans += 1\nif ans == h+w-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"h,w = map(int,input().split())",
"h",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"s = []",
"s",
"[]",
"for i in range(h):\n s.append(list(input()))",
"i",
"range(h)",
"range",
"h",
"s.append(list(input()))",
"s.append",
"s",
"append",
"list(input())",
"list",
"input()",
"input",
"ans = 0",
"ans",
"0",
"for i in range(h):\n for j in range(w):\n if s[i][j] == \"#\":\n ans += 1",
"i",
"range(h)",
"range",
"h",
"for j in range(w):\n if s[i][j] == \"#\":\n ans += 1",
"j",
"range(w)",
"range",
"w",
"if s[i][j] == \"#\":\n ans += 1",
"s[i][j] == \"#\"",
"s[i][j]",
"[i]",
"s",
"i",
"j",
"\"#\"",
"ans += 1",
"ans",
"1",
"if ans == h+w-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"ans == h+w-1",
"ans",
"h+w-1",
"h+w",
"h",
"w",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"w = map(int,input().split())",
"map(int,input().split())",
"w",
"h,w = map(int,input().split())",
"map(int,input().split())",
"h",
"ans = 0",
"0",
"ans",
"s = []",
"[]",
"s",
"ans += 1",
"1",
"ans"
] |
h,w = map(int,input().split())
s = []
for i in range(h):
s.append(list(input()))
ans = 0
for i in range(h):
for j in range(w):
if s[i][j] == "#":
ans += 1
if ans == h+w-1:
print("Possible")
else:
print("Impossible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
13,
13
] |
[
[
74,
2
],
[
74,
11
],
[
15,
14
],
[
75,
17
],
[
77,
24
],
[
68,
27
],
[
31,
30
],
[
75,
33
],
[
36,
35
],
[
66,
38
],
[
78,
43
],
[
30,
44
],
[
35,
45
],
[
71,
48
],
[
72,
52
],
[
69,
52
],
[
75,
55
],
[
66,
56
],
[
74,
66
],
[
68,
69
],
[
71,
72
],
[
74,
75
],
[
77,
78
]
] |
[
"h, w = map(int, input().split())\n\nfield = [list(input()) for i in range(h)]\n\ncnt = 0\n\nfor i in range(h):\n for j in range(w):\n if field[i][j] == '#':\n cnt += 1\n\nif cnt == h + w - 1:\n print('Possible')\nelse:\n print('Impossible')",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"list(input()) for i in range(h)",
"for i in range(h)",
"i",
"range(h)",
"range",
"h",
"for i in range(h)",
"list(input())",
"list",
"input()",
"input",
"field = [list(input()) for i in range(h)]",
"field",
"[list(input()) for i in range(h)]",
"cnt = 0",
"cnt",
"0",
"for i in range(h):\n for j in range(w):\n if field[i][j] == '#':\n cnt += 1",
"i",
"range(h)",
"range",
"h",
"for j in range(w):\n if field[i][j] == '#':\n cnt += 1",
"j",
"range(w)",
"range",
"w",
"if field[i][j] == '#':\n cnt += 1",
"field[i][j] == '#'",
"field[i][j]",
"[i]",
"field",
"i",
"j",
"'#'",
"cnt += 1",
"cnt",
"1",
"if cnt == h + w - 1:\n print('Possible')\nelse:\n print('Impossible')",
"cnt == h + w - 1",
"cnt",
"h + w - 1",
"h + w",
"h",
"w",
"1",
"print('Possible')",
"print",
"'Possible'",
"print('Impossible')",
"print",
"'Impossible'",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"cnt = 0",
"0",
"cnt",
"cnt += 1",
"1",
"cnt",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h",
"field = [list(input()) for i in range(h)]",
"[list(input()) for i in range(h)]",
"field"
] |
h, w = map(int, input().split())
field = [list(input()) for i in range(h)]
cnt = 0
for i in range(h):
for j in range(w):
if field[i][j] == '#':
cnt += 1
if cnt == h + w - 1:
print('Possible')
else:
print('Impossible')
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
28,
13,
13,
14,
2,
13,
17,
0,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13
] |
[
[
63,
2
],
[
63,
11
],
[
57,
13
],
[
17,
16
],
[
64,
19
],
[
60,
21
],
[
28,
27
],
[
61,
27
],
[
27,
31
],
[
54,
34
],
[
55,
38
],
[
58,
38
],
[
64,
41
],
[
52,
42
],
[
63,
52
],
[
54,
55
],
[
57,
58
],
[
60,
61
],
[
63,
64
]
] |
[
"H,W=(map(int,input().split()))\ncount=0\nfor i in range(H):\n a=list(input())\n for i in a:\n if i=='#':\n count+=1\nif count==H+W-1:\n print('Possible')\nelse:\n print('Impossible')",
"H,W=(map(int,input().split()))",
"H",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"count=0",
"count",
"0",
"for i in range(H):\n a=list(input())\n for i in a:\n if i=='#':\n count+=1",
"i",
"range(H)",
"range",
"H",
"a=list(input())",
"a",
"list(input())",
"list",
"input()",
"input",
"for i in a:\n if i=='#':\n count+=1",
"i",
"a",
"if i=='#':\n count+=1",
"i=='#'",
"i",
"'#'",
"count+=1",
"count",
"1",
"if count==H+W-1:\n print('Possible')\nelse:\n print('Impossible')",
"count==H+W-1",
"count",
"H+W-1",
"H+W",
"H",
"W",
"1",
"print('Possible')",
"print",
"'Possible'",
"print('Impossible')",
"print",
"'Impossible'",
"W=(map(int,input().split()))",
"map(int,input().split())",
"W",
"count+=1",
"1",
"count",
"count=0",
"0",
"count",
"a=list(input())",
"list(input())",
"a",
"H,W=(map(int,input().split()))",
"map(int,input().split())",
"H"
] |
H,W=(map(int,input().split()))
count=0
for i in range(H):
a=list(input())
for i in a:
if i=='#':
count+=1
if count==H+W-1:
print('Possible')
else:
print('Impossible')
|
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
12,
13,
41,
28,
13,
13,
28,
13,
13,
4,
13,
29,
13,
23,
13,
12,
13,
41,
0,
18,
18,
13,
13,
13,
17,
14,
2,
2,
13,
13,
2,
13,
13,
0,
13,
4,
13,
13,
0,
13,
2,
17,
13,
14,
2,
18,
18,
13,
13,
2,
13,
17,
17,
4,
13,
13,
2,
13,
17,
14,
2,
18,
18,
13,
2,
13,
17,
13,
17,
4,
13,
2,
13,
17,
13,
0,
18,
18,
13,
13,
13,
17,
23,
13,
23,
13,
12,
13,
41,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
4,
18,
13,
13,
2,
39,
17,
2,
13,
17,
28,
13,
4,
13,
13,
4,
18,
13,
13,
2,
2,
39,
17,
4,
13,
18,
4,
13,
39,
17,
39,
17,
4,
18,
13,
13,
2,
39,
17,
2,
13,
17,
0,
13,
17,
4,
13,
17,
17,
14,
13,
4,
13,
17,
4,
13,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
18,
13,
10,
12,
13,
10,
12,
13
] |
[
[
180,
4
],
[
15,
14
],
[
24,
14
],
[
18,
17
],
[
14,
17
],
[
17,
20
],
[
24,
24
],
[
34,
29
],
[
93,
32
],
[
95,
33
],
[
93,
38
],
[
95,
41
],
[
45,
44
],
[
184,
46
],
[
50,
49
],
[
44,
52
],
[
93,
58
],
[
95,
60
],
[
93,
65
],
[
95,
67
],
[
93,
75
],
[
95,
77
],
[
93,
82
],
[
95,
84
],
[
91,
86
],
[
93,
89
],
[
95,
90
],
[
93,
93
],
[
95,
95
],
[
101,
100
],
[
181,
107
],
[
101,
109
],
[
112,
111
],
[
111,
115
],
[
109,
121
],
[
125,
124
],
[
100,
127
],
[
111,
130
],
[
181,
140
],
[
111,
147
],
[
109,
153
],
[
157,
156
],
[
178,
159
],
[
187,
175
],
[
180,
181
]
] |
[
"import sys\n\nreadline = sys.stdin.readline\n\ndef flatten_2dim(array):\n return [item for sublist in array for item in sublist]\n\n\ndef dfs(i, j):\n global flag, grid\n grid[i][j] = '.'\n if i == H and j == W:\n fgrid = flatten_2dim(grid)\n flag = ('#' in fgrid)\n if grid[i][j+1] == '#':\n dfs(i, j+1)\n if grid[i+1][j] == '#':\n dfs(i+1, j)\n grid[i][j] = '#'\n\n\ndef main():\n global H, W, grid, flag\n H, W = map(int, readline().split())\n grid = []\n grid.append(['.']*(W+2))\n for _ in range(H):\n grid.append(['.'] + list(readline()[:-1]) + ['.'])\n grid.append(['.']*(W+2))\n flag = True\n dfs(1, 1)\n\n if flag:\n print('Impossible')\n else:\n print('Possible')\n\n\nif __name__ == \"__main__\":\n main()",
"import sys",
"sys",
"readline = sys.stdin.readline",
"readline",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"def flatten_2dim(array):\n return [item for sublist in array for item in sublist]",
"flatten_2dim",
"item for sublist in array for item in sublist",
"for sublist in array for item in sublist",
"sublist",
"array",
"for item in sublist",
"item",
"sublist",
"for item in sublist",
"item",
"return [item for sublist in array for item in sublist]",
"[item for sublist in array for item in sublist]",
"array",
"array",
"def dfs(i, j):\n global flag, grid\n grid[i][j] = '.'\n if i == H and j == W:\n fgrid = flatten_2dim(grid)\n flag = ('#' in fgrid)\n if grid[i][j+1] == '#':\n dfs(i, j+1)\n if grid[i+1][j] == '#':\n dfs(i+1, j)\n grid[i][j] = '#'",
"dfs",
"global flag, grid",
"grid[i][j] = '.'",
"grid[i][j]",
"[i]",
"grid",
"i",
"j",
"'.'",
"if i == H and j == W:\n fgrid = flatten_2dim(grid)\n flag = ('#' in fgrid)\n ",
"i == H and j == W",
"i == H",
"i",
"H",
"j == W",
"j",
"W",
"fgrid = flatten_2dim(grid)",
"fgrid",
"flatten_2dim(grid)",
"flatten_2dim",
"grid",
"flag = ('#' in fgrid)",
"flag",
"'#' in fgrid",
"'#'",
"fgrid",
"if grid[i][j+1] == '#':\n dfs(i, j+1)\n ",
"grid[i][j+1] == '#'",
"grid[i][j+1]",
"[i]",
"grid",
"i",
"j+1",
"j",
"1",
"'#'",
"dfs(i, j+1)",
"dfs",
"i",
"j+1",
"j",
"1",
"if grid[i+1][j] == '#':\n dfs(i+1, j)\n ",
"grid[i+1][j] == '#'",
"grid[i+1][j]",
"[i+1]",
"grid",
"i+1",
"i",
"1",
"j",
"'#'",
"dfs(i+1, j)",
"dfs",
"i+1",
"i",
"1",
"j",
"grid[i][j] = '#'",
"grid[i][j]",
"[i]",
"grid",
"i",
"j",
"'#'",
"i",
"i",
"j",
"j",
"def main():\n global H, W, grid, flag\n H, W = map(int, readline().split())\n grid = []\n grid.append(['.']*(W+2))\n for _ in range(H):\n grid.append(['.'] + list(readline()[:-1]) + ['.'])\n grid.append(['.']*(W+2))\n flag = True\n dfs(1, 1)\n\n if flag:\n print('Impossible')\n else:\n print('Possible')",
"main",
"global H, W, grid, flag",
"H, W = map(int, readline().split())",
"H",
"map(int, readline().split())",
"map",
"int",
"readline().split()",
"().split",
"()",
"readline",
"split",
"W",
"grid = []",
"grid",
"[]",
"grid.append(['.']*(W+2))",
"grid.append",
"grid",
"append",
"['.']*(W+2)",
"['.']",
"'.'",
"W+2",
"W",
"2",
"for _ in range(H):\n grid.append(['.'] + list(readline()[:-1]) + ['.'])\n ",
"_",
"range(H)",
"range",
"H",
"grid.append(['.'] + list(readline()[:-1]) + ['.'])",
"grid.append",
"grid",
"append",
"['.'] + list(readline()[:-1]) + ['.']",
"['.'] + list(readline()[:-1])",
"['.']",
"'.'",
"list(readline()[:-1])",
"list",
"readline()[:-1]",
"()",
"readline",
":-1",
"-1",
"['.']",
"'.'",
"grid.append(['.']*(W+2))",
"grid.append",
"grid",
"append",
"['.']*(W+2)",
"['.']",
"'.'",
"W+2",
"W",
"2",
"flag = True",
"flag",
"True",
"dfs(1, 1)",
"dfs",
"1",
"1",
"if flag:\n print('Impossible')\n else:\n print('Possible')",
"flag",
"print('Impossible')",
"print",
"'Impossible'",
"print('Possible')",
"print",
"'Possible'",
"if __name__ == \"__main__\":\n main()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"main()",
"main",
"def dfs(i, j):\n global flag, grid\n grid[i][j] = '.'\n if i == H and j == W:\n fgrid = flatten_2dim(grid)\n flag = ('#' in fgrid)\n if grid[i][j+1] == '#':\n dfs(i, j+1)\n if grid[i+1][j] == '#':\n dfs(i+1, j)\n grid[i][j] = '#'",
"def dfs(i, j):\n global flag, grid\n grid[i][j] = '.'\n if i == H and j == W:\n fgrid = flatten_2dim(grid)\n flag = ('#' in fgrid)\n if grid[i][j+1] == '#':\n dfs(i, j+1)\n if grid[i+1][j] == '#':\n dfs(i+1, j)\n grid[i][j] = '#'",
"dfs",
"readline = sys.stdin.readline",
"sys.stdin.readline",
"readline",
"def flatten_2dim(array):\n return [item for sublist in array for item in sublist]",
"def flatten_2dim(array):\n return [item for sublist in array for item in sublist]",
"flatten_2dim",
"def main():\n global H, W, grid, flag\n H, W = map(int, readline().split())\n grid = []\n grid.append(['.']*(W+2))\n for _ in range(H):\n grid.append(['.'] + list(readline()[:-1]) + ['.'])\n grid.append(['.']*(W+2))\n flag = True\n dfs(1, 1)\n\n if flag:\n print('Impossible')\n else:\n print('Possible')",
"def main():\n global H, W, grid, flag\n H, W = map(int, readline().split())\n grid = []\n grid.append(['.']*(W+2))\n for _ in range(H):\n grid.append(['.'] + list(readline()[:-1]) + ['.'])\n grid.append(['.']*(W+2))\n flag = True\n dfs(1, 1)\n\n if flag:\n print('Impossible')\n else:\n print('Possible')",
"main"
] |
import sys
readline = sys.stdin.readline
def flatten_2dim(array):
return [item for sublist in array for item in sublist]
def dfs(i, j):
global flag, grid
grid[i][j] = '.'
if i == H and j == W:
fgrid = flatten_2dim(grid)
flag = ('#' in fgrid)
if grid[i][j+1] == '#':
dfs(i, j+1)
if grid[i+1][j] == '#':
dfs(i+1, j)
grid[i][j] = '#'
def main():
global H, W, grid, flag
H, W = map(int, readline().split())
grid = []
grid.append(['.']*(W+2))
for _ in range(H):
grid.append(['.'] + list(readline()[:-1]) + ['.'])
grid.append(['.']*(W+2))
flag = True
dfs(1, 1)
if flag:
print('Impossible')
else:
print('Possible')
if __name__ == "__main__":
main()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
4,
13,
8,
2,
13,
2,
2,
13,
13,
17,
17,
17,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
13,
13
] |
[
[
70,
2
],
[
70,
11
],
[
15,
14
],
[
71,
17
],
[
73,
22
],
[
67,
25
],
[
29,
28
],
[
71,
31
],
[
34,
33
],
[
62,
36
],
[
74,
41
],
[
28,
42
],
[
33,
43
],
[
64,
46
],
[
65,
52
],
[
68,
52
],
[
71,
55
],
[
62,
56
],
[
70,
62
],
[
64,
65
],
[
67,
68
],
[
70,
71
],
[
73,
74
]
] |
[
"H,W = map(int,input().split())\nA = [input() for i in range(H)]\nc = 0\nfor i in range(H):\n for j in range(W):\n if A[i][j] == '#':\n c += 1\n\nprint('Possible' if c == H+W-1 else 'Impossible')",
"H,W = map(int,input().split())",
"H",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"input() for i in range(H)",
"for i in range(H)",
"i",
"range(H)",
"range",
"H",
"for i in range(H)",
"input()",
"input",
"A = [input() for i in range(H)]",
"A",
"[input() for i in range(H)]",
"c = 0",
"c",
"0",
"for i in range(H):\n for j in range(W):\n if A[i][j] == '#':\n c += 1",
"i",
"range(H)",
"range",
"H",
"for j in range(W):\n if A[i][j] == '#':\n c += 1",
"j",
"range(W)",
"range",
"W",
"if A[i][j] == '#':\n c += 1",
"A[i][j] == '#'",
"A[i][j]",
"[i]",
"A",
"i",
"j",
"'#'",
"c += 1",
"c",
"1",
"print('Possible' if c == H+W-1 else 'Impossible')",
"print",
"'Possible' if c == H+W-1 else 'Impossible'",
"c == H+W-1",
"c",
"H+W-1",
"H+W",
"H",
"W",
"1",
"'Possible'",
"'Impossible'",
"W = map(int,input().split())",
"map(int,input().split())",
"W",
"c += 1",
"1",
"c",
"c = 0",
"0",
"c",
"H,W = map(int,input().split())",
"map(int,input().split())",
"H",
"A = [input() for i in range(H)]",
"[input() for i in range(H)]",
"A"
] |
H,W = map(int,input().split())
A = [input() for i in range(H)]
c = 0
for i in range(H):
for j in range(W):
if A[i][j] == '#':
c += 1
print('Possible' if c == H+W-1 else 'Impossible')
|
[
7,
0,
13,
12,
2,
4,
13,
13,
17,
23,
12,
13,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
12,
13,
0,
13,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
28,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
0,
13,
2,
13,
17,
14,
2,
2,
2,
13,
13,
17,
13,
4,
13,
17,
4,
13,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13
] |
[
[
92,
2
],
[
21,
20
],
[
105,
26
],
[
30,
30
],
[
35,
34
],
[
99,
36
],
[
35,
37
],
[
40,
39
],
[
43,
42
],
[
34,
45
],
[
48,
47
],
[
54,
53
],
[
37,
56
],
[
47,
60
],
[
53,
61
],
[
65,
64
],
[
39,
66
],
[
64,
66
],
[
34,
72
],
[
37,
73
],
[
64,
75
],
[
39,
75
],
[
90,
87
],
[
92,
93
]
] |
[
"# import sys\n# sys.setrecursionlimit(10 ** 6)\nint1 = lambda x: int(x) - 1\ndef II(): return int(input())\n\ndef MI(): return map(int, input().split())\ndef MI1(): return map(int1, input().split())\n\ndef LI(): return list(map(int, input().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\n\n\ndef solve():\n h, w = MI()\n cnt = 0\n for i in range(h):\n l = list(input())\n for j in range(w):\n if l[j] == '#':\n cnt = cnt + 1\n if h + w - 1 == cnt:\n print('Possible')\n else:\n print('Impossible')\n\nif __name__ == '__main__':\n solve()",
"int1 = lambda x: int(x) - 1",
"int1",
"lambda x: int(x) - 1",
"int(x) - 1",
"int(x)",
"int",
"x",
"1",
"x",
"def II(): return int(input())",
"II",
"def MI(): return map(int, input().split())",
"MI",
"def MI1(): return map(int1, input().split())",
"MI1",
"def LI(): return list(map(int, input().split()))",
"LI",
"LI() for _ in range(rows_number)",
"for _ in range(rows_number)",
"_",
"range(rows_number)",
"range",
"rows_number",
"for _ in range(rows_number)",
"LI()",
"LI",
"def LLI(rows_number): return [LI() for _ in range(rows_number)]",
"LLI",
"rows_number",
"rows_number",
"def solve():\n h, w = MI()\n cnt = 0\n for i in range(h):\n l = list(input())\n for j in range(w):\n if l[j] == '#':\n cnt = cnt + 1\n if h + w - 1 == cnt:\n print('Possible')\n else:\n print('Impossible')",
"solve",
"h, w = MI()",
"h",
"MI()",
"MI",
"w",
"cnt = 0",
"cnt",
"0",
"for i in range(h):\n l = list(input())\n for j in range(w):\n if l[j] == '#':\n cnt = cnt + 1\n ",
"i",
"range(h)",
"range",
"h",
"l = list(input())",
"l",
"list(input())",
"list",
"input()",
"input",
"for j in range(w):\n if l[j] == '#':\n cnt = cnt + 1\n ",
"j",
"range(w)",
"range",
"w",
"if l[j] == '#':\n cnt = cnt + 1\n ",
"l[j] == '#'",
"l[j]",
"l",
"j",
"'#'",
"cnt = cnt + 1",
"cnt",
"cnt + 1",
"cnt",
"1",
"if h + w - 1 == cnt:\n print('Possible')\n else:\n print('Impossible')",
"h + w - 1 == cnt",
"h + w - 1",
"h + w",
"h",
"w",
"1",
"cnt",
"print('Possible')",
"print",
"'Possible'",
"print('Impossible')",
"print",
"'Impossible'",
"if __name__ == '__main__':\n solve()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"solve()",
"solve",
"def solve():\n h, w = MI()\n cnt = 0\n for i in range(h):\n l = list(input())\n for j in range(w):\n if l[j] == '#':\n cnt = cnt + 1\n if h + w - 1 == cnt:\n print('Possible')\n else:\n print('Impossible')",
"def solve():\n h, w = MI()\n cnt = 0\n for i in range(h):\n l = list(input())\n for j in range(w):\n if l[j] == '#':\n cnt = cnt + 1\n if h + w - 1 == cnt:\n print('Possible')\n else:\n print('Impossible')",
"solve",
"int1 = lambda x: int(x) - 1",
"lambda x: int(x) - 1",
"int1",
"def II(): return int(input())",
"def II(): return int(input())",
"II",
"def MI(): return map(int, input().split())",
"def MI(): return map(int, input().split())",
"MI",
"def LLI(rows_number): return [LI() for _ in range(rows_number)]",
"def LLI(rows_number): return [LI() for _ in range(rows_number)]",
"LLI",
"def LI(): return list(map(int, input().split()))",
"def LI(): return list(map(int, input().split()))",
"LI",
"def MI1(): return map(int1, input().split())",
"def MI1(): return map(int1, input().split())",
"MI1"
] |
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def solve():
h, w = MI()
cnt = 0
for i in range(h):
l = list(input())
for j in range(w):
if l[j] == '#':
cnt = cnt + 1
if h + w - 1 == cnt:
print('Possible')
else:
print('Impossible')
if __name__ == '__main__':
solve()
|
[
7,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
41,
28,
13,
13,
4,
13,
18,
13,
17,
2,
13,
17,
4,
13,
0,
13,
13,
28,
13,
4,
13,
17,
13,
41,
28,
13,
13,
4,
13,
18,
13,
13,
2,
13,
17,
4,
13,
0,
13,
13,
14,
2,
2,
4,
13,
2,
4,
13,
13,
4,
13,
13,
17,
2,
18,
13,
17,
18,
13,
17,
0,
13,
13,
4,
13,
17,
4,
13,
4,
13,
17,
10,
13,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13
] |
[
[
106,
3
],
[
106,
12
],
[
16,
15
],
[
107,
18
],
[
100,
23
],
[
101,
32
],
[
97,
40
],
[
44,
43
],
[
107,
47
],
[
101,
55
],
[
43,
56
],
[
109,
63
],
[
98,
73
],
[
113,
73
],
[
110,
76
],
[
98,
80
],
[
113,
80
],
[
110,
83
],
[
112,
86
],
[
110,
87
],
[
97,
98
],
[
100,
101
],
[
106,
104
],
[
106,
107
],
[
109,
110
],
[
110,
112
],
[
112,
113
]
] |
[
"\"\"\"\ni-1行目の右端のマスとi行目の左端のマスが隣接しており、\nそれらの行においてはそれ以外のマスは隣接していないこと。\n\n以上を満たした場合に'Possible'を出力すればよさそう。\n\"\"\"\nH, W = map(int, input().split())\ntable = [input() for _ in range(H)]\npre_row = [i for i, x in enumerate(table[0]) if x == \"#\"]\nfor i in range(1, H):\n next_row = [j for j, x in enumerate(table[i]) if x == \"#\"]\n if len(set(pre_row) & set(next_row)) == 1 and pre_row[-1] == next_row[0]:\n pre_row = next_row\n else:\n print('Impossible')\n exit()\nprint('Possible')",
"\"\"\"\ni-1行目の右端のマスとi行目の左端のマスが隣接しており、\nそれらの行においてはそれ以外のマスは隣接していないこと。\n\n以上を満たした場合に'Possible'を出力すればよさそう。\n\"\"\"",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"input() for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"input()",
"input",
"table = [input() for _ in range(H)]",
"table",
"[input() for _ in range(H)]",
"i for i, x in enumerate(table[0]) if x == \"#\"",
"for i, x in enumerate(table[0]) if x == \"#\"",
"i",
"x",
"enumerate(table[0])",
"enumerate",
"table[0]",
"table",
"0",
"x == \"#\"",
"x",
"\"#\"",
"if x == \"#\"",
"i",
"pre_row = [i for i, x in enumerate(table[0]) if x == \"#\"]",
"pre_row",
"[i for i, x in enumerate(table[0]) if x == \"#\"]",
"for i in range(1, H):\n next_row = [j for j, x in enumerate(table[i]) if x == \"#\"]\n if len(set(pre_row) & set(next_row)) == 1 and pre_row[-1] == next_row[0]:\n pre_row = next_row\n else:\n print('Impossible')\n exit()",
"i",
"range(1, H)",
"range",
"1",
"H",
"j for j, x in enumerate(table[i]) if x == \"#\"",
"for j, x in enumerate(table[i]) if x == \"#\"",
"j",
"x",
"enumerate(table[i])",
"enumerate",
"table[i]",
"table",
"i",
"x == \"#\"",
"x",
"\"#\"",
"if x == \"#\"",
"j",
"next_row = [j for j, x in enumerate(table[i]) if x == \"#\"]",
"next_row",
"[j for j, x in enumerate(table[i]) if x == \"#\"]",
"if len(set(pre_row) & set(next_row)) == 1 and pre_row[-1] == next_row[0]:\n pre_row = next_row\n else:\n print('Impossible')\n exit()",
"len(set(pre_row) & set(next_row)) == 1 and pre_row[-1] == next_row[0]",
"len(set(pre_row) & set(next_row)) == 1",
"len(set(pre_row) & set(next_row))",
"len",
"set(pre_row) & set(next_row)",
"set(pre_row)",
"set",
"pre_row",
"set(next_row)",
"set",
"next_row",
"1",
"pre_row[-1] == next_row[0]",
"pre_row[-1]",
"pre_row",
"-1",
"next_row[0]",
"next_row",
"0",
"pre_row = next_row",
"pre_row",
"next_row",
"print('Impossible')",
"print",
"'Impossible'",
"exit()",
"exit",
"print('Possible')",
"print",
"'Possible'",
"pre_row = [i for i, x in enumerate(table[0]) if x == \"#\"]",
"[i for i, x in enumerate(table[0]) if x == \"#\"]",
"pre_row",
"table = [input() for _ in range(H)]",
"[input() for _ in range(H)]",
"table",
"W = map(int, input().split())",
"map(int, input().split())",
"W",
"H, W = map(int, input().split())",
"map(int, input().split())",
"H",
"next_row = [j for j, x in enumerate(table[i]) if x == \"#\"]",
"[j for j, x in enumerate(table[i]) if x == \"#\"]",
"next_row",
"pre_row = next_row",
"next_row",
"pre_row"
] |
"""
i-1行目の右端のマスとi行目の左端のマスが隣接しており、
それらの行においてはそれ以外のマスは隣接していないこと。
以上を満たした場合に'Possible'を出力すればよさそう。
"""
H, W = map(int, input().split())
table = [input() for _ in range(H)]
pre_row = [i for i, x in enumerate(table[0]) if x == "#"]
for i in range(1, H):
next_row = [j for j, x in enumerate(table[i]) if x == "#"]
if len(set(pre_row) & set(next_row)) == 1 and pre_row[-1] == next_row[0]:
pre_row = next_row
else:
print('Impossible')
exit()
print('Possible')
|
[
7,
12,
13,
0,
18,
18,
13,
13,
13,
17,
28,
13,
4,
13,
17,
0,
13,
2,
13,
18,
13,
13,
0,
13,
2,
13,
18,
13,
13,
14,
2,
2,
2,
40,
17,
13,
13,
2,
40,
17,
13,
13,
2,
18,
18,
13,
13,
13,
17,
4,
13,
13,
13,
3,
23,
13,
23,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
2,
18,
18,
13,
17,
17,
17,
0,
13,
39,
17,
17,
0,
13,
39,
17,
17,
4,
13,
17,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
4,
13,
17,
4,
13,
4,
13,
17,
10,
4,
13,
10,
13,
13,
10,
39,
13,
10,
39,
13,
10,
4,
13,
10,
12,
13
] |
[
[
9,
4
],
[
55,
7
],
[
57,
8
],
[
12,
11
],
[
17,
16
],
[
55,
18
],
[
11,
21
],
[
24,
23
],
[
57,
25
],
[
11,
28
],
[
16,
35
],
[
23,
40
],
[
16,
46
],
[
23,
47
],
[
16,
51
],
[
23,
52
],
[
55,
55
],
[
57,
57
],
[
143,
59
],
[
143,
68
],
[
72,
71
],
[
144,
74
],
[
134,
81
],
[
135,
86
],
[
140,
91
],
[
137,
96
],
[
147,
101
],
[
106,
105
],
[
144,
108
],
[
111,
110
],
[
132,
113
],
[
135,
118
],
[
105,
119
],
[
110,
120
],
[
143,
132
],
[
134,
135
],
[
137,
138
],
[
140,
141
],
[
143,
144
]
] |
[
"def lake(x,y):\n l[x][y] = \".\"\n for i in range(2):\n xi = x + dx[i]\n yi = y + dy[i]\n if 0 <= xi < n and 0 <= yi < m and l[xi][yi] == \"#\":\n lake(xi,yi)\n break\n\n\nn,m = map(int, input().split())\nl = [list(input()) for _ in range(n)]\nl[0][0]==\".\"\ndx = [1,0]\ndy = [0,1]\nlake(0,0)\nfor i in range(n):\n for j in range(m):\n if l[i][j] == \"#\":\n print(\"Impossible\")\n exit()\n\nprint(\"Possible\")",
"def lake(x,y):\n l[x][y] = \".\"\n for i in range(2):\n xi = x + dx[i]\n yi = y + dy[i]\n if 0 <= xi < n and 0 <= yi < m and l[xi][yi] == \"#\":\n lake(xi,yi)\n break",
"lake",
"l[x][y] = \".\"",
"l[x][y]",
"[x]",
"l",
"x",
"y",
"\".\"",
"for i in range(2):\n xi = x + dx[i]\n yi = y + dy[i]\n if 0 <= xi < n and 0 <= yi < m and l[xi][yi] == \"#\":\n lake(xi,yi)\n break",
"i",
"range(2)",
"range",
"2",
"xi = x + dx[i]",
"xi",
"x + dx[i]",
"x",
"dx[i]",
"dx",
"i",
"yi = y + dy[i]",
"yi",
"y + dy[i]",
"y",
"dy[i]",
"dy",
"i",
"if 0 <= xi < n and 0 <= yi < m and l[xi][yi] == \"#\":\n lake(xi,yi)\n break",
"0 <= xi < n and 0 <= yi < m and l[xi][yi] == \"#\"",
"0 <= xi < n and 0 <= yi < m",
"0 <= xi < n",
"0 <= xi",
"0",
"xi",
"n",
"0 <= yi < m",
"0 <= yi",
"0",
"yi",
"m",
"l[xi][yi] == \"#\"",
"l[xi][yi]",
"[xi]",
"l",
"xi",
"yi",
"\"#\"",
"lake(xi,yi)",
"lake",
"xi",
"yi",
"break",
"x",
"x",
"y",
"y",
"n,m = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"m",
"list(input()) for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"list(input())",
"list",
"input()",
"input",
"l = [list(input()) for _ in range(n)]",
"l",
"[list(input()) for _ in range(n)]",
"l[0][0]==\".\"",
"l[0][0]",
"[0]",
"l",
"0",
"0",
"\".\"",
"dx = [1,0]",
"dx",
"[1,0]",
"1",
"0",
"dy = [0,1]",
"dy",
"[0,1]",
"0",
"1",
"lake(0,0)",
"lake",
"0",
"0",
"for i in range(n):\n for j in range(m):\n if l[i][j] == \"#\":\n print(\"Impossible\")\n exit()",
"i",
"range(n)",
"range",
"n",
"for j in range(m):\n if l[i][j] == \"#\":\n print(\"Impossible\")\n exit()",
"j",
"range(m)",
"range",
"m",
"if l[i][j] == \"#\":\n print(\"Impossible\")\n exit()",
"l[i][j] == \"#\"",
"l[i][j]",
"[i]",
"l",
"i",
"j",
"\"#\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"exit()",
"exit",
"print(\"Possible\")",
"print",
"\"Possible\"",
"m = map(int, input().split())",
"map(int, input().split())",
"m",
"l = [list(input()) for _ in range(n)]",
"[list(input()) for _ in range(n)]",
"l",
"dy = [0,1]",
"[0,1]",
"dy",
"dx = [1,0]",
"[1,0]",
"dx",
"n,m = map(int, input().split())",
"map(int, input().split())",
"n",
"def lake(x,y):\n l[x][y] = \".\"\n for i in range(2):\n xi = x + dx[i]\n yi = y + dy[i]\n if 0 <= xi < n and 0 <= yi < m and l[xi][yi] == \"#\":\n lake(xi,yi)\n break",
"def lake(x,y):\n l[x][y] = \".\"\n for i in range(2):\n xi = x + dx[i]\n yi = y + dy[i]\n if 0 <= xi < n and 0 <= yi < m and l[xi][yi] == \"#\":\n lake(xi,yi)\n break",
"lake"
] |
def lake(x,y):
l[x][y] = "."
for i in range(2):
xi = x + dx[i]
yi = y + dy[i]
if 0 <= xi < n and 0 <= yi < m and l[xi][yi] == "#":
lake(xi,yi)
break
n,m = map(int, input().split())
l = [list(input()) for _ in range(n)]
l[0][0]=="."
dx = [1,0]
dy = [0,1]
lake(0,0)
for i in range(n):
for j in range(m):
if l[i][j] == "#":
print("Impossible")
exit()
print("Possible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
13,
0,
13,
4,
18,
13,
13,
17,
4,
13,
8,
2,
13,
2,
13,
2,
13,
17,
17,
17,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13
] |
[
[
62,
2
],
[
62,
11
],
[
15,
14
],
[
63,
17
],
[
56,
22
],
[
50,
25
],
[
29,
28
],
[
57,
28
],
[
59,
31
],
[
28,
34
],
[
60,
41
],
[
51,
41
],
[
54,
43
],
[
63,
45
],
[
50,
51
],
[
62,
54
],
[
56,
57
],
[
59,
60
],
[
62,
63
]
] |
[
"H,W = map(int, input().split())\nA = [input() for _ in range(H)]\n\ncnt = 0\nfor a in A:\n cnt += a.count(\"#\")\nprint(\"Possible\" if cnt == W + (H-1) else \"Impossible\")",
"H,W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"input() for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"input()",
"input",
"A = [input() for _ in range(H)]",
"A",
"[input() for _ in range(H)]",
"cnt = 0",
"cnt",
"0",
"for a in A:\n cnt += a.count(\"#\")",
"a",
"A",
"cnt += a.count(\"#\")",
"cnt",
"a.count(\"#\")",
"a.count",
"a",
"count",
"\"#\"",
"print(\"Possible\" if cnt == W + (H-1) else \"Impossible\")",
"print",
"\"Possible\" if cnt == W + (H-1) else \"Impossible\"",
"cnt == W + (H-1)",
"cnt",
"W + (H-1)",
"W",
"H-1",
"H",
"1",
"\"Possible\"",
"\"Impossible\"",
"cnt = 0",
"0",
"cnt",
"W = map(int, input().split())",
"map(int, input().split())",
"W",
"A = [input() for _ in range(H)]",
"[input() for _ in range(H)]",
"A",
"cnt += a.count(\"#\")",
"a.count(\"#\")",
"cnt",
"H,W = map(int, input().split())",
"map(int, input().split())",
"H"
] |
H,W = map(int, input().split())
A = [input() for _ in range(H)]
cnt = 0
for a in A:
cnt += a.count("#")
print("Possible" if cnt == W + (H-1) else "Impossible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
18,
18,
13,
13,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13
] |
[
[
67,
2
],
[
67,
11
],
[
15,
14
],
[
68,
17
],
[
70,
24
],
[
58,
27
],
[
31,
30
],
[
68,
33
],
[
64,
35
],
[
71,
39
],
[
30,
40
],
[
65,
45
],
[
59,
45
],
[
68,
48
],
[
62,
49
],
[
58,
59
],
[
67,
62
],
[
64,
65
],
[
67,
68
],
[
70,
71
]
] |
[
"h,w=map(int,input().split())\n\na=[str(input()) for _ in range(h)]\nans=0\nfor i in range(h):\n ans+=a[i].count(\"#\")\n#print(ans)\nif ans==h+w-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"h,w=map(int,input().split())",
"h",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"str(input()) for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"str(input())",
"str",
"input()",
"input",
"a=[str(input()) for _ in range(h)]",
"a",
"[str(input()) for _ in range(h)]",
"ans=0",
"ans",
"0",
"for i in range(h):\n ans+=a[i].count(\"#\")\n#print(ans)",
"i",
"range(h)",
"range",
"h",
"ans+=a[i].count(\"#\")",
"ans",
"a[i].count(\"#\")",
"[i].count",
"[i]",
"a",
"i",
"count",
"\"#\"",
"if ans==h+w-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"ans==h+w-1",
"ans",
"h+w-1",
"h+w",
"h",
"w",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"ans=0",
"0",
"ans",
"w=map(int,input().split())",
"map(int,input().split())",
"w",
"ans+=a[i].count(\"#\")",
"a[i].count(\"#\")",
"ans",
"h,w=map(int,input().split())",
"map(int,input().split())",
"h",
"a=[str(input()) for _ in range(h)]",
"[str(input()) for _ in range(h)]",
"a"
] |
h,w=map(int,input().split())
a=[str(input()) for _ in range(h)]
ans=0
for i in range(h):
ans+=a[i].count("#")
#print(ans)
if ans==h+w-1:
print("Possible")
else:
print("Impossible")
|
[
7,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
18,
4,
13,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13
] |
[
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
19,
18
],
[
4,
21
],
[
24,
23
],
[
15,
28
],
[
23,
28
],
[
23,
32
],
[
15,
32
],
[
4,
35
],
[
13,
36
],
[
52,
49
]
] |
[
"def main2():\n H, W = map(int, input().split())\n\n count = 0\n for i in range(H):\n count += input().count(\"#\")\n\n if count == (H + W - 1):\n print(\"Possible\")\n else:\n print(\"Impossible\")\n\nif __name__ == \"__main__\":\n main2()",
"def main2():\n H, W = map(int, input().split())\n\n count = 0\n for i in range(H):\n count += input().count(\"#\")\n\n if count == (H + W - 1):\n print(\"Possible\")\n else:\n print(\"Impossible\")",
"main2",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"count = 0",
"count",
"0",
"for i in range(H):\n count += input().count(\"#\")\n\n ",
"i",
"range(H)",
"range",
"H",
"count += input().count(\"#\")",
"count",
"input().count(\"#\")",
"().count",
"()",
"input",
"count",
"\"#\"",
"if count == (H + W - 1):\n print(\"Possible\")\n else:\n print(\"Impossible\")",
"count == (H + W - 1)",
"count",
"H + W - 1",
"H + W",
"H",
"W",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"if __name__ == \"__main__\":\n main2()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"main2()",
"main2",
"def main2():\n H, W = map(int, input().split())\n\n count = 0\n for i in range(H):\n count += input().count(\"#\")\n\n if count == (H + W - 1):\n print(\"Possible\")\n else:\n print(\"Impossible\")",
"def main2():\n H, W = map(int, input().split())\n\n count = 0\n for i in range(H):\n count += input().count(\"#\")\n\n if count == (H + W - 1):\n print(\"Possible\")\n else:\n print(\"Impossible\")",
"main2"
] |
def main2():
H, W = map(int, input().split())
count = 0
for i in range(H):
count += input().count("#")
if count == (H + W - 1):
print("Possible")
else:
print("Impossible")
if __name__ == "__main__":
main2()
|
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
2,
17,
2,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
18,
13,
13,
2,
2,
17,
13,
17,
0,
13,
4,
18,
13,
13,
17,
4,
18,
13,
13,
2,
17,
2,
13,
17,
0,
13,
17,
13,
17,
0,
13,
17,
42,
2,
2,
13,
13,
2,
13,
13,
0,
13,
2,
18,
18,
13,
2,
13,
17,
13,
17,
0,
13,
2,
18,
18,
13,
13,
2,
13,
17,
17,
14,
2,
13,
13,
14,
13,
0,
13,
2,
13,
17,
0,
13,
2,
13,
17,
0,
13,
17,
4,
13,
17,
4,
18,
13,
13,
14,
2,
13,
13,
4,
13,
17,
4,
13,
17,
10,
17,
13,
10,
2,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
39,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13
] |
[
[
167,
4
],
[
167,
13
],
[
149,
15
],
[
168,
20
],
[
140,
23
],
[
27,
26
],
[
147,
29
],
[
161,
31
],
[
150,
36
],
[
162,
41
],
[
155,
44
],
[
162,
47
],
[
150,
52
],
[
168,
57
],
[
170,
60
],
[
134,
62
],
[
143,
65
],
[
171,
70
],
[
165,
70
],
[
168,
71
],
[
135,
73
],
[
174,
73
],
[
147,
74
],
[
137,
76
],
[
150,
80
],
[
135,
82
],
[
174,
82
],
[
171,
84
],
[
165,
84
],
[
152,
87
],
[
150,
91
],
[
135,
92
],
[
174,
92
],
[
171,
94
],
[
165,
94
],
[
138,
99
],
[
153,
100
],
[
173,
104
],
[
135,
106
],
[
174,
106
],
[
164,
109
],
[
171,
111
],
[
165,
111
],
[
158,
114
],
[
156,
125
],
[
141,
125
],
[
159,
126
],
[
144,
126
],
[
134,
135
],
[
137,
138
],
[
140,
141
],
[
143,
144
],
[
167,
147
],
[
149,
150
],
[
152,
153
],
[
155,
156
],
[
158,
159
],
[
161,
162
],
[
164,
165
],
[
167,
168
],
[
170,
171
],
[
173,
174
]
] |
[
"import sys\n\nH,W=map(int,input().split())\n\nA=[\".\"*(W+2)]\nT=0\nfor _ in range(H):\n G=input()\n A.append(\".\"+G+\".\")\n T+=G.count(\"#\")\n \nA.append(\".\"*(W+2))\n\nx,y=1,1\nU=1\nwhile x<W or y<H:\n p=(A[y+1][x]==\"#\")\n q=(A[y][x+1]==\"#\")\n\n if p^q:\n if p:\n y=y+1\n else:\n x=x+1\n U+=1\n else:\n print(\"Impossible\")\n sys.exit()\n\nif T==U:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"import sys",
"sys",
"H,W=map(int,input().split())",
"H",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"A=[\".\"*(W+2)]",
"A",
"[\".\"*(W+2)]",
"\".\"*(W+2)",
"\".\"",
"W+2",
"W",
"2",
"T=0",
"T",
"0",
"for _ in range(H):\n G=input()\n A.append(\".\"+G+\".\")\n T+=G.count(\"#\")\n ",
"_",
"range(H)",
"range",
"H",
"G=input()",
"G",
"input()",
"input",
"A.append(\".\"+G+\".\")",
"A.append",
"A",
"append",
"\".\"+G+\".\"",
"\".\"+G",
"\".\"",
"G",
"\".\"",
"T+=G.count(\"#\")",
"T",
"G.count(\"#\")",
"G.count",
"G",
"count",
"\"#\"",
"A.append(\".\"*(W+2))",
"A.append",
"A",
"append",
"\".\"*(W+2)",
"\".\"",
"W+2",
"W",
"2",
"x,y=1,1",
"x",
"1",
"y",
"1",
"U=1",
"U",
"1",
"while x<W or y<H:\n p=(A[y+1][x]==\"#\")\n q=(A[y][x+1]==\"#\")\n\n if p^q:\n if p:\n y=y+1\n else:\n x=x+1\n U+=1\n else:\n print(\"Impossible\")\n sys.exit()",
"x<W or y<H",
"x<W",
"x",
"W",
"y<H",
"y",
"H",
"p=(A[y+1][x]==\"#\")",
"p",
"A[y+1][x]==\"#\"",
"A[y+1][x]",
"[y+1]",
"A",
"y+1",
"y",
"1",
"x",
"\"#\"",
"q=(A[y][x+1]==\"#\")",
"q",
"A[y][x+1]==\"#\"",
"A[y][x+1]",
"[y]",
"A",
"y",
"x+1",
"x",
"1",
"\"#\"",
"if p^q:\n if p:\n y=y+1\n else:\n x=x+1\n U+=1\n else:\n print(\"Impossible\")\n sys.exit()",
"p^q",
"p",
"q",
"if p:\n y=y+1\n else:\n x=x+1\n ",
"p",
"y=y+1",
"y",
"y+1",
"y",
"1",
"x=x+1",
"x",
"x+1",
"x",
"1",
"U+=1",
"U",
"1",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"sys.exit()",
"sys.exit",
"sys",
"exit",
"if T==U:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"T==U",
"T",
"U",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"y=1,1",
"1",
"y",
"p=(A[y+1][x]==\"#\")",
"A[y+1][x]==\"#\"",
"p",
"T=0",
"0",
"T",
"U=1",
"1",
"U",
"H,W=map(int,input().split())",
"map(int,input().split())",
"H",
"A=[\".\"*(W+2)]",
"[\".\"*(W+2)]",
"A",
"q=(A[y][x+1]==\"#\")",
"A[y][x+1]==\"#\"",
"q",
"T+=G.count(\"#\")",
"G.count(\"#\")",
"T",
"U+=1",
"1",
"U",
"G=input()",
"input()",
"G",
"x=x+1",
"x+1",
"x",
"W=map(int,input().split())",
"map(int,input().split())",
"W",
"x,y=1,1",
"1",
"x",
"y=y+1",
"y+1",
"y"
] |
import sys
H,W=map(int,input().split())
A=["."*(W+2)]
T=0
for _ in range(H):
G=input()
A.append("."+G+".")
T+=G.count("#")
A.append("."*(W+2))
x,y=1,1
U=1
while x<W or y<H:
p=(A[y+1][x]=="#")
q=(A[y][x+1]=="#")
if p^q:
if p:
y=y+1
else:
x=x+1
U+=1
else:
print("Impossible")
sys.exit()
if T==U:
print("Possible")
else:
print("Impossible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
39,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13
] |
[
[
77,
2
],
[
77,
11
],
[
65,
13
],
[
17,
16
],
[
75,
19
],
[
66,
22
],
[
68,
27
],
[
31,
30
],
[
75,
33
],
[
36,
35
],
[
78,
38
],
[
66,
43
],
[
30,
44
],
[
35,
45
],
[
71,
48
],
[
72,
52
],
[
69,
52
],
[
75,
55
],
[
78,
56
],
[
65,
66
],
[
68,
69
],
[
71,
72
],
[
77,
75
],
[
77,
78
]
] |
[
"#!/usr/bin/env python\n# coding: utf-8\n\n# In[21]:\n\n\nH,W = map(int, input().split())\nA = []\nfor _ in range(H):\n A.append(input())\n\n\n# In[ ]:\n\n\ncnt = 0\nfor i in range(H):\n for j in range(W):\n if A[i][j] == \"#\":\n cnt += 1\nif cnt == H+W-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")\n",
"H,W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"A = []",
"A",
"[]",
"for _ in range(H):\n A.append(input())\n\n\n# In[ ]:",
"_",
"range(H)",
"range",
"H",
"A.append(input())",
"A.append",
"A",
"append",
"input()",
"input",
"cnt = 0",
"cnt",
"0",
"for i in range(H):\n for j in range(W):\n if A[i][j] == \"#\":\n cnt += 1",
"i",
"range(H)",
"range",
"H",
"for j in range(W):\n if A[i][j] == \"#\":\n cnt += 1",
"j",
"range(W)",
"range",
"W",
"if A[i][j] == \"#\":\n cnt += 1",
"A[i][j] == \"#\"",
"A[i][j]",
"[i]",
"A",
"i",
"j",
"\"#\"",
"cnt += 1",
"cnt",
"1",
"if cnt == H+W-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"cnt == H+W-1",
"cnt",
"H+W-1",
"H+W",
"H",
"W",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"A = []",
"[]",
"A",
"cnt = 0",
"0",
"cnt",
"cnt += 1",
"1",
"cnt",
"H,W = map(int, input().split())",
"map(int, input().split())",
"H",
"W = map(int, input().split())",
"map(int, input().split())",
"W"
] |
#!/usr/bin/env python
# coding: utf-8
# In[21]:
H,W = map(int, input().split())
A = []
for _ in range(H):
A.append(input())
# In[ ]:
cnt = 0
for i in range(H):
for j in range(W):
if A[i][j] == "#":
cnt += 1
if cnt == H+W-1:
print("Possible")
else:
print("Impossible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13
] |
[
[
66,
2
],
[
66,
11
],
[
15,
14
],
[
67,
17
],
[
69,
22
],
[
72,
25
],
[
29,
28
],
[
67,
31
],
[
34,
33
],
[
64,
36
],
[
70,
41
],
[
28,
42
],
[
33,
43
],
[
75,
46
],
[
76,
50
],
[
73,
50
],
[
67,
53
],
[
64,
54
],
[
66,
64
],
[
66,
67
],
[
69,
70
],
[
72,
73
],
[
75,
76
]
] |
[
"h, w = map(int, input().split())\na = [input() for _ in range(h)]\n\ncnt = 0\nfor i in range(h):\n for j in range(w):\n if a[i][j] == '#':\n cnt += 1\nif cnt == h+w-1:\n print('Possible')\nelse:\n print('Impossible')",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"input() for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"input()",
"input",
"a = [input() for _ in range(h)]",
"a",
"[input() for _ in range(h)]",
"cnt = 0",
"cnt",
"0",
"for i in range(h):\n for j in range(w):\n if a[i][j] == '#':\n cnt += 1",
"i",
"range(h)",
"range",
"h",
"for j in range(w):\n if a[i][j] == '#':\n cnt += 1",
"j",
"range(w)",
"range",
"w",
"if a[i][j] == '#':\n cnt += 1",
"a[i][j] == '#'",
"a[i][j]",
"[i]",
"a",
"i",
"j",
"'#'",
"cnt += 1",
"cnt",
"1",
"if cnt == h+w-1:\n print('Possible')\nelse:\n print('Impossible')",
"cnt == h+w-1",
"cnt",
"h+w-1",
"h+w",
"h",
"w",
"1",
"print('Possible')",
"print",
"'Possible'",
"print('Impossible')",
"print",
"'Impossible'",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h",
"a = [input() for _ in range(h)]",
"[input() for _ in range(h)]",
"a",
"cnt = 0",
"0",
"cnt",
"cnt += 1",
"1",
"cnt"
] |
h, w = map(int, input().split())
a = [input() for _ in range(h)]
cnt = 0
for i in range(h):
for j in range(w):
if a[i][j] == '#':
cnt += 1
if cnt == h+w-1:
print('Possible')
else:
print('Impossible')
|
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
0,
13,
17,
42,
17,
0,
13,
39,
0,
13,
17,
14,
40,
13,
2,
13,
17,
4,
18,
13,
13,
39,
2,
13,
17,
13,
17,
14,
40,
13,
2,
13,
17,
4,
18,
13,
13,
39,
13,
2,
13,
17,
17,
28,
13,
13,
14,
2,
18,
18,
13,
18,
13,
17,
18,
13,
17,
17,
0,
13,
17,
0,
13,
18,
13,
17,
0,
13,
18,
13,
17,
14,
2,
40,
13,
17,
40,
2,
2,
13,
2,
13,
17,
2,
13,
2,
13,
17,
4,
13,
17,
3,
0,
13,
39,
0,
13,
17,
14,
40,
13,
17,
4,
18,
13,
13,
39,
2,
13,
17,
13,
17,
14,
40,
13,
17,
4,
18,
13,
13,
39,
13,
2,
13,
17,
17,
28,
13,
13,
14,
2,
18,
18,
13,
18,
13,
17,
18,
13,
17,
17,
0,
13,
17,
14,
2,
13,
17,
4,
13,
17,
3,
14,
2,
2,
13,
2,
13,
17,
2,
13,
2,
13,
17,
4,
13,
17,
3,
0,
13,
13,
0,
13,
13,
10,
18,
13,
10,
18,
13,
10,
17,
13,
10,
17,
13,
10,
39,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
39,
13,
10,
13,
13,
10,
17,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13
] |
[
[
225,
2
],
[
225,
13
],
[
17,
16
],
[
226,
19
],
[
231,
24
],
[
240,
27
],
[
243,
30
],
[
216,
35
],
[
210,
38
],
[
241,
42
],
[
238,
42
],
[
223,
44
],
[
217,
48
],
[
229,
48
],
[
241,
52
],
[
238,
52
],
[
244,
58
],
[
220,
58
],
[
226,
60
],
[
217,
64
],
[
229,
64
],
[
244,
69
],
[
220,
69
],
[
74,
73
],
[
217,
73
],
[
229,
73
],
[
232,
79
],
[
73,
81
],
[
73,
84
],
[
213,
88
],
[
207,
91
],
[
73,
93
],
[
204,
96
],
[
73,
98
],
[
214,
103
],
[
211,
103
],
[
247,
103
],
[
235,
103
],
[
241,
108
],
[
238,
108
],
[
223,
110
],
[
244,
113
],
[
220,
113
],
[
226,
115
],
[
228,
122
],
[
234,
125
],
[
241,
129
],
[
238,
129
],
[
229,
133
],
[
217,
133
],
[
241,
137
],
[
238,
137
],
[
244,
143
],
[
220,
143
],
[
229,
147
],
[
217,
147
],
[
244,
152
],
[
220,
152
],
[
157,
156
],
[
229,
156
],
[
217,
156
],
[
232,
162
],
[
156,
164
],
[
156,
167
],
[
246,
171
],
[
247,
175
],
[
235,
175
],
[
214,
175
],
[
211,
175
],
[
241,
184
],
[
238,
184
],
[
223,
186
],
[
244,
189
],
[
220,
189
],
[
226,
191
],
[
237,
198
],
[
208,
199
],
[
219,
201
],
[
205,
202
],
[
204,
205
],
[
207,
208
],
[
210,
211
],
[
213,
214
],
[
216,
217
],
[
205,
219
],
[
219,
220
],
[
225,
223
],
[
225,
226
],
[
228,
229
],
[
231,
232
],
[
234,
235
],
[
208,
237
],
[
237,
238
],
[
240,
241
],
[
243,
244
],
[
246,
247
]
] |
[
"h, w = list(map(int, input().split()))\ngrid = [input() for _ in range(h)]\n\nx = 0\ny = 0\n\nwhile True:\n c = []\n neighbours = 0\n if x != w-1:\n c.append([x+1, y, 1])\n if y != h-1:\n c.append([x, y+1, 3])\n\n for coords in c:\n if grid[coords[1]][coords[0]] == \"#\":\n neighbours += 1\n x2 = coords[0]\n y2 = coords[1]\n\n if neighbours != 1 and not (x == w-1 and y == h-1):\n print(\"Impossible\")\n break\n\n c = []\n neighbours = 0\n if x != 0:\n c.append([x-1, y, 0])\n if y != 0:\n c.append([x, y-1, 2])\n\n for coords in c:\n if grid[coords[1]][coords[0]] == \"#\":\n neighbours += 1\n\n if neighbours > 1:\n print(\"Impossible\")\n break\n\n if x == w-1 and y == h-1:\n print(\"Possible\")\n break\n\n x = x2\n y = y2",
"h, w = list(map(int, input().split()))",
"h",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"input() for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"input()",
"input",
"grid = [input() for _ in range(h)]",
"grid",
"[input() for _ in range(h)]",
"x = 0",
"x",
"0",
"y = 0",
"y",
"0",
"while True:\n c = []\n neighbours = 0\n if x != w-1:\n c.append([x+1, y, 1])\n if y != h-1:\n c.append([x, y+1, 3])\n\n for coords in c:\n if grid[coords[1]][coords[0]] == \"#\":\n neighbours += 1\n x2 = coords[0]\n y2 = coords[1]\n\n if neighbours != 1 and not (x == w-1 and y == h-1):\n print(\"Impossible\")\n break\n\n c = []\n neighbours = 0\n if x != 0:\n c.append([x-1, y, 0])\n if y != 0:\n c.append([x, y-1, 2])\n\n for coords in c:\n if grid[coords[1]][coords[0]] == \"#\":\n neighbours += 1\n\n if neighbours > 1:\n print(\"Impossible\")\n break\n\n if x == w-1 and y == h-1:\n print(\"Possible\")\n break\n\n x = x2\n y = y2",
"True",
"c = []",
"c",
"[]",
"neighbours = 0",
"neighbours",
"0",
"if x != w-1:\n c.append([x+1, y, 1])\n ",
"x != w-1",
"x",
"w-1",
"w",
"1",
"c.append([x+1, y, 1])",
"c.append",
"c",
"append",
"[x+1, y, 1]",
"x+1",
"x",
"1",
"y",
"1",
"if y != h-1:\n c.append([x, y+1, 3])\n\n ",
"y != h-1",
"y",
"h-1",
"h",
"1",
"c.append([x, y+1, 3])",
"c.append",
"c",
"append",
"[x, y+1, 3]",
"x",
"y+1",
"y",
"1",
"3",
"for coords in c:\n if grid[coords[1]][coords[0]] == \"#\":\n neighbours += 1\n x2 = coords[0]\n y2 = coords[1]\n\n ",
"coords",
"c",
"if grid[coords[1]][coords[0]] == \"#\":\n neighbours += 1\n x2 = coords[0]\n y2 = coords[1]\n\n ",
"grid[coords[1]][coords[0]] == \"#\"",
"grid[coords[1]][coords[0]]",
"[coords[1]]",
"grid",
"coords[1]",
"coords",
"1",
"coords[0]",
"coords",
"0",
"\"#\"",
"neighbours += 1",
"neighbours",
"1",
"x2 = coords[0]",
"x2",
"coords[0]",
"coords",
"0",
"y2 = coords[1]",
"y2",
"coords[1]",
"coords",
"1",
"if neighbours != 1 and not (x == w-1 and y == h-1):\n print(\"Impossible\")\n break\n\n ",
"neighbours != 1 and not (x == w-1 and y == h-1)",
"neighbours != 1",
"neighbours",
"1",
"not (x == w-1 and y == h-1)",
"x == w-1 and y == h-1",
"x == w-1",
"x",
"w-1",
"w",
"1",
"y == h-1",
"y",
"h-1",
"h",
"1",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"break",
"c = []",
"c",
"[]",
"neighbours = 0",
"neighbours",
"0",
"if x != 0:\n c.append([x-1, y, 0])\n ",
"x != 0",
"x",
"0",
"c.append([x-1, y, 0])",
"c.append",
"c",
"append",
"[x-1, y, 0]",
"x-1",
"x",
"1",
"y",
"0",
"if y != 0:\n c.append([x, y-1, 2])\n\n ",
"y != 0",
"y",
"0",
"c.append([x, y-1, 2])",
"c.append",
"c",
"append",
"[x, y-1, 2]",
"x",
"y-1",
"y",
"1",
"2",
"for coords in c:\n if grid[coords[1]][coords[0]] == \"#\":\n neighbours += 1\n\n ",
"coords",
"c",
"if grid[coords[1]][coords[0]] == \"#\":\n neighbours += 1\n\n ",
"grid[coords[1]][coords[0]] == \"#\"",
"grid[coords[1]][coords[0]]",
"[coords[1]]",
"grid",
"coords[1]",
"coords",
"1",
"coords[0]",
"coords",
"0",
"\"#\"",
"neighbours += 1",
"neighbours",
"1",
"if neighbours > 1:\n print(\"Impossible\")\n break\n\n ",
"neighbours > 1",
"neighbours",
"1",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"break",
"if x == w-1 and y == h-1:\n print(\"Possible\")\n break\n\n ",
"x == w-1 and y == h-1",
"x == w-1",
"x",
"w-1",
"w",
"1",
"y == h-1",
"y",
"h-1",
"h",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"break",
"x = x2",
"x",
"x2",
"y = y2",
"y",
"y2",
"y2 = coords[1]",
"coords[1]",
"y2",
"x2 = coords[0]",
"coords[0]",
"x2",
"neighbours = 0",
"0",
"neighbours",
"neighbours += 1",
"1",
"neighbours",
"c = []",
"[]",
"c",
"y = y2",
"y2",
"y",
"w = list(map(int, input().split()))",
"list(map(int, input().split()))",
"w",
"h, w = list(map(int, input().split()))",
"list(map(int, input().split()))",
"h",
"c = []",
"[]",
"c",
"grid = [input() for _ in range(h)]",
"[input() for _ in range(h)]",
"grid",
"neighbours = 0",
"0",
"neighbours",
"x = x2",
"x2",
"x",
"x = 0",
"0",
"x",
"y = 0",
"0",
"y",
"neighbours += 1",
"1",
"neighbours"
] |
h, w = list(map(int, input().split()))
grid = [input() for _ in range(h)]
x = 0
y = 0
while True:
c = []
neighbours = 0
if x != w-1:
c.append([x+1, y, 1])
if y != h-1:
c.append([x, y+1, 3])
for coords in c:
if grid[coords[1]][coords[0]] == "#":
neighbours += 1
x2 = coords[0]
y2 = coords[1]
if neighbours != 1 and not (x == w-1 and y == h-1):
print("Impossible")
break
c = []
neighbours = 0
if x != 0:
c.append([x-1, y, 0])
if y != 0:
c.append([x, y-1, 2])
for coords in c:
if grid[coords[1]][coords[0]] == "#":
neighbours += 1
if neighbours > 1:
print("Impossible")
break
if x == w-1 and y == h-1:
print("Possible")
break
x = x2
y = y2
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
18,
4,
13,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
52,
2
],
[
52,
11
],
[
43,
13
],
[
17,
16
],
[
53,
19
],
[
49,
21
],
[
50,
30
],
[
44,
30
],
[
53,
33
],
[
47,
34
],
[
43,
44
],
[
52,
47
],
[
49,
50
],
[
52,
53
]
] |
[
"H, W = map(int, input().split())\ncnt = 0\nfor i in range(H):\n cnt += input().count(\"#\")\n\nif cnt == H+W-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"cnt = 0",
"cnt",
"0",
"for i in range(H):\n cnt += input().count(\"#\")",
"i",
"range(H)",
"range",
"H",
"cnt += input().count(\"#\")",
"cnt",
"input().count(\"#\")",
"().count",
"()",
"input",
"count",
"\"#\"",
"if cnt == H+W-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"cnt == H+W-1",
"cnt",
"H+W-1",
"H+W",
"H",
"W",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"cnt = 0",
"0",
"cnt",
"W = map(int, input().split())",
"map(int, input().split())",
"W",
"cnt += input().count(\"#\")",
"input().count(\"#\")",
"cnt",
"H, W = map(int, input().split())",
"map(int, input().split())",
"H"
] |
H, W = map(int, input().split())
cnt = 0
for i in range(H):
cnt += input().count("#")
if cnt == H+W-1:
print("Possible")
else:
print("Impossible")
|
[
7,
15,
13,
15,
15,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
17,
0,
13,
2,
2,
17,
17,
17,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
4,
13,
39,
17,
17,
0,
13,
2,
2,
13,
13,
17,
0,
13,
4,
18,
13,
13,
13,
14,
2,
2,
4,
18,
13,
13,
17,
2,
13,
17,
2,
4,
18,
13,
13,
17,
2,
13,
17,
0,
13,
17,
13,
17,
28,
13,
13,
14,
2,
13,
17,
0,
13,
17,
0,
13,
17,
0,
18,
18,
13,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
40,
18,
18,
13,
13,
13,
18,
18,
13,
13,
13,
0,
13,
17,
3,
14,
13,
4,
13,
17,
3,
4,
13,
17,
14,
2,
13,
17,
4,
13,
10,
2,
13,
10,
4,
13,
10,
12,
13
] |
[
[
184,
14
],
[
181,
19
],
[
29,
28
],
[
29,
37
],
[
41,
40
],
[
28,
43
],
[
51,
50
],
[
55,
54
],
[
28,
57
],
[
62,
61
],
[
69,
64
],
[
61,
66
],
[
72,
71
],
[
79,
78
],
[
28,
81
],
[
37,
82
],
[
86,
85
],
[
61,
90
],
[
71,
96
],
[
37,
100
],
[
71,
105
],
[
28,
109
],
[
113,
112
],
[
115,
114
],
[
118,
117
],
[
71,
117
],
[
117,
121
],
[
125,
124
],
[
128,
127
],
[
135,
130
],
[
85,
132
],
[
127,
133
],
[
112,
133
],
[
124,
134
],
[
114,
134
],
[
138,
137
],
[
141,
140
],
[
28,
143
],
[
146,
145
],
[
37,
148
],
[
50,
153
],
[
140,
154
],
[
145,
155
],
[
130,
156
],
[
85,
158
],
[
140,
159
],
[
145,
160
],
[
163,
162
],
[
188,
179
],
[
181,
182
],
[
184,
185
]
] |
[
"import sys\nfrom itertools import product\nimport copy\n\nsys.setrecursionlimit(10 ** 7)\nf_inf = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef resolve():\n H, W = map(int, input().split())\n A = [list(input()) for _ in range(H)]\n\n grid_init = [[\".\" for _ in range(W)] for _ in range(H)]\n grid_init[0][0] = \"#\"\n for pattern in product([\"L\", \"D\"], repeat=H + W - 2):\n grid = copy.deepcopy(grid_init)\n if pattern.count(\"L\") == W - 1 or pattern.count(\"D\") == H - 1:\n h, w = 0, 0\n for p in pattern:\n if p == \"L\":\n w += 1\n else:\n h += 1\n grid[h][w] = \"#\"\n\n flg = True\n for h in range(H):\n for w in range(W):\n if A[h][w] != grid[h][w]:\n flg = False\n break\n\n if flg:\n print(\"Possible\")\n break\n else:\n print(\"Impossible\")\n\n\nif __name__ == '__main__':\n resolve()",
"import sys",
"sys",
"from itertools import product",
"import copy",
"copy",
"sys.setrecursionlimit(10 ** 7)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 7",
"10",
"7",
"f_inf = float('inf')",
"f_inf",
"float('inf')",
"float",
"'inf'",
"mod = 10 ** 9 + 7",
"mod",
"10 ** 9 + 7",
"10 ** 9",
"10",
"9",
"7",
"def resolve():\n H, W = map(int, input().split())\n A = [list(input()) for _ in range(H)]\n\n grid_init = [[\".\" for _ in range(W)] for _ in range(H)]\n grid_init[0][0] = \"#\"\n for pattern in product([\"L\", \"D\"], repeat=H + W - 2):\n grid = copy.deepcopy(grid_init)\n if pattern.count(\"L\") == W - 1 or pattern.count(\"D\") == H - 1:\n h, w = 0, 0\n for p in pattern:\n if p == \"L\":\n w += 1\n else:\n h += 1\n grid[h][w] = \"#\"\n\n flg = True\n for h in range(H):\n for w in range(W):\n if A[h][w] != grid[h][w]:\n flg = False\n break\n\n if flg:\n print(\"Possible\")\n break\n else:\n print(\"Impossible\")",
"resolve",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"list(input()) for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"list(input())",
"list",
"input()",
"input",
"A = [list(input()) for _ in range(H)]",
"A",
"[list(input()) for _ in range(H)]",
"[\".\" for _ in range(W)] for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"[\".\" for _ in range(W)]",
"grid_init = [[\".\" for _ in range(W)] for _ in range(H)]",
"grid_init",
"[[\".\" for _ in range(W)] for _ in range(H)]",
"grid_init[0][0] = \"#\"",
"grid_init[0][0]",
"[0]",
"grid_init",
"0",
"0",
"\"#\"",
"for pattern in product([\"L\", \"D\"], repeat=H + W - 2):\n grid = copy.deepcopy(grid_init)\n if pattern.count(\"L\") == W - 1 or pattern.count(\"D\") == H - 1:\n h, w = 0, 0\n for p in pattern:\n if p == \"L\":\n w += 1\n else:\n h += 1\n grid[h][w] = \"#\"\n\n flg = True\n for h in range(H):\n for w in range(W):\n if A[h][w] != grid[h][w]:\n flg = False\n break\n\n if flg:\n print(\"Possible\")\n break\n else:\n print(\"Impossible\")",
"pattern",
"product([\"L\", \"D\"], repeat=H + W - 2)",
"product",
"[\"L\", \"D\"]",
"\"L\"",
"\"D\"",
"repeat=H + W - 2",
"repeat",
"H + W - 2",
"H + W",
"H",
"W",
"2",
"grid = copy.deepcopy(grid_init)",
"grid",
"copy.deepcopy(grid_init)",
"copy.deepcopy",
"copy",
"deepcopy",
"grid_init",
"if pattern.count(\"L\") == W - 1 or pattern.count(\"D\") == H - 1:\n h, w = 0, 0\n for p in pattern:\n if p == \"L\":\n w += 1\n else:\n h += 1\n grid[h][w] = \"#\"\n\n flg = True\n for h in range(H):\n for w in range(W):\n if A[h][w] != grid[h][w]:\n flg = False\n break\n\n if flg:\n print(\"Possible\")\n break\n ",
"pattern.count(\"L\") == W - 1 or pattern.count(\"D\") == H - 1",
"pattern.count(\"L\") == W - 1",
"pattern.count(\"L\")",
"pattern.count",
"pattern",
"count",
"\"L\"",
"W - 1",
"W",
"1",
"pattern.count(\"D\") == H - 1",
"pattern.count(\"D\")",
"pattern.count",
"pattern",
"count",
"\"D\"",
"H - 1",
"H",
"1",
"h, w = 0, 0",
"h",
"0",
"w",
"0",
"for p in pattern:\n if p == \"L\":\n w += 1\n else:\n h += 1\n grid[h][w] = \"#\"\n\n ",
"p",
"pattern",
"if p == \"L\":\n w += 1\n else:\n h += 1\n ",
"p == \"L\"",
"p",
"\"L\"",
"w += 1",
"w",
"1",
"h += 1",
"h",
"1",
"grid[h][w] = \"#\"",
"grid[h][w]",
"[h]",
"grid",
"h",
"w",
"\"#\"",
"flg = True",
"flg",
"True",
"for h in range(H):\n for w in range(W):\n if A[h][w] != grid[h][w]:\n flg = False\n break\n\n ",
"h",
"range(H)",
"range",
"H",
"for w in range(W):\n if A[h][w] != grid[h][w]:\n flg = False\n break\n\n ",
"w",
"range(W)",
"range",
"W",
"if A[h][w] != grid[h][w]:\n flg = False\n break\n\n ",
"A[h][w] != grid[h][w]",
"A[h][w]",
"[h]",
"A",
"h",
"w",
"grid[h][w]",
"[h]",
"grid",
"h",
"w",
"flg = False",
"flg",
"False",
"break",
"if flg:\n print(\"Possible\")\n break\n ",
"flg",
"print(\"Possible\")",
"print",
"\"Possible\"",
"break",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"if __name__ == '__main__':\n resolve()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"resolve()",
"resolve",
"mod = 10 ** 9 + 7",
"10 ** 9 + 7",
"mod",
"f_inf = float('inf')",
"float('inf')",
"f_inf",
"def resolve():\n H, W = map(int, input().split())\n A = [list(input()) for _ in range(H)]\n\n grid_init = [[\".\" for _ in range(W)] for _ in range(H)]\n grid_init[0][0] = \"#\"\n for pattern in product([\"L\", \"D\"], repeat=H + W - 2):\n grid = copy.deepcopy(grid_init)\n if pattern.count(\"L\") == W - 1 or pattern.count(\"D\") == H - 1:\n h, w = 0, 0\n for p in pattern:\n if p == \"L\":\n w += 1\n else:\n h += 1\n grid[h][w] = \"#\"\n\n flg = True\n for h in range(H):\n for w in range(W):\n if A[h][w] != grid[h][w]:\n flg = False\n break\n\n if flg:\n print(\"Possible\")\n break\n else:\n print(\"Impossible\")",
"def resolve():\n H, W = map(int, input().split())\n A = [list(input()) for _ in range(H)]\n\n grid_init = [[\".\" for _ in range(W)] for _ in range(H)]\n grid_init[0][0] = \"#\"\n for pattern in product([\"L\", \"D\"], repeat=H + W - 2):\n grid = copy.deepcopy(grid_init)\n if pattern.count(\"L\") == W - 1 or pattern.count(\"D\") == H - 1:\n h, w = 0, 0\n for p in pattern:\n if p == \"L\":\n w += 1\n else:\n h += 1\n grid[h][w] = \"#\"\n\n flg = True\n for h in range(H):\n for w in range(W):\n if A[h][w] != grid[h][w]:\n flg = False\n break\n\n if flg:\n print(\"Possible\")\n break\n else:\n print(\"Impossible\")",
"resolve"
] |
import sys
from itertools import product
import copy
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]
grid_init = [["." for _ in range(W)] for _ in range(H)]
grid_init[0][0] = "#"
for pattern in product(["L", "D"], repeat=H + W - 2):
grid = copy.deepcopy(grid_init)
if pattern.count("L") == W - 1 or pattern.count("D") == H - 1:
h, w = 0, 0
for p in pattern:
if p == "L":
w += 1
else:
h += 1
grid[h][w] = "#"
flg = True
for h in range(H):
for w in range(W):
if A[h][w] != grid[h][w]:
flg = False
break
if flg:
print("Possible")
break
else:
print("Impossible")
if __name__ == '__main__':
resolve()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
2,
13,
17,
0,
13,
2,
13,
17,
14,
2,
2,
40,
17,
13,
13,
2,
40,
17,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
4,
13,
17,
4,
13,
0,
13,
2,
13,
17,
0,
13,
2,
13,
17,
14,
2,
2,
40,
17,
13,
13,
2,
40,
17,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
4,
13,
17,
4,
13,
4,
13,
17,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
13,
13,
10,
2,
13
] |
[
[
125,
2
],
[
125,
11
],
[
15,
14
],
[
123,
17
],
[
131,
22
],
[
26,
25
],
[
123,
28
],
[
31,
30
],
[
126,
33
],
[
132,
38
],
[
25,
39
],
[
30,
40
],
[
134,
43
],
[
25,
45
],
[
116,
48
],
[
30,
50
],
[
135,
57
],
[
120,
57
],
[
123,
58
],
[
117,
62
],
[
129,
62
],
[
126,
63
],
[
132,
68
],
[
135,
69
],
[
120,
69
],
[
117,
70
],
[
129,
70
],
[
119,
78
],
[
25,
80
],
[
128,
83
],
[
30,
85
],
[
120,
92
],
[
135,
92
],
[
123,
93
],
[
129,
97
],
[
117,
97
],
[
126,
98
],
[
132,
103
],
[
120,
104
],
[
135,
104
],
[
129,
105
],
[
117,
105
],
[
116,
117
],
[
119,
120
],
[
125,
123
],
[
125,
126
],
[
128,
129
],
[
131,
132
],
[
134,
135
]
] |
[
"H,W = map(int,input().split())\n\na = [input() for _ in range(H)]\n\nfor i in range(H):\n for j in range(W):\n if a[i][j] == \"#\":\n x = i-1\n y = j+1\n\n if 0 <= x < H and 0 <= y < W:\n if a[x][y] == \"#\":\n print(\"Impossible\")\n exit()\n \n x = i+1\n y = j-1\n if 0 <= x < H and 0 <= y < W:\n if a[x][y] == \"#\":\n print(\"Impossible\")\n exit()\nprint(\"Possible\")",
"H,W = map(int,input().split())",
"H",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"input() for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"input()",
"input",
"a = [input() for _ in range(H)]",
"a",
"[input() for _ in range(H)]",
"for i in range(H):\n for j in range(W):\n if a[i][j] == \"#\":\n x = i-1\n y = j+1\n\n if 0 <= x < H and 0 <= y < W:\n if a[x][y] == \"#\":\n print(\"Impossible\")\n exit()\n \n x = i+1\n y = j-1\n if 0 <= x < H and 0 <= y < W:\n if a[x][y] == \"#\":\n print(\"Impossible\")\n exit()",
"i",
"range(H)",
"range",
"H",
"for j in range(W):\n if a[i][j] == \"#\":\n x = i-1\n y = j+1\n\n if 0 <= x < H and 0 <= y < W:\n if a[x][y] == \"#\":\n print(\"Impossible\")\n exit()\n \n x = i+1\n y = j-1\n if 0 <= x < H and 0 <= y < W:\n if a[x][y] == \"#\":\n print(\"Impossible\")\n exit()",
"j",
"range(W)",
"range",
"W",
"if a[i][j] == \"#\":\n x = i-1\n y = j+1\n\n if 0 <= x < H and 0 <= y < W:\n if a[x][y] == \"#\":\n print(\"Impossible\")\n exit()\n \n x = i+1\n y = j-1\n if 0 <= x < H and 0 <= y < W:\n if a[x][y] == \"#\":\n print(\"Impossible\")\n exit()",
"a[i][j] == \"#\"",
"a[i][j]",
"[i]",
"a",
"i",
"j",
"\"#\"",
"x = i-1",
"x",
"i-1",
"i",
"1",
"y = j+1",
"y",
"j+1",
"j",
"1",
"if 0 <= x < H and 0 <= y < W:\n if a[x][y] == \"#\":\n print(\"Impossible\")\n exit()\n \n ",
"0 <= x < H and 0 <= y < W",
"0 <= x < H",
"0 <= x",
"0",
"x",
"H",
"0 <= y < W",
"0 <= y",
"0",
"y",
"W",
"if a[x][y] == \"#\":\n print(\"Impossible\")\n exit()\n \n ",
"a[x][y] == \"#\"",
"a[x][y]",
"[x]",
"a",
"x",
"y",
"\"#\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"exit()",
"exit",
"x = i+1",
"x",
"i+1",
"i",
"1",
"y = j-1",
"y",
"j-1",
"j",
"1",
"if 0 <= x < H and 0 <= y < W:\n if a[x][y] == \"#\":\n print(\"Impossible\")\n exit()",
"0 <= x < H and 0 <= y < W",
"0 <= x < H",
"0 <= x",
"0",
"x",
"H",
"0 <= y < W",
"0 <= y",
"0",
"y",
"W",
"if a[x][y] == \"#\":\n print(\"Impossible\")\n exit()",
"a[x][y] == \"#\"",
"a[x][y]",
"[x]",
"a",
"x",
"y",
"\"#\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"exit()",
"exit",
"print(\"Possible\")",
"print",
"\"Possible\"",
"y = j+1",
"j+1",
"y",
"x = i+1",
"i+1",
"x",
"H,W = map(int,input().split())",
"map(int,input().split())",
"H",
"W = map(int,input().split())",
"map(int,input().split())",
"W",
"y = j-1",
"j-1",
"y",
"a = [input() for _ in range(H)]",
"[input() for _ in range(H)]",
"a",
"x = i-1",
"i-1",
"x"
] |
H,W = map(int,input().split())
a = [input() for _ in range(H)]
for i in range(H):
for j in range(W):
if a[i][j] == "#":
x = i-1
y = j+1
if 0 <= x < H and 0 <= y < W:
if a[x][y] == "#":
print("Impossible")
exit()
x = i+1
y = j-1
if 0 <= x < H and 0 <= y < W:
if a[x][y] == "#":
print("Impossible")
exit()
print("Possible")
|
[
7,
15,
13,
15,
13,
15,
13,
15,
13,
15,
15,
15,
15,
15,
4,
18,
13,
13,
2,
17,
17,
0,
13,
2,
17,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
2,
4,
13,
17,
0,
13,
13,
4,
18,
13,
13,
2,
17,
2,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
17,
13,
10,
2,
13,
10,
18,
13,
10,
2,
13,
10,
13,
13,
10,
18,
13,
10,
4,
13,
10,
18,
13,
10,
4,
13,
10,
17,
13
] |
[
[
138,
22
],
[
144,
27
],
[
141,
34
],
[
150,
43
],
[
156,
52
],
[
159,
61
],
[
159,
72
],
[
76,
75
],
[
154,
78
],
[
147,
85
],
[
148,
89
],
[
160,
94
],
[
135,
97
],
[
101,
100
],
[
154,
103
],
[
106,
105
],
[
160,
108
],
[
148,
113
],
[
100,
114
],
[
105,
115
],
[
162,
118
],
[
163,
122
],
[
136,
122
],
[
154,
125
],
[
160,
126
],
[
135,
136
],
[
138,
139
],
[
141,
142
],
[
144,
145
],
[
147,
148
],
[
150,
151
],
[
159,
154
],
[
156,
157
],
[
159,
160
],
[
162,
163
]
] |
[
"import sys\nimport itertools\n# import numpy as np\nimport time\nimport math\nfrom heapq import heappop, heappush\nfrom collections import defaultdict\nfrom collections import Counter\nfrom collections import deque\nfrom itertools import permutations\nsys.setrecursionlimit(10 ** 7)\n \nINF = 10 ** 18\nMOD = 10 ** 9 + 7\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\n# map(int, input().split())\nH, W = list(map(int, input().split()))\nA = [input() + '.' for _ in range(H)]\nA.append('.' * (W + 1))\n\ncnt = 0\nfor i in range(H):\n for j in range(W):\n if A[i][j] == '#':\n cnt += 1\nif cnt == H + W - 1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")\n\n# cur = (0, 0)\n# while True:\n# x, y = cur\n# if x == W - 1 and y == H - 1:\n# print(\"Possible\")\n# break\n# nx1, ny1 = x + 1, y\n# nx2, ny2 = x, y + 1\n# if A[ny1][nx1] == '#' and A[ny2][nx2] == '#':\n# print(\"Impossible\")\n# break\n# if A[ny1][nx1] == '#':\n# cur = (nx1, ny1)\n# elif A[ny2][nx2] == '#':\n# cur = (nx2, ny2)\n# else:\n# print(\"Impossible\")\n# break\n\n",
"import sys",
"sys",
"import itertools",
"itertools",
"import time",
"time",
"import math",
"math",
"from heapq import heappop, heappush",
"from collections import defaultdict",
"from collections import Counter",
"from collections import deque",
"from itertools import permutations",
"sys.setrecursionlimit(10 ** 7)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 7",
"10",
"7",
"INF = 10 ** 18",
"INF",
"10 ** 18",
"10",
"18",
"MOD = 10 ** 9 + 7",
"MOD",
"10 ** 9 + 7",
"10 ** 9",
"10",
"9",
"7",
"read = sys.stdin.buffer.read",
"read",
"sys.stdin.buffer.read",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"read",
"readline = sys.stdin.buffer.readline",
"readline",
"sys.stdin.buffer.readline",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readline",
"readlines = sys.stdin.buffer.readlines",
"readlines",
"sys.stdin.buffer.readlines",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readlines",
"H, W = list(map(int, input().split()))",
"H",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"input() + '.' for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"input() + '.'",
"input()",
"input",
"'.'",
"A = [input() + '.' for _ in range(H)]",
"A",
"[input() + '.' for _ in range(H)]",
"A.append('.' * (W + 1))",
"A.append",
"A",
"append",
"'.' * (W + 1)",
"'.'",
"W + 1",
"W",
"1",
"cnt = 0",
"cnt",
"0",
"for i in range(H):\n for j in range(W):\n if A[i][j] == '#':\n cnt += 1",
"i",
"range(H)",
"range",
"H",
"for j in range(W):\n if A[i][j] == '#':\n cnt += 1",
"j",
"range(W)",
"range",
"W",
"if A[i][j] == '#':\n cnt += 1",
"A[i][j] == '#'",
"A[i][j]",
"[i]",
"A",
"i",
"j",
"'#'",
"cnt += 1",
"cnt",
"1",
"if cnt == H + W - 1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")\n\n# cur = (0, 0)\n# while True:\n# x, y = cur\n# if x == W - 1 and y == H - 1:\n# print(\"Possible\")\n# break\n# nx1, ny1 = x + 1, y\n# nx2, ny2 = x, y + 1\n# if A[ny1][nx1] == '#' and A[ny2][nx2] == '#':\n# print(\"Impossible\")\n# break\n# if A[ny1][nx1] == '#':\n# cur = (nx1, ny1)\n# elif A[ny2][nx2] == '#':\n# cur = (nx2, ny2)\n# else:\n# print(\"Impossible\")\n# break",
"cnt == H + W - 1",
"cnt",
"H + W - 1",
"H + W",
"H",
"W",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"cnt = 0",
"0",
"cnt",
"INF = 10 ** 18",
"10 ** 18",
"INF",
"read = sys.stdin.buffer.read",
"sys.stdin.buffer.read",
"read",
"MOD = 10 ** 9 + 7",
"10 ** 9 + 7",
"MOD",
"A = [input() + '.' for _ in range(H)]",
"[input() + '.' for _ in range(H)]",
"A",
"readline = sys.stdin.buffer.readline",
"sys.stdin.buffer.readline",
"readline",
"H, W = list(map(int, input().split()))",
"list(map(int, input().split()))",
"H",
"readlines = sys.stdin.buffer.readlines",
"sys.stdin.buffer.readlines",
"readlines",
"W = list(map(int, input().split()))",
"list(map(int, input().split()))",
"W",
"cnt += 1",
"1",
"cnt"
] |
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# map(int, input().split())
H, W = list(map(int, input().split()))
A = [input() + '.' for _ in range(H)]
A.append('.' * (W + 1))
cnt = 0
for i in range(H):
for j in range(W):
if A[i][j] == '#':
cnt += 1
if cnt == H + W - 1:
print("Possible")
else:
print("Impossible")
# cur = (0, 0)
# while True:
# x, y = cur
# if x == W - 1 and y == H - 1:
# print("Possible")
# break
# nx1, ny1 = x + 1, y
# nx2, ny2 = x, y + 1
# if A[ny1][nx1] == '#' and A[ny2][nx2] == '#':
# print("Impossible")
# break
# if A[ny1][nx1] == '#':
# cur = (nx1, ny1)
# elif A[ny2][nx2] == '#':
# cur = (nx2, ny2)
# else:
# print("Impossible")
# break
|
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
0,
13,
17,
0,
13,
17,
0,
18,
18,
13,
13,
13,
17,
42,
17,
14,
2,
2,
13,
2,
13,
17,
2,
18,
18,
13,
13,
2,
13,
17,
17,
0,
13,
2,
13,
17,
0,
18,
18,
13,
13,
13,
17,
14,
2,
2,
13,
2,
13,
17,
2,
18,
18,
13,
2,
13,
17,
13,
17,
0,
13,
2,
13,
17,
0,
18,
18,
13,
13,
13,
17,
14,
2,
2,
13,
2,
13,
17,
2,
18,
18,
13,
2,
13,
17,
13,
17,
4,
13,
17,
4,
13,
3,
28,
13,
13,
14,
2,
17,
13,
4,
13,
17,
4,
13,
4,
13,
17,
10,
4,
13,
10,
2,
13,
10,
13,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13
] |
[
[
152,
2
],
[
152,
13
],
[
17,
16
],
[
138,
19
],
[
143,
26
],
[
155,
29
],
[
146,
32
],
[
40,
35
],
[
144,
37
],
[
147,
38
],
[
156,
39
],
[
156,
46
],
[
150,
46
],
[
153,
48
],
[
144,
53
],
[
147,
54
],
[
141,
54
],
[
156,
56
],
[
150,
56
],
[
149,
60
],
[
156,
62
],
[
150,
62
],
[
70,
65
],
[
144,
67
],
[
147,
68
],
[
141,
68
],
[
150,
69
],
[
156,
69
],
[
147,
74
],
[
141,
74
],
[
138,
76
],
[
144,
81
],
[
147,
83
],
[
141,
83
],
[
156,
85
],
[
150,
85
],
[
140,
88
],
[
147,
90
],
[
141,
90
],
[
98,
93
],
[
144,
95
],
[
141,
96
],
[
147,
96
],
[
156,
97
],
[
150,
97
],
[
147,
102
],
[
141,
102
],
[
138,
104
],
[
144,
109
],
[
147,
111
],
[
141,
111
],
[
156,
113
],
[
150,
113
],
[
123,
122
],
[
144,
122
],
[
122,
127
],
[
152,
138
],
[
140,
141
],
[
143,
144
],
[
146,
147
],
[
149,
150
],
[
152,
153
],
[
155,
156
]
] |
[
"H,W = list(map(int,input().split()))\nA = [list(input()) for _ in range(H)]\nx = 0\ny = 0\nA[y][x] = 'x'\nwhile True:\n if x < W-1 and A[y][x+1] == '#':\n x = x+1\n A[y][x] = 'x'\n elif y < H-1 and A[y+1][x] == '#':\n y = y+1\n A[y][x] = 'x'\n elif y < H-1 and A[y+1][x] == '.':\n print('Impossible')\n exit()\n else:\n break\nfor a in A:\n if '#' in a:\n print('Impossible')\n exit()\nprint('Possible')",
"H,W = list(map(int,input().split()))",
"H",
"list(map(int,input().split()))",
"list",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"list(input()) for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"list(input())",
"list",
"input()",
"input",
"A = [list(input()) for _ in range(H)]",
"A",
"[list(input()) for _ in range(H)]",
"x = 0",
"x",
"0",
"y = 0",
"y",
"0",
"A[y][x] = 'x'",
"A[y][x]",
"[y]",
"A",
"y",
"x",
"'x'",
"while True:\n if x < W-1 and A[y][x+1] == '#':\n x = x+1\n A[y][x] = 'x'\n elif y < H-1 and A[y+1][x] == '#':\n y = y+1\n A[y][x] = 'x'\n elif y < H-1 and A[y+1][x] == '.':\n print('Impossible')\n exit()\n else:\n break",
"True",
"if x < W-1 and A[y][x+1] == '#':\n x = x+1\n A[y][x] = 'x'\n elif y < H-1 and A[y+1][x] == '#':\n y = y+1\n A[y][x] = 'x'\n elif y < H-1 and A[y+1][x] == '.':\n print('Impossible')\n exit()\n else:\n break",
"x < W-1 and A[y][x+1] == '#'",
"x < W-1",
"x",
"W-1",
"W",
"1",
"A[y][x+1] == '#'",
"A[y][x+1]",
"[y]",
"A",
"y",
"x+1",
"x",
"1",
"'#'",
"x = x+1",
"x",
"x+1",
"x",
"1",
"A[y][x] = 'x'",
"A[y][x]",
"[y]",
"A",
"y",
"x",
"'x'",
"elif y < H-1 and A[y+1][x] == '#':\n y = y+1\n A[y][x] = 'x'\n ",
"y < H-1 and A[y+1][x] == '#'",
"y < H-1",
"y",
"H-1",
"H",
"1",
"A[y+1][x] == '#'",
"A[y+1][x]",
"[y+1]",
"A",
"y+1",
"y",
"1",
"x",
"'#'",
"y = y+1",
"y",
"y+1",
"y",
"1",
"A[y][x] = 'x'",
"A[y][x]",
"[y]",
"A",
"y",
"x",
"'x'",
"elif y < H-1 and A[y+1][x] == '.':\n print('Impossible')\n exit()\n ",
"y < H-1 and A[y+1][x] == '.'",
"y < H-1",
"y",
"H-1",
"H",
"1",
"A[y+1][x] == '.'",
"A[y+1][x]",
"[y+1]",
"A",
"y+1",
"y",
"1",
"x",
"'.'",
"print('Impossible')",
"print",
"'Impossible'",
"exit()",
"exit",
"break",
"for a in A:\n if '#' in a:\n print('Impossible')\n exit()",
"a",
"A",
"if '#' in a:\n print('Impossible')\n exit()",
"'#' in a",
"'#'",
"a",
"print('Impossible')",
"print",
"'Impossible'",
"exit()",
"exit",
"print('Possible')",
"print",
"'Possible'",
"H,W = list(map(int,input().split()))",
"list(map(int,input().split()))",
"H",
"y = y+1",
"y+1",
"y",
"A = [list(input()) for _ in range(H)]",
"[list(input()) for _ in range(H)]",
"A",
"y = 0",
"0",
"y",
"x = x+1",
"x+1",
"x",
"W = list(map(int,input().split()))",
"list(map(int,input().split()))",
"W",
"x = 0",
"0",
"x"
] |
H,W = list(map(int,input().split()))
A = [list(input()) for _ in range(H)]
x = 0
y = 0
A[y][x] = 'x'
while True:
if x < W-1 and A[y][x+1] == '#':
x = x+1
A[y][x] = 'x'
elif y < H-1 and A[y+1][x] == '#':
y = y+1
A[y][x] = 'x'
elif y < H-1 and A[y+1][x] == '.':
print('Impossible')
exit()
else:
break
for a in A:
if '#' in a:
print('Impossible')
exit()
print('Possible')
|
[
7,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
0,
13,
17,
13,
17,
42,
2,
2,
13,
2,
13,
17,
2,
13,
2,
13,
17,
14,
2,
2,
2,
2,
2,
2,
13,
17,
13,
40,
18,
18,
13,
2,
13,
17,
13,
17,
2,
2,
2,
13,
17,
13,
40,
18,
18,
13,
13,
2,
13,
17,
17,
2,
2,
2,
2,
13,
17,
13,
2,
2,
13,
17,
13,
40,
18,
18,
13,
13,
2,
13,
17,
17,
2,
2,
2,
2,
13,
17,
13,
2,
2,
13,
17,
13,
40,
18,
18,
13,
2,
13,
17,
13,
17,
0,
13,
17,
3,
14,
2,
2,
2,
13,
17,
13,
2,
18,
18,
13,
13,
2,
13,
17,
17,
0,
18,
13,
13,
2,
2,
18,
18,
13,
13,
39,
13,
17,
18,
18,
13,
13,
39,
2,
13,
17,
0,
13,
17,
14,
2,
2,
2,
13,
17,
13,
2,
18,
18,
13,
2,
13,
17,
13,
17,
0,
18,
13,
13,
2,
2,
18,
18,
13,
13,
39,
13,
17,
18,
18,
13,
13,
39,
2,
13,
17,
0,
13,
17,
14,
2,
13,
17,
0,
18,
13,
2,
13,
17,
2,
18,
18,
13,
2,
13,
17,
39,
2,
13,
17,
17,
28,
13,
13,
14,
2,
17,
13,
0,
13,
17,
3,
4,
13,
13,
10,
17,
13,
10,
13,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13
] |
[
[
4,
3
],
[
3,
12
],
[
252,
14
],
[
252,
16
],
[
20,
19
],
[
250,
22
],
[
267,
27
],
[
264,
30
],
[
246,
33
],
[
255,
35
],
[
247,
40
],
[
271,
40
],
[
250,
42
],
[
256,
45
],
[
274,
45
],
[
253,
47
],
[
247,
56
],
[
271,
56
],
[
250,
58
],
[
268,
62
],
[
247,
64
],
[
271,
64
],
[
256,
66
],
[
274,
66
],
[
256,
71
],
[
274,
71
],
[
253,
73
],
[
186,
76
],
[
146,
76
],
[
268,
77
],
[
247,
78
],
[
271,
78
],
[
256,
80
],
[
274,
80
],
[
247,
87
],
[
271,
87
],
[
250,
89
],
[
256,
92
],
[
274,
92
],
[
253,
94
],
[
186,
97
],
[
146,
97
],
[
268,
98
],
[
247,
99
],
[
271,
99
],
[
256,
101
],
[
274,
101
],
[
247,
108
],
[
271,
108
],
[
250,
110
],
[
256,
113
],
[
274,
113
],
[
253,
115
],
[
268,
119
],
[
247,
121
],
[
271,
121
],
[
256,
123
],
[
274,
123
],
[
258,
126
],
[
256,
133
],
[
274,
133
],
[
253,
135
],
[
186,
138
],
[
146,
138
],
[
268,
139
],
[
247,
140
],
[
271,
140
],
[
256,
142
],
[
274,
142
],
[
149,
146
],
[
268,
147
],
[
247,
148
],
[
271,
148
],
[
186,
152
],
[
146,
152
],
[
268,
153
],
[
247,
154
],
[
271,
154
],
[
186,
159
],
[
146,
159
],
[
268,
160
],
[
247,
161
],
[
271,
161
],
[
256,
164
],
[
274,
164
],
[
273,
167
],
[
247,
173
],
[
271,
173
],
[
250,
175
],
[
268,
179
],
[
247,
181
],
[
271,
181
],
[
256,
183
],
[
274,
183
],
[
189,
186
],
[
268,
187
],
[
247,
188
],
[
271,
188
],
[
186,
192
],
[
146,
192
],
[
268,
193
],
[
247,
194
],
[
271,
194
],
[
186,
199
],
[
146,
199
],
[
268,
200
],
[
247,
201
],
[
271,
201
],
[
256,
204
],
[
274,
204
],
[
270,
207
],
[
259,
211
],
[
265,
211
],
[
219,
214
],
[
268,
215
],
[
250,
217
],
[
268,
222
],
[
250,
224
],
[
253,
228
],
[
233,
232
],
[
268,
232
],
[
232,
237
],
[
261,
239
],
[
262,
244
],
[
259,
244
],
[
265,
244
],
[
246,
247
],
[
252,
250
],
[
252,
253
],
[
255,
256
],
[
258,
259
],
[
261,
262
],
[
264,
265
],
[
267,
268
],
[
270,
271
],
[
273,
274
]
] |
[
"# AGC 007: A – Shik and Stone\nH, W = [int(s) for s in input().split()]\nA = [input() for _ in range(H)]\n\nisExact = 'Possible'\n\ni, j = 0, 0\n\nwhile i < H - 1 or j < W - 1:\n if ((i + 1 < H and A[i + 1][j] != '#') and (j + 1 < W and A[i][j + 1] != '#')) \\\n or (i + 1 == H and j + 1 < W and A[i][j + 1] != '#') \\\n or (i + 1 < H and j + 1 == W and A[i + 1][j] != '#'):\n isExact = 'Impossible'\n break\n elif j + 1 < W and A[i][j + 1] == '#':\n A[i] = A[i][:j] + '.' + A[i][j + 1:]\n j += 1\n elif i + 1 < H and A[i + 1][j] == '#':\n A[i] = A[i][:j] + '.' + A[i][j + 1:]\n i += 1\n\nif isExact == 'Possible':\n A[H - 1] = A[H - 1][:W - 1] + '.'\n\n for line in A:\n if '#' in line:\n isExact = 'Impossible'\n break\n\nprint(isExact)",
"int(s) for s in input().split()",
"for s in input().split()",
"s",
"input().split()",
"().split",
"()",
"input",
"split",
"for s in input().split()",
"int(s)",
"int",
"s",
"H, W = [int(s) for s in input().split()]",
"H",
"[int(s) for s in input().split()]",
"W",
"input() for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"input()",
"input",
"A = [input() for _ in range(H)]",
"A",
"[input() for _ in range(H)]",
"isExact = 'Possible'",
"isExact",
"'Possible'",
"i, j = 0, 0",
"i",
"0",
"j",
"0",
"while i < H - 1 or j < W - 1:\n if ((i + 1 < H and A[i + 1][j] != '#') and (j + 1 < W and A[i][j + 1] != '#')) \\\n or (i + 1 == H and j + 1 < W and A[i][j + 1] != '#') \\\n or (i + 1 < H and j + 1 == W and A[i + 1][j] != '#'):\n isExact = 'Impossible'\n break\n elif j + 1 < W and A[i][j + 1] == '#':\n A[i] = A[i][:j] + '.' + A[i][j + 1:]\n j += 1\n elif i + 1 < H and A[i + 1][j] == '#':\n A[i] = A[i][:j] + '.' + A[i][j + 1:]\n i += 1",
"i < H - 1 or j < W - 1",
"i < H - 1",
"i",
"H - 1",
"H",
"1",
"j < W - 1",
"j",
"W - 1",
"W",
"1",
"if ((i + 1 < H and A[i + 1][j] != '#') and (j + 1 < W and A[i][j + 1] != '#')) \\\n or (i + 1 == H and j + 1 < W and A[i][j + 1] != '#') \\\n or (i + 1 < H and j + 1 == W and A[i + 1][j] != '#'):\n isExact = 'Impossible'\n break\n elif j + 1 < W and A[i][j + 1] == '#':\n A[i] = A[i][:j] + '.' + A[i][j + 1:]\n j += 1\n elif i + 1 < H and A[i + 1][j] == '#':\n A[i] = A[i][:j] + '.' + A[i][j + 1:]\n i += 1",
"((i + 1 < H and A[i + 1][j] != '#') and (j + 1 < W and A[i][j + 1] != '#')) \\\n or (i + 1 == H and j + 1 < W and A[i][j + 1] != '#') \\\n or (i + 1 < H and j + 1 == W and A[i + 1][j] != '#')",
"((i + 1 < H and A[i + 1][j] != '#') and (j + 1 < W and A[i][j + 1] != '#')) \\\n or (i + 1 == H and j + 1 < W and A[i][j + 1] != '#')",
"(i + 1 < H and A[i + 1][j] != '#') and (j + 1 < W and A[i][j + 1] != '#')",
"i + 1 < H and A[i + 1][j] != '#'",
"i + 1 < H",
"i + 1",
"i",
"1",
"H",
"A[i + 1][j] != '#'",
"A[i + 1][j]",
"[i + 1]",
"A",
"i + 1",
"i",
"1",
"j",
"'#'",
"j + 1 < W and A[i][j + 1] != '#'",
"j + 1 < W",
"j + 1",
"j",
"1",
"W",
"A[i][j + 1] != '#'",
"A[i][j + 1]",
"[i]",
"A",
"i",
"j + 1",
"j",
"1",
"'#'",
"i + 1 == H and j + 1 < W and A[i][j + 1] != '#'",
"i + 1 == H and j + 1 < W",
"i + 1 == H",
"i + 1",
"i",
"1",
"H",
"j + 1 < W",
"j + 1",
"j",
"1",
"W",
"A[i][j + 1] != '#'",
"A[i][j + 1]",
"[i]",
"A",
"i",
"j + 1",
"j",
"1",
"'#'",
"i + 1 < H and j + 1 == W and A[i + 1][j] != '#'",
"i + 1 < H and j + 1 == W",
"i + 1 < H",
"i + 1",
"i",
"1",
"H",
"j + 1 == W",
"j + 1",
"j",
"1",
"W",
"A[i + 1][j] != '#'",
"A[i + 1][j]",
"[i + 1]",
"A",
"i + 1",
"i",
"1",
"j",
"'#'",
"isExact = 'Impossible'",
"isExact",
"'Impossible'",
"break",
"elif j + 1 < W and A[i][j + 1] == '#':\n A[i] = A[i][:j] + '.' + A[i][j + 1:]\n j += 1\n ",
"j + 1 < W and A[i][j + 1] == '#'",
"j + 1 < W",
"j + 1",
"j",
"1",
"W",
"A[i][j + 1] == '#'",
"A[i][j + 1]",
"[i]",
"A",
"i",
"j + 1",
"j",
"1",
"'#'",
"A[i] = A[i][:j] + '.' + A[i][j + 1:]",
"A[i]",
"A",
"i",
"A[i][:j] + '.' + A[i][j + 1:]",
"A[i][:j] + '.'",
"A[i][:j]",
"[i]",
"A",
"i",
":j",
"j",
"'.'",
"A[i][j + 1:]",
"[i]",
"A",
"i",
"j + 1:",
"j + 1",
"j",
"1",
"j += 1",
"j",
"1",
"elif i + 1 < H and A[i + 1][j] == '#':\n A[i] = A[i][:j] + '.' + A[i][j + 1:]\n i += 1",
"i + 1 < H and A[i + 1][j] == '#'",
"i + 1 < H",
"i + 1",
"i",
"1",
"H",
"A[i + 1][j] == '#'",
"A[i + 1][j]",
"[i + 1]",
"A",
"i + 1",
"i",
"1",
"j",
"'#'",
"A[i] = A[i][:j] + '.' + A[i][j + 1:]",
"A[i]",
"A",
"i",
"A[i][:j] + '.' + A[i][j + 1:]",
"A[i][:j] + '.'",
"A[i][:j]",
"[i]",
"A",
"i",
":j",
"j",
"'.'",
"A[i][j + 1:]",
"[i]",
"A",
"i",
"j + 1:",
"j + 1",
"j",
"1",
"i += 1",
"i",
"1",
"if isExact == 'Possible':\n A[H - 1] = A[H - 1][:W - 1] + '.'\n\n for line in A:\n if '#' in line:\n isExact = 'Impossible'\n break",
"isExact == 'Possible'",
"isExact",
"'Possible'",
"A[H - 1] = A[H - 1][:W - 1] + '.'",
"A[H - 1]",
"A",
"H - 1",
"H",
"1",
"A[H - 1][:W - 1] + '.'",
"A[H - 1][:W - 1]",
"[H - 1]",
"A",
"H - 1",
"H",
"1",
":W - 1",
"W - 1",
"W",
"1",
"'.'",
"for line in A:\n if '#' in line:\n isExact = 'Impossible'\n break",
"line",
"A",
"if '#' in line:\n isExact = 'Impossible'\n break",
"'#' in line",
"'#'",
"line",
"isExact = 'Impossible'",
"isExact",
"'Impossible'",
"break",
"print(isExact)",
"print",
"isExact",
"i, j = 0, 0",
"0",
"i",
"H, W = [int(s) for s in input().split()]",
"[int(s) for s in input().split()]",
"H",
"W = [int(s) for s in input().split()]",
"[int(s) for s in input().split()]",
"W",
"j = 0, 0",
"0",
"j",
"isExact = 'Impossible'",
"'Impossible'",
"isExact",
"isExact = 'Impossible'",
"'Impossible'",
"isExact",
"isExact = 'Possible'",
"'Possible'",
"isExact",
"A = [input() for _ in range(H)]",
"[input() for _ in range(H)]",
"A",
"i += 1",
"1",
"i",
"j += 1",
"1",
"j"
] |
# AGC 007: A – Shik and Stone
H, W = [int(s) for s in input().split()]
A = [input() for _ in range(H)]
isExact = 'Possible'
i, j = 0, 0
while i < H - 1 or j < W - 1:
if ((i + 1 < H and A[i + 1][j] != '#') and (j + 1 < W and A[i][j + 1] != '#')) \
or (i + 1 == H and j + 1 < W and A[i][j + 1] != '#') \
or (i + 1 < H and j + 1 == W and A[i + 1][j] != '#'):
isExact = 'Impossible'
break
elif j + 1 < W and A[i][j + 1] == '#':
A[i] = A[i][:j] + '.' + A[i][j + 1:]
j += 1
elif i + 1 < H and A[i + 1][j] == '#':
A[i] = A[i][:j] + '.' + A[i][j + 1:]
i += 1
if isExact == 'Possible':
A[H - 1] = A[H - 1][:W - 1] + '.'
for line in A:
if '#' in line:
isExact = 'Impossible'
break
print(isExact)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
13,
4,
18,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
14,
2,
13,
13,
4,
13,
17,
4,
13,
0,
13,
13,
4,
13,
17,
10,
4,
13,
10,
39,
13,
10,
17,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13
] |
[
[
86,
2
],
[
86,
11
],
[
74,
13
],
[
17,
16
],
[
87,
19
],
[
71,
21
],
[
75,
31
],
[
72,
33
],
[
77,
35
],
[
39,
38
],
[
87,
41
],
[
44,
43
],
[
84,
46
],
[
75,
51
],
[
38,
52
],
[
43,
53
],
[
43,
57
],
[
78,
58
],
[
81,
58
],
[
80,
65
],
[
43,
66
],
[
71,
72
],
[
74,
75
],
[
77,
78
],
[
43,
80
],
[
80,
81
],
[
86,
84
],
[
86,
87
]
] |
[
"h,w = map(int,input().split())\nl = []\nfor _ in range(h):\n a = list(map(str,input()))\n l.append(a)\n\ntmp = 0\n\nfor i in range(h):\n for j in range(w):\n if l[i][j] == \"#\":\n if j < tmp:\n print(\"Impossible\")\n exit()\n else:\n tmp = j\n\n\nprint(\"Possible\")",
"h,w = map(int,input().split())",
"h",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"l = []",
"l",
"[]",
"for _ in range(h):\n a = list(map(str,input()))\n l.append(a)",
"_",
"range(h)",
"range",
"h",
"a = list(map(str,input()))",
"a",
"list(map(str,input()))",
"list",
"map(str,input())",
"map",
"str",
"input()",
"input",
"l.append(a)",
"l.append",
"l",
"append",
"a",
"tmp = 0",
"tmp",
"0",
"for i in range(h):\n for j in range(w):\n if l[i][j] == \"#\":\n if j < tmp:\n print(\"Impossible\")\n exit()\n else:\n tmp = j",
"i",
"range(h)",
"range",
"h",
"for j in range(w):\n if l[i][j] == \"#\":\n if j < tmp:\n print(\"Impossible\")\n exit()\n else:\n tmp = j",
"j",
"range(w)",
"range",
"w",
"if l[i][j] == \"#\":\n if j < tmp:\n print(\"Impossible\")\n exit()\n else:\n tmp = j",
"l[i][j] == \"#\"",
"l[i][j]",
"[i]",
"l",
"i",
"j",
"\"#\"",
"if j < tmp:\n print(\"Impossible\")\n exit()\n else:\n tmp = j",
"j < tmp",
"j",
"tmp",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"exit()",
"exit",
"tmp = j",
"tmp",
"j",
"print(\"Possible\")",
"print",
"\"Possible\"",
"a = list(map(str,input()))",
"list(map(str,input()))",
"a",
"l = []",
"[]",
"l",
"tmp = 0",
"0",
"tmp",
"tmp = j",
"j",
"tmp",
"w = map(int,input().split())",
"map(int,input().split())",
"w",
"h,w = map(int,input().split())",
"map(int,input().split())",
"h"
] |
h,w = map(int,input().split())
l = []
for _ in range(h):
a = list(map(str,input()))
l.append(a)
tmp = 0
for i in range(h):
for j in range(w):
if l[i][j] == "#":
if j < tmp:
print("Impossible")
exit()
else:
tmp = j
print("Possible")
|
[
7,
15,
13,
15,
15,
12,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
41,
28,
13,
4,
13,
4,
13,
0,
13,
13,
42,
2,
2,
2,
18,
13,
13,
17,
2,
2,
13,
17,
13,
2,
18,
13,
2,
13,
17,
17,
0,
18,
13,
13,
17,
0,
13,
17,
14,
2,
2,
18,
13,
13,
17,
40,
4,
18,
13,
13,
17,
17,
0,
13,
17,
14,
13,
4,
13,
17,
4,
13,
17,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
13,
4,
13,
17,
10,
17,
13,
10,
4,
13,
10,
12,
13
] |
[
[
10,
9
],
[
9,
18
],
[
21,
20
],
[
21,
22
],
[
25,
24
],
[
28,
27
],
[
31,
30
],
[
20,
33
],
[
37,
36
],
[
36,
40
],
[
43,
42
],
[
65,
48
],
[
42,
49
],
[
24,
50
],
[
70,
50
],
[
24,
54
],
[
70,
54
],
[
22,
56
],
[
42,
59
],
[
24,
61
],
[
70,
61
],
[
68,
65
],
[
42,
66
],
[
24,
67
],
[
70,
67
],
[
71,
70
],
[
65,
75
],
[
42,
76
],
[
70,
77
],
[
24,
77
],
[
42,
82
],
[
88,
87
],
[
114,
98
],
[
102,
101
],
[
115,
106
],
[
117,
109
],
[
121,
111
],
[
114,
115
],
[
117,
118
]
] |
[
"# -*- coding: utf-8 -*-\nimport sys\nfrom collections import deque, defaultdict\nfrom math import sqrt, factorial, gcd\n# def input(): return sys.stdin.readline()[:-1] # warning not \\n\n# def input(): return sys.stdin.buffer.readline().strip() # warning bytes\n# def input(): return sys.stdin.buffer.readline().decode('utf-8')\n\n\ndef solve():\n n, w = [int(x) for x in input().split()]\n j = 0\n ok = 1\n for i in range(n):\n r = [x for x in input()]\n while r[j] == '#' and j+1 < w and r[j+1] == '#':\n r[j] = '.'\n j += 1\n if r[j] == '.' or r.count('#') != 1:\n ok = 0\n\n\n if ok:\n print(\"Possible\")\n else:\n print(\"Impossible\")\n\n \n\n\n\n\n \n \n\n \n \n\nt = 1\n# t = int(input())\nfor case in range(1,t+1):\n ans = solve()\n\n\n\"\"\"\n\n2 2 2 2 2\n\n\"\"\"",
"import sys",
"sys",
"from collections import deque, defaultdict",
"from math import sqrt, factorial, gcd",
"def solve():\n n, w = [int(x) for x in input().split()]\n j = 0\n ok = 1\n for i in range(n):\n r = [x for x in input()]\n while r[j] == '#' and j+1 < w and r[j+1] == '#':\n r[j] = '.'\n j += 1\n if r[j] == '.' or r.count('#') != 1:\n ok = 0\n\n\n if ok:\n print(\"Possible\")\n else:\n print(\"Impossible\")\n\n \n\n\n\n\n \n \n\n \n ",
"solve",
"int(x) for x in input().split()",
"for x in input().split()",
"x",
"input().split()",
"().split",
"()",
"input",
"split",
"for x in input().split()",
"int(x)",
"int",
"x",
"n, w = [int(x) for x in input().split()]",
"n",
"[int(x) for x in input().split()]",
"w",
"j = 0",
"j",
"0",
"ok = 1",
"ok",
"1",
"for i in range(n):\n r = [x for x in input()]\n while r[j] == '#' and j+1 < w and r[j+1] == '#':\n r[j] = '.'\n j += 1\n if r[j] == '.' or r.count('#') != 1:\n ok = 0\n\n\n ",
"i",
"range(n)",
"range",
"n",
"x for x in input()",
"for x in input()",
"x",
"input()",
"input",
"for x in input()",
"x",
"r = [x for x in input()]",
"r",
"[x for x in input()]",
"while r[j] == '#' and j+1 < w and r[j+1] == '#':\n r[j] = '.'\n j += 1\n ",
"r[j] == '#' and j+1 < w and r[j+1] == '#'",
"r[j] == '#' and j+1 < w",
"r[j] == '#'",
"r[j]",
"r",
"j",
"'#'",
"j+1 < w",
"j+1",
"j",
"1",
"w",
"r[j+1] == '#'",
"r[j+1]",
"r",
"j+1",
"j",
"1",
"'#'",
"r[j] = '.'",
"r[j]",
"r",
"j",
"'.'",
"j += 1",
"j",
"1",
"if r[j] == '.' or r.count('#') != 1:\n ok = 0\n\n\n ",
"r[j] == '.' or r.count('#') != 1",
"r[j] == '.'",
"r[j]",
"r",
"j",
"'.'",
"r.count('#') != 1",
"r.count('#')",
"r.count",
"r",
"count",
"'#'",
"1",
"ok = 0",
"ok",
"0",
"if ok:\n print(\"Possible\")\n else:\n print(\"Impossible\")\n\n \n\n\n\n\n \n \n\n \n ",
"ok",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"t = 1",
"t",
"1",
"for case in range(1,t+1):\n ans = solve()",
"case",
"range(1,t+1)",
"range",
"1",
"t+1",
"t",
"1",
"ans = solve()",
"ans",
"solve()",
"solve",
"\"\"\"\n\n2 2 2 2 2\n\n\"\"\"",
"t = 1",
"1",
"t",
"ans = solve()",
"solve()",
"ans",
"def solve():\n n, w = [int(x) for x in input().split()]\n j = 0\n ok = 1\n for i in range(n):\n r = [x for x in input()]\n while r[j] == '#' and j+1 < w and r[j+1] == '#':\n r[j] = '.'\n j += 1\n if r[j] == '.' or r.count('#') != 1:\n ok = 0\n\n\n if ok:\n print(\"Possible\")\n else:\n print(\"Impossible\")\n\n \n\n\n\n\n \n \n\n \n ",
"def solve():\n n, w = [int(x) for x in input().split()]\n j = 0\n ok = 1\n for i in range(n):\n r = [x for x in input()]\n while r[j] == '#' and j+1 < w and r[j+1] == '#':\n r[j] = '.'\n j += 1\n if r[j] == '.' or r.count('#') != 1:\n ok = 0\n\n\n if ok:\n print(\"Possible\")\n else:\n print(\"Impossible\")\n\n \n\n\n\n\n \n \n\n \n ",
"solve"
] |
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
def solve():
n, w = [int(x) for x in input().split()]
j = 0
ok = 1
for i in range(n):
r = [x for x in input()]
while r[j] == '#' and j+1 < w and r[j+1] == '#':
r[j] = '.'
j += 1
if r[j] == '.' or r.count('#') != 1:
ok = 0
if ok:
print("Possible")
else:
print("Impossible")
t = 1
# t = int(input())
for case in range(1,t+1):
ans = solve()
"""
2 2 2 2 2
"""
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
0,
13,
4,
18,
13,
13,
17,
14,
2,
40,
4,
18,
4,
18,
13,
13,
2,
17,
13,
17,
13,
17,
17,
17,
40,
18,
13,
39,
13,
2,
13,
13,
2,
17,
13,
4,
13,
17,
4,
13,
0,
13,
2,
13,
17,
4,
13,
17,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13
] |
[
[
88,
2
],
[
88,
11
],
[
82,
13
],
[
17,
16
],
[
86,
19
],
[
79,
21
],
[
76,
25
],
[
80,
28
],
[
80,
38
],
[
77,
42
],
[
80,
50
],
[
83,
54
],
[
74,
54
],
[
77,
55
],
[
77,
58
],
[
73,
65
],
[
77,
67
],
[
73,
74
],
[
76,
77
],
[
79,
80
],
[
82,
83
],
[
88,
86
],
[
88,
89
]
] |
[
"#!/usr/bin/env python3\nh, _ = map(int, input().split())\ni = 0\nfor _ in range(h):\n a = input()\n c = a.count(\"#\")\n if a.replace(\"#\" * c, \"\").replace(\".\", \"\") != \"\" or a[i:i + c] != \"#\" * c:\n print(\"Impossible\")\n exit()\n else:\n i += c - 1\nprint(\"Possible\")",
"h, _ = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"_",
"i = 0",
"i",
"0",
"for _ in range(h):\n a = input()\n c = a.count(\"#\")\n if a.replace(\"#\" * c, \"\").replace(\".\", \"\") != \"\" or a[i:i + c] != \"#\" * c:\n print(\"Impossible\")\n exit()\n else:\n i += c - 1",
"_",
"range(h)",
"range",
"h",
"a = input()",
"a",
"input()",
"input",
"c = a.count(\"#\")",
"c",
"a.count(\"#\")",
"a.count",
"a",
"count",
"\"#\"",
"if a.replace(\"#\" * c, \"\").replace(\".\", \"\") != \"\" or a[i:i + c] != \"#\" * c:\n print(\"Impossible\")\n exit()\n else:\n i += c - 1",
"a.replace(\"#\" * c, \"\").replace(\".\", \"\") != \"\" or a[i:i + c] != \"#\" * c",
"a.replace(\"#\" * c, \"\").replace(\".\", \"\") != \"\"",
"a.replace(\"#\" * c, \"\").replace(\".\", \"\")",
"a.replace(\"#\" * c, \"\").replace",
"a.replace(\"#\" * c, \"\")",
"a.replace",
"a",
"replace",
"\"#\" * c",
"\"#\"",
"c",
"\"\"",
"replace",
"\".\"",
"\"\"",
"\"\"",
"a[i:i + c] != \"#\" * c",
"a[i:i + c]",
"a",
"i:i + c",
"i",
"i + c",
"i",
"c",
"\"#\" * c",
"\"#\"",
"c",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"exit()",
"exit",
"i += c - 1",
"i",
"c - 1",
"c",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"i += c - 1",
"c - 1",
"i",
"c = a.count(\"#\")",
"a.count(\"#\")",
"c",
"a = input()",
"input()",
"a",
"i = 0",
"0",
"i",
"h, _ = map(int, input().split())",
"map(int, input().split())",
"h",
"_ = map(int, input().split())",
"map(int, input().split())",
"_"
] |
#!/usr/bin/env python3
h, _ = map(int, input().split())
i = 0
for _ in range(h):
a = input()
c = a.count("#")
if a.replace("#" * c, "").replace(".", "") != "" or a[i:i + c] != "#" * c:
print("Impossible")
exit()
else:
i += c - 1
print("Possible")
|
[
7,
15,
13,
15,
0,
13,
18,
18,
18,
13,
13,
13,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
17,
0,
13,
2,
2,
17,
17,
17,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
18,
13,
13,
17,
4,
13,
8,
2,
13,
2,
2,
13,
13,
17,
17,
17,
14,
2,
13,
17,
4,
13,
10,
4,
13,
10,
2,
13,
10,
18,
13,
10,
12,
13
] |
[
[
91,
5
],
[
85,
21
],
[
88,
26
],
[
36,
35
],
[
36,
44
],
[
47,
46
],
[
50,
49
],
[
35,
52
],
[
55,
54
],
[
61,
60
],
[
54,
63
],
[
60,
70
],
[
46,
70
],
[
35,
73
],
[
44,
74
],
[
95,
83
],
[
85,
86
],
[
88,
89
],
[
91,
92
]
] |
[
"import sys\nfrom collections import deque\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\ndef main():\n h, w = map(int, input().split())\n c = 0\n for _ in range(h):\n a = list(input())\n c += a.count(\"#\")\n print((\"Possible\" if c == h + w - 1 else \"Impossible\"))\n\n\nif __name__ == '__main__':\n main()",
"import sys",
"sys",
"from collections import deque",
"readline = sys.stdin.buffer.readline",
"readline",
"sys.stdin.buffer.readline",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readline",
"sys.setrecursionlimit(10 ** 8)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 8",
"10",
"8",
"INF = float('inf')",
"INF",
"float('inf')",
"float",
"'inf'",
"MOD = 10 ** 9 + 7",
"MOD",
"10 ** 9 + 7",
"10 ** 9",
"10",
"9",
"7",
"def main():\n h, w = map(int, input().split())\n c = 0\n for _ in range(h):\n a = list(input())\n c += a.count(\"#\")\n print((\"Possible\" if c == h + w - 1 else \"Impossible\"))",
"main",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"c = 0",
"c",
"0",
"for _ in range(h):\n a = list(input())\n c += a.count(\"#\")\n ",
"_",
"range(h)",
"range",
"h",
"a = list(input())",
"a",
"list(input())",
"list",
"input()",
"input",
"c += a.count(\"#\")",
"c",
"a.count(\"#\")",
"a.count",
"a",
"count",
"\"#\"",
"print((\"Possible\" if c == h + w - 1 else \"Impossible\"))",
"print",
"\"Possible\" if c == h + w - 1 else \"Impossible\"",
"c == h + w - 1",
"c",
"h + w - 1",
"h + w",
"h",
"w",
"1",
"\"Possible\"",
"\"Impossible\"",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"INF = float('inf')",
"float('inf')",
"INF",
"MOD = 10 ** 9 + 7",
"10 ** 9 + 7",
"MOD",
"readline = sys.stdin.buffer.readline",
"sys.stdin.buffer.readline",
"readline",
"def main():\n h, w = map(int, input().split())\n c = 0\n for _ in range(h):\n a = list(input())\n c += a.count(\"#\")\n print((\"Possible\" if c == h + w - 1 else \"Impossible\"))",
"def main():\n h, w = map(int, input().split())\n c = 0\n for _ in range(h):\n a = list(input())\n c += a.count(\"#\")\n print((\"Possible\" if c == h + w - 1 else \"Impossible\"))",
"main"
] |
import sys
from collections import deque
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
def main():
h, w = map(int, input().split())
c = 0
for _ in range(h):
a = list(input())
c += a.count("#")
print(("Possible" if c == h + w - 1 else "Impossible"))
if __name__ == '__main__':
main()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
0,
13,
17,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
4,
13,
0,
13,
4,
18,
18,
13,
17,
13,
17,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
0,
13,
17,
13,
17,
0,
13,
39,
17,
17,
0,
13,
17,
42,
17,
0,
13,
39,
39,
4,
13,
2,
18,
13,
13,
17,
2,
13,
17,
18,
13,
13,
39,
18,
13,
13,
4,
13,
2,
18,
13,
13,
17,
2,
13,
17,
0,
13,
17,
28,
13,
4,
13,
17,
14,
18,
18,
13,
18,
18,
13,
13,
13,
18,
18,
13,
13,
13,
14,
2,
18,
18,
13,
18,
18,
13,
13,
13,
18,
18,
13,
13,
13,
17,
0,
13,
39,
18,
18,
13,
13,
13,
18,
18,
13,
13,
13,
0,
18,
18,
13,
18,
18,
13,
13,
13,
18,
18,
13,
13,
13,
17,
0,
13,
17,
0,
13,
17,
3,
14,
13,
3,
14,
2,
2,
13,
13,
2,
13,
39,
2,
13,
17,
2,
13,
17,
4,
13,
17,
4,
13,
17,
10,
39,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
39,
13,
10,
17,
13,
10,
17,
13,
10,
39,
13,
10,
4,
13,
10,
39,
13,
10,
17,
13,
10,
13,
13,
10,
17,
13
] |
[
[
231,
2
],
[
231,
11
],
[
201,
13
],
[
207,
16
],
[
20,
19
],
[
214,
22
],
[
202,
25
],
[
210,
32
],
[
202,
36
],
[
43,
42
],
[
214,
45
],
[
240,
49
],
[
57,
52
],
[
241,
54
],
[
225,
59
],
[
216,
61
],
[
219,
64
],
[
222,
69
],
[
234,
74
],
[
220,
81
],
[
229,
81
],
[
217,
82
],
[
214,
85
],
[
220,
88
],
[
229,
88
],
[
226,
89
],
[
220,
92
],
[
229,
92
],
[
217,
93
],
[
220,
98
],
[
229,
98
],
[
226,
99
],
[
232,
102
],
[
204,
105
],
[
109,
108
],
[
241,
115
],
[
235,
118
],
[
108,
119
],
[
226,
120
],
[
235,
123
],
[
108,
124
],
[
217,
125
],
[
202,
130
],
[
235,
133
],
[
108,
134
],
[
226,
135
],
[
235,
138
],
[
108,
139
],
[
217,
140
],
[
228,
143
],
[
235,
147
],
[
108,
148
],
[
217,
149
],
[
235,
152
],
[
108,
153
],
[
226,
154
],
[
169,
156
],
[
241,
158
],
[
235,
161
],
[
108,
162
],
[
226,
163
],
[
235,
166
],
[
108,
167
],
[
217,
168
],
[
243,
171
],
[
237,
174
],
[
244,
183
],
[
223,
183
],
[
211,
184
],
[
208,
184
],
[
229,
186
],
[
220,
186
],
[
232,
189
],
[
214,
192
],
[
201,
202
],
[
204,
205
],
[
207,
208
],
[
210,
211
],
[
231,
214
],
[
216,
217
],
[
219,
220
],
[
222,
223
],
[
225,
226
],
[
228,
229
],
[
231,
232
],
[
234,
235
],
[
237,
238
],
[
240,
241
],
[
243,
244
]
] |
[
"h,w = map(int,input().split())\na = []\ncnt = 0\nfor _ in range(h):\n a.append(list(input()))\n cnt += a[-1].count(\"#\")\nlooked = [[True for _ in range(w)]for i in range(h)]\nlooked[0][0] = False\nx,y = 0,1\nnow = [0,0]\nans = 1\n\nwhile(True):\n look = [[min(now[y]+1,h-1),now[x]],[now[y],min(now[x]+1,w-1)]]\n flag = 1\n for i in range(2):\n if looked[look[i][x]][look[i][y]]:\n if a[look[i][x]][look[i][y]] == \"#\":\n now = [look[i][y],look[i][x]]\n looked[look[i][x]][look[i][y]] = False\n ans += 1\n flag = 0\n break\n if flag:\n break\nif ans == cnt and now == [w-1,h-1]:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"h,w = map(int,input().split())",
"h",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"a = []",
"a",
"[]",
"cnt = 0",
"cnt",
"0",
"for _ in range(h):\n a.append(list(input()))\n cnt += a[-1].count(\"#\")",
"_",
"range(h)",
"range",
"h",
"a.append(list(input()))",
"a.append",
"a",
"append",
"list(input())",
"list",
"input()",
"input",
"cnt += a[-1].count(\"#\")",
"cnt",
"a[-1].count(\"#\")",
"[-1].count",
"[-1]",
"a",
"-1",
"count",
"\"#\"",
"[True for _ in range(w)]for i in range(h)",
"for i in range(h)",
"i",
"range(h)",
"range",
"h",
"for i in range(h)",
"[True for _ in range(w)]",
"looked = [[True for _ in range(w)]for i in range(h)]",
"looked",
"[[True for _ in range(w)]for i in range(h)]",
"looked[0][0] = False",
"looked[0][0]",
"[0]",
"looked",
"0",
"0",
"False",
"x,y = 0,1",
"x",
"0",
"y",
"1",
"now = [0,0]",
"now",
"[0,0]",
"0",
"0",
"ans = 1",
"ans",
"1",
"while(True):\n look = [[min(now[y]+1,h-1),now[x]],[now[y],min(now[x]+1,w-1)]]\n flag = 1\n for i in range(2):\n if looked[look[i][x]][look[i][y]]:\n if a[look[i][x]][look[i][y]] == \"#\":\n now = [look[i][y],look[i][x]]\n looked[look[i][x]][look[i][y]] = False\n ans += 1\n flag = 0\n break\n if flag:\n break",
"True",
"look = [[min(now[y]+1,h-1),now[x]],[now[y],min(now[x]+1,w-1)]]",
"look",
"[[min(now[y]+1,h-1),now[x]],[now[y],min(now[x]+1,w-1)]]",
"[min(now[y]+1,h-1),now[x]]",
"min(now[y]+1,h-1)",
"min",
"now[y]+1",
"now[y]",
"now",
"y",
"1",
"h-1",
"h",
"1",
"now[x]",
"now",
"x",
"[now[y],min(now[x]+1,w-1)]",
"now[y]",
"now",
"y",
"min(now[x]+1,w-1)",
"min",
"now[x]+1",
"now[x]",
"now",
"x",
"1",
"w-1",
"w",
"1",
"flag = 1",
"flag",
"1",
"for i in range(2):\n if looked[look[i][x]][look[i][y]]:\n if a[look[i][x]][look[i][y]] == \"#\":\n now = [look[i][y],look[i][x]]\n looked[look[i][x]][look[i][y]] = False\n ans += 1\n flag = 0\n break\n ",
"i",
"range(2)",
"range",
"2",
"if looked[look[i][x]][look[i][y]]:\n if a[look[i][x]][look[i][y]] == \"#\":\n now = [look[i][y],look[i][x]]\n looked[look[i][x]][look[i][y]] = False\n ans += 1\n flag = 0\n break\n ",
"looked[look[i][x]][look[i][y]]",
"[look[i][x]]",
"looked",
"look[i][x]",
"[i]",
"look",
"i",
"x",
"look[i][y]",
"[i]",
"look",
"i",
"y",
"if a[look[i][x]][look[i][y]] == \"#\":\n now = [look[i][y],look[i][x]]\n looked[look[i][x]][look[i][y]] = False\n ans += 1\n flag = 0\n break\n ",
"a[look[i][x]][look[i][y]] == \"#\"",
"a[look[i][x]][look[i][y]]",
"[look[i][x]]",
"a",
"look[i][x]",
"[i]",
"look",
"i",
"x",
"look[i][y]",
"[i]",
"look",
"i",
"y",
"\"#\"",
"now = [look[i][y],look[i][x]]",
"now",
"[look[i][y],look[i][x]]",
"look[i][y]",
"[i]",
"look",
"i",
"y",
"look[i][x]",
"[i]",
"look",
"i",
"x",
"looked[look[i][x]][look[i][y]] = False",
"looked[look[i][x]][look[i][y]]",
"[look[i][x]]",
"looked",
"look[i][x]",
"[i]",
"look",
"i",
"x",
"look[i][y]",
"[i]",
"look",
"i",
"y",
"False",
"ans += 1",
"ans",
"1",
"flag = 0",
"flag",
"0",
"break",
"if flag:\n break",
"flag",
"break",
"if ans == cnt and now == [w-1,h-1]:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"ans == cnt and now == [w-1,h-1]",
"ans == cnt",
"ans",
"cnt",
"now == [w-1,h-1]",
"now",
"[w-1,h-1]",
"w-1",
"w",
"1",
"h-1",
"h",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"a = []",
"[]",
"a",
"flag = 1",
"1",
"flag",
"cnt = 0",
"0",
"cnt",
"cnt += a[-1].count(\"#\")",
"a[-1].count(\"#\")",
"cnt",
"h,w = map(int,input().split())",
"map(int,input().split())",
"h",
"y = 0,1",
"1",
"y",
"now = [0,0]",
"[0,0]",
"now",
"ans = 1",
"1",
"ans",
"x,y = 0,1",
"0",
"x",
"now = [look[i][y],look[i][x]]",
"[look[i][y],look[i][x]]",
"now",
"w = map(int,input().split())",
"map(int,input().split())",
"w",
"look = [[min(now[y]+1,h-1),now[x]],[now[y],min(now[x]+1,w-1)]]",
"[[min(now[y]+1,h-1),now[x]],[now[y],min(now[x]+1,w-1)]]",
"look",
"flag = 0",
"0",
"flag",
"looked = [[True for _ in range(w)]for i in range(h)]",
"[[True for _ in range(w)]for i in range(h)]",
"looked",
"ans += 1",
"1",
"ans"
] |
h,w = map(int,input().split())
a = []
cnt = 0
for _ in range(h):
a.append(list(input()))
cnt += a[-1].count("#")
looked = [[True for _ in range(w)]for i in range(h)]
looked[0][0] = False
x,y = 0,1
now = [0,0]
ans = 1
while(True):
look = [[min(now[y]+1,h-1),now[x]],[now[y],min(now[x]+1,w-1)]]
flag = 1
for i in range(2):
if looked[look[i][x]][look[i][y]]:
if a[look[i][x]][look[i][y]] == "#":
now = [look[i][y],look[i][x]]
looked[look[i][x]][look[i][y]] = False
ans += 1
flag = 0
break
if flag:
break
if ans == cnt and now == [w-1,h-1]:
print("Possible")
else:
print("Impossible")
|
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
4,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
18,
18,
13,
13,
13,
17,
4,
13,
8,
2,
2,
2,
13,
13,
17,
13,
17,
17,
10,
39,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
69,
2
],
[
69,
13
],
[
60,
15
],
[
19,
18
],
[
67,
21
],
[
61,
24
],
[
63,
31
],
[
35,
34
],
[
67,
37
],
[
72,
39
],
[
61,
43
],
[
34,
44
],
[
67,
53
],
[
70,
54
],
[
73,
56
],
[
64,
56
],
[
60,
61
],
[
63,
64
],
[
69,
67
],
[
69,
70
],
[
72,
73
]
] |
[
"x,y = list(map(int, input().split()))\nl = []\nfor i in range (x):\n l.append(list(input()))\nval = 0\nfor j in range (x):\n val += l[j].count('#')\nprint('Possible' if x + y - 1 == val else 'Impossible')",
"x,y = list(map(int, input().split()))",
"x",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"y",
"l = []",
"l",
"[]",
"for i in range (x):\n l.append(list(input()))",
"i",
"range (x)",
"range",
"x",
"l.append(list(input()))",
"l.append",
"l",
"append",
"list(input())",
"list",
"input()",
"input",
"val = 0",
"val",
"0",
"for j in range (x):\n val += l[j].count('#')",
"j",
"range (x)",
"range",
"x",
"val += l[j].count('#')",
"val",
"l[j].count('#')",
"[j].count",
"[j]",
"l",
"j",
"count",
"'#'",
"print('Possible' if x + y - 1 == val else 'Impossible')",
"print",
"'Possible' if x + y - 1 == val else 'Impossible'",
"x + y - 1 == val",
"x + y - 1",
"x + y",
"x",
"y",
"1",
"val",
"'Possible'",
"'Impossible'",
"l = []",
"[]",
"l",
"val = 0",
"0",
"val",
"x,y = list(map(int, input().split()))",
"list(map(int, input().split()))",
"x",
"y = list(map(int, input().split()))",
"list(map(int, input().split()))",
"y",
"val += l[j].count('#')",
"l[j].count('#')",
"val"
] |
x,y = list(map(int, input().split()))
l = []
for i in range (x):
l.append(list(input()))
val = 0
for j in range (x):
val += l[j].count('#')
print('Possible' if x + y - 1 == val else 'Impossible')
|
[
7,
15,
13,
12,
13,
29,
4,
18,
4,
18,
18,
13,
13,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
18,
4,
13,
13,
17,
4,
13,
8,
2,
13,
2,
2,
13,
13,
17,
17,
17,
10,
4,
13,
10,
17,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13
] |
[
[
64,
16
],
[
62,
23
],
[
64,
25
],
[
58,
27
],
[
31,
30
],
[
56,
33
],
[
67,
35
],
[
62,
39
],
[
59,
40
],
[
68,
40
],
[
68,
46
],
[
59,
46
],
[
56,
49
],
[
65,
50
],
[
64,
56
],
[
58,
59
],
[
64,
65
],
[
67,
68
]
] |
[
"import sys\ndef input():\n return sys.stdin.readline().rstrip()\n\nH,W=map(int,input().split())\n\ncount=0\nfor _ in range(H):\n count+=input().count(\"#\")\nprint(\"Possible\" if count==H+W-1 else \"Impossible\")",
"import sys",
"sys",
"def input():\n return sys.stdin.readline().rstrip()",
"input",
"return sys.stdin.readline().rstrip()",
"sys.stdin.readline().rstrip()",
"sys.stdin.readline().rstrip",
"sys.stdin.readline()",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"rstrip",
"H,W=map(int,input().split())",
"H",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"count=0",
"count",
"0",
"for _ in range(H):\n count+=input().count(\"#\")",
"_",
"range(H)",
"range",
"H",
"count+=input().count(\"#\")",
"count",
"input().count(\"#\")",
"().count",
"()",
"input",
"count",
"\"#\"",
"print(\"Possible\" if count==H+W-1 else \"Impossible\")",
"print",
"\"Possible\" if count==H+W-1 else \"Impossible\"",
"count==H+W-1",
"count",
"H+W-1",
"H+W",
"H",
"W",
"1",
"\"Possible\"",
"\"Impossible\"",
"H,W=map(int,input().split())",
"map(int,input().split())",
"H",
"count=0",
"0",
"count",
"def input():\n return sys.stdin.readline().rstrip()",
"def input():\n return sys.stdin.readline().rstrip()",
"input",
"W=map(int,input().split())",
"map(int,input().split())",
"W",
"count+=input().count(\"#\")",
"input().count(\"#\")",
"count"
] |
import sys
def input():
return sys.stdin.readline().rstrip()
H,W=map(int,input().split())
count=0
for _ in range(H):
count+=input().count("#")
print("Possible" if count==H+W-1 else "Impossible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
4,
18,
13,
13,
13,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
39,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13
] |
[
[
82,
2
],
[
82,
11
],
[
70,
13
],
[
79,
16
],
[
20,
19
],
[
77,
22
],
[
85,
24
],
[
71,
31
],
[
86,
33
],
[
36,
35
],
[
77,
38
],
[
41,
40
],
[
83,
43
],
[
71,
48
],
[
35,
49
],
[
40,
50
],
[
73,
53
],
[
74,
57
],
[
80,
57
],
[
77,
60
],
[
83,
61
],
[
70,
71
],
[
73,
74
],
[
82,
77
],
[
79,
80
],
[
82,
83
],
[
85,
86
]
] |
[
"H,W = map(int,input().split())\nlist1 =[]\ncount = 0\nfor i in range(H):\n a = list(input())\n list1.append(a)\nfor i in range(H):\n for j in range(W):\n if list1[i][j] == '#':\n count +=1\nif count == H +W -1:\n print('Possible')\nelse:\n print('Impossible')",
"H,W = map(int,input().split())",
"H",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"list1 =[]",
"list1",
"[]",
"count = 0",
"count",
"0",
"for i in range(H):\n a = list(input())\n list1.append(a)",
"i",
"range(H)",
"range",
"H",
"a = list(input())",
"a",
"list(input())",
"list",
"input()",
"input",
"list1.append(a)",
"list1.append",
"list1",
"append",
"a",
"for i in range(H):\n for j in range(W):\n if list1[i][j] == '#':\n count +=1",
"i",
"range(H)",
"range",
"H",
"for j in range(W):\n if list1[i][j] == '#':\n count +=1",
"j",
"range(W)",
"range",
"W",
"if list1[i][j] == '#':\n count +=1",
"list1[i][j] == '#'",
"list1[i][j]",
"[i]",
"list1",
"i",
"j",
"'#'",
"count +=1",
"count",
"1",
"if count == H +W -1:\n print('Possible')\nelse:\n print('Impossible')",
"count == H +W -1",
"count",
"H +W -1",
"H +W",
"H",
"W",
"1",
"print('Possible')",
"print",
"'Possible'",
"print('Impossible')",
"print",
"'Impossible'",
"list1 =[]",
"[]",
"list1",
"count +=1",
"1",
"count",
"H,W = map(int,input().split())",
"map(int,input().split())",
"H",
"count = 0",
"0",
"count",
"W = map(int,input().split())",
"map(int,input().split())",
"W",
"a = list(input())",
"list(input())",
"a"
] |
H,W = map(int,input().split())
list1 =[]
count = 0
for i in range(H):
a = list(input())
list1.append(a)
for i in range(H):
for j in range(W):
if list1[i][j] == '#':
count +=1
if count == H +W -1:
print('Possible')
else:
print('Impossible')
|
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
0,
13,
4,
13,
39,
39,
17,
17,
42,
2,
4,
13,
13,
17,
0,
13,
4,
18,
13,
13,
0,
18,
18,
13,
18,
13,
17,
18,
13,
17,
17,
14,
2,
2,
2,
18,
13,
17,
17,
13,
2,
18,
18,
13,
2,
18,
13,
17,
17,
18,
13,
17,
17,
4,
18,
13,
13,
39,
2,
18,
13,
17,
17,
18,
13,
17,
14,
2,
2,
2,
18,
13,
17,
17,
13,
2,
18,
18,
13,
18,
13,
17,
2,
18,
13,
17,
17,
17,
4,
18,
13,
13,
39,
18,
13,
17,
2,
18,
13,
17,
17,
14,
2,
2,
13,
2,
2,
13,
13,
17,
2,
18,
18,
13,
2,
13,
17,
2,
13,
17,
17,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
4,
13,
10,
39,
13,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] |
[
[
193,
3
],
[
193,
12
],
[
196,
14
],
[
18,
17
],
[
191,
20
],
[
197,
23
],
[
202,
28
],
[
32,
31
],
[
191,
34
],
[
37,
36
],
[
194,
39
],
[
197,
44
],
[
31,
45
],
[
36,
46
],
[
208,
49
],
[
54,
53
],
[
191,
56
],
[
199,
60
],
[
211,
63
],
[
212,
74
],
[
205,
77
],
[
212,
80
],
[
92,
83
],
[
200,
85
],
[
206,
87
],
[
206,
90
],
[
206,
98
],
[
191,
101
],
[
197,
105
],
[
206,
108
],
[
206,
112
],
[
212,
117
],
[
206,
122
],
[
206,
126
],
[
206,
133
],
[
194,
136
],
[
197,
140
],
[
206,
142
],
[
206,
146
],
[
212,
152
],
[
206,
156
],
[
206,
160
],
[
209,
166
],
[
203,
166
],
[
191,
169
],
[
194,
170
],
[
200,
175
],
[
191,
177
],
[
194,
180
],
[
193,
191
],
[
193,
194
],
[
196,
197
],
[
199,
200
],
[
202,
203
],
[
205,
206
],
[
208,
209
],
[
211,
212
]
] |
[
"from collections import deque\nH, W = map(int, input().split())\nS = []\nfor i in range(H):\n S.append(input())\nnum = 0\nfor i in range(H):\n for j in range(W):\n if S[i][j] == \"#\":\n num += 1\nA = [[0 for j in range(W)] for i in range(H)]\nd = deque([[0, 0]])\nwhile len(d) > 0:\n x = d.pop()\n A[x[0]][x[1]] = 1\n if x[0] + 1 < H and S[x[0]+1][x[1]] == \"#\":\n d.append([x[0]+1, x[1]])\n if x[1] + 1 < W and S[x[0]][x[1]+1] == \"#\":\n d.append([x[0], x[1]+1])\nif num == H + W - 1 and A[H-1][W-1] == 1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"from collections import deque",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"S = []",
"S",
"[]",
"for i in range(H):\n S.append(input())",
"i",
"range(H)",
"range",
"H",
"S.append(input())",
"S.append",
"S",
"append",
"input()",
"input",
"num = 0",
"num",
"0",
"for i in range(H):\n for j in range(W):\n if S[i][j] == \"#\":\n num += 1",
"i",
"range(H)",
"range",
"H",
"for j in range(W):\n if S[i][j] == \"#\":\n num += 1",
"j",
"range(W)",
"range",
"W",
"if S[i][j] == \"#\":\n num += 1",
"S[i][j] == \"#\"",
"S[i][j]",
"[i]",
"S",
"i",
"j",
"\"#\"",
"num += 1",
"num",
"1",
"[0 for j in range(W)] for i in range(H)",
"for i in range(H)",
"i",
"range(H)",
"range",
"H",
"for i in range(H)",
"[0 for j in range(W)]",
"A = [[0 for j in range(W)] for i in range(H)]",
"A",
"[[0 for j in range(W)] for i in range(H)]",
"d = deque([[0, 0]])",
"d",
"deque([[0, 0]])",
"deque",
"[[0, 0]]",
"[0, 0]",
"0",
"0",
"while len(d) > 0:\n x = d.pop()\n A[x[0]][x[1]] = 1\n if x[0] + 1 < H and S[x[0]+1][x[1]] == \"#\":\n d.append([x[0]+1, x[1]])\n if x[1] + 1 < W and S[x[0]][x[1]+1] == \"#\":\n d.append([x[0], x[1]+1])",
"len(d) > 0",
"len(d)",
"len",
"d",
"0",
"x = d.pop()",
"x",
"d.pop()",
"d.pop",
"d",
"pop",
"A[x[0]][x[1]] = 1",
"A[x[0]][x[1]]",
"[x[0]]",
"A",
"x[0]",
"x",
"0",
"x[1]",
"x",
"1",
"1",
"if x[0] + 1 < H and S[x[0]+1][x[1]] == \"#\":\n d.append([x[0]+1, x[1]])\n ",
"x[0] + 1 < H and S[x[0]+1][x[1]] == \"#\"",
"x[0] + 1 < H",
"x[0] + 1",
"x[0]",
"x",
"0",
"1",
"H",
"S[x[0]+1][x[1]] == \"#\"",
"S[x[0]+1][x[1]]",
"[x[0]+1]",
"S",
"x[0]+1",
"x[0]",
"x",
"0",
"1",
"x[1]",
"x",
"1",
"\"#\"",
"d.append([x[0]+1, x[1]])",
"d.append",
"d",
"append",
"[x[0]+1, x[1]]",
"x[0]+1",
"x[0]",
"x",
"0",
"1",
"x[1]",
"x",
"1",
"if x[1] + 1 < W and S[x[0]][x[1]+1] == \"#\":\n d.append([x[0], x[1]+1])",
"x[1] + 1 < W and S[x[0]][x[1]+1] == \"#\"",
"x[1] + 1 < W",
"x[1] + 1",
"x[1]",
"x",
"1",
"1",
"W",
"S[x[0]][x[1]+1] == \"#\"",
"S[x[0]][x[1]+1]",
"[x[0]]",
"S",
"x[0]",
"x",
"0",
"x[1]+1",
"x[1]",
"x",
"1",
"1",
"\"#\"",
"d.append([x[0], x[1]+1])",
"d.append",
"d",
"append",
"[x[0], x[1]+1]",
"x[0]",
"x",
"0",
"x[1]+1",
"x[1]",
"x",
"1",
"1",
"if num == H + W - 1 and A[H-1][W-1] == 1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"num == H + W - 1 and A[H-1][W-1] == 1",
"num == H + W - 1",
"num",
"H + W - 1",
"H + W",
"H",
"W",
"1",
"A[H-1][W-1] == 1",
"A[H-1][W-1]",
"[H-1]",
"A",
"H-1",
"H",
"1",
"W-1",
"W",
"1",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"H, W = map(int, input().split())",
"map(int, input().split())",
"H",
"W = map(int, input().split())",
"map(int, input().split())",
"W",
"S = []",
"[]",
"S",
"A = [[0 for j in range(W)] for i in range(H)]",
"[[0 for j in range(W)] for i in range(H)]",
"A",
"num = 0",
"0",
"num",
"x = d.pop()",
"d.pop()",
"x",
"num += 1",
"1",
"num",
"d = deque([[0, 0]])",
"deque([[0, 0]])",
"d"
] |
from collections import deque
H, W = map(int, input().split())
S = []
for i in range(H):
S.append(input())
num = 0
for i in range(H):
for j in range(W):
if S[i][j] == "#":
num += 1
A = [[0 for j in range(W)] for i in range(H)]
d = deque([[0, 0]])
while len(d) > 0:
x = d.pop()
A[x[0]][x[1]] = 1
if x[0] + 1 < H and S[x[0]+1][x[1]] == "#":
d.append([x[0]+1, x[1]])
if x[1] + 1 < W and S[x[0]][x[1]+1] == "#":
d.append([x[0], x[1]+1])
if num == H + W - 1 and A[H-1][W-1] == 1:
print("Possible")
else:
print("Impossible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
41,
28,
13,
4,
13,
4,
13,
4,
13,
0,
13,
13,
4,
18,
13,
13,
13,
12,
13,
41,
41,
14,
2,
2,
17,
18,
18,
13,
13,
39,
13,
40,
18,
18,
13,
13,
13,
17,
29,
17,
42,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
14,
2,
13,
13,
3,
14,
2,
2,
13,
2,
13,
17,
2,
13,
13,
29,
17,
14,
2,
13,
2,
13,
17,
29,
17,
14,
2,
4,
18,
18,
18,
13,
13,
39,
2,
13,
17,
13,
17,
17,
29,
4,
13,
13,
2,
13,
17,
2,
13,
17,
23,
13,
23,
13,
23,
13,
14,
4,
13,
13,
17,
17,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
39,
13,
10,
13,
13,
10,
4,
13,
10,
12,
13
] |
[
[
149,
2
],
[
149,
11
],
[
143,
13
],
[
17,
16
],
[
150,
19
],
[
23,
22
],
[
22,
28
],
[
146,
30
],
[
144,
34
],
[
147,
36
],
[
122,
47
],
[
124,
48
],
[
122,
54
],
[
124,
55
],
[
126,
56
],
[
122,
64
],
[
124,
65
],
[
126,
66
],
[
69,
66
],
[
70,
69
],
[
69,
73
],
[
126,
73
],
[
124,
79
],
[
69,
84
],
[
126,
84
],
[
124,
90
],
[
122,
102
],
[
124,
103
],
[
69,
106
],
[
126,
106
],
[
122,
114
],
[
124,
116
],
[
69,
119
],
[
126,
119
],
[
122,
122
],
[
124,
124
],
[
126,
126
],
[
153,
129
],
[
144,
130
],
[
149,
141
],
[
143,
144
],
[
146,
147
],
[
149,
150
]
] |
[
"H, W = map(int, input().split())\nA = []\nfor i in range(H):\n a = [i for i in str(input())]\n A.append(a)\n \ndef meiro(A, h, w):\n global H\n global W\n if ('#' in A[h][:w]) or (A[h][w] != '#'):\n return False\n while A[h][w] == '#':\n w += 1\n if w == W:\n break\n if h==H-1 and w==W:\n return True\n elif h == H-1:\n return False\n elif A[h][w-1:].count('#')==1:\n return meiro(A, h+1, w-1)\n \nif meiro(A, 0, 0):\n print('Possible')\nelse:\n print('Impossible')",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"A = []",
"A",
"[]",
"for i in range(H):\n a = [i for i in str(input())]\n A.append(a)\n ",
"i",
"range(H)",
"range",
"H",
"i for i in str(input())",
"for i in str(input())",
"i",
"str(input())",
"str",
"input()",
"input",
"for i in str(input())",
"i",
"a = [i for i in str(input())]",
"a",
"[i for i in str(input())]",
"A.append(a)",
"A.append",
"A",
"append",
"a",
"def meiro(A, h, w):\n global H\n global W\n if ('#' in A[h][:w]) or (A[h][w] != '#'):\n return False\n while A[h][w] == '#':\n w += 1\n if w == W:\n break\n if h==H-1 and w==W:\n return True\n elif h == H-1:\n return False\n elif A[h][w-1:].count('#')==1:\n return meiro(A, h+1, w-1)\n ",
"meiro",
"global H",
"global W",
"if ('#' in A[h][:w]) or (A[h][w] != '#'):\n return False\n ",
"('#' in A[h][:w]) or (A[h][w] != '#')",
"'#' in A[h][:w]",
"'#'",
"A[h][:w]",
"[h]",
"A",
"h",
":w",
"w",
"A[h][w] != '#'",
"A[h][w]",
"[h]",
"A",
"h",
"w",
"'#'",
"return False",
"False",
"while A[h][w] == '#':\n w += 1\n if w == W:\n break\n ",
"A[h][w] == '#'",
"A[h][w]",
"[h]",
"A",
"h",
"w",
"'#'",
"w += 1",
"w",
"1",
"if w == W:\n break\n ",
"w == W",
"w",
"W",
"break",
"if h==H-1 and w==W:\n return True\n elif h == H-1:\n return False\n elif A[h][w-1:].count('#')==1:\n return meiro(A, h+1, w-1)\n ",
"h==H-1 and w==W",
"h==H-1",
"h",
"H-1",
"H",
"1",
"w==W",
"w",
"W",
"return True",
"True",
"elif h == H-1:\n return False\n ",
"h == H-1",
"h",
"H-1",
"H",
"1",
"return False",
"False",
"elif A[h][w-1:].count('#')==1:\n return meiro(A, h+1, w-1)\n ",
"A[h][w-1:].count('#')==1",
"A[h][w-1:].count('#')",
"[w-1:].count",
"[w-1:]",
"[h]",
"A",
"h",
"w-1:",
"w-1",
"w",
"1",
"count",
"'#'",
"1",
"return meiro(A, h+1, w-1)",
"meiro(A, h+1, w-1)",
"meiro",
"A",
"h+1",
"h",
"1",
"w-1",
"w",
"1",
"A",
"A",
"h",
"h",
"w",
"w",
"if meiro(A, 0, 0):\n print('Possible')\nelse:\n print('Impossible')",
"meiro(A, 0, 0)",
"meiro",
"A",
"0",
"0",
"print('Possible')",
"print",
"'Possible'",
"print('Impossible')",
"print",
"'Impossible'",
"W = map(int, input().split())",
"map(int, input().split())",
"W",
"A = []",
"[]",
"A",
"a = [i for i in str(input())]",
"[i for i in str(input())]",
"a",
"H, W = map(int, input().split())",
"map(int, input().split())",
"H",
"def meiro(A, h, w):\n global H\n global W\n if ('#' in A[h][:w]) or (A[h][w] != '#'):\n return False\n while A[h][w] == '#':\n w += 1\n if w == W:\n break\n if h==H-1 and w==W:\n return True\n elif h == H-1:\n return False\n elif A[h][w-1:].count('#')==1:\n return meiro(A, h+1, w-1)\n ",
"def meiro(A, h, w):\n global H\n global W\n if ('#' in A[h][:w]) or (A[h][w] != '#'):\n return False\n while A[h][w] == '#':\n w += 1\n if w == W:\n break\n if h==H-1 and w==W:\n return True\n elif h == H-1:\n return False\n elif A[h][w-1:].count('#')==1:\n return meiro(A, h+1, w-1)\n ",
"meiro"
] |
H, W = map(int, input().split())
A = []
for i in range(H):
a = [i for i in str(input())]
A.append(a)
def meiro(A, h, w):
global H
global W
if ('#' in A[h][:w]) or (A[h][w] != '#'):
return False
while A[h][w] == '#':
w += 1
if w == W:
break
if h==H-1 and w==W:
return True
elif h == H-1:
return False
elif A[h][w-1:].count('#')==1:
return meiro(A, h+1, w-1)
if meiro(A, 0, 0):
print('Possible')
else:
print('Impossible')
|
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
4,
13,
4,
13,
0,
13,
17,
41,
28,
13,
4,
13,
2,
2,
13,
13,
17,
4,
13,
0,
13,
13,
28,
13,
4,
13,
13,
2,
13,
17,
0,
13,
17,
13,
17,
41,
28,
13,
4,
13,
13,
4,
2,
39,
17,
13,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
4,
13,
2,
2,
13,
13,
17,
14,
2,
13,
13,
0,
13,
17,
0,
13,
17,
0,
18,
18,
13,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
2,
40,
18,
18,
13,
13,
13,
2,
18,
18,
13,
13,
13,
17,
2,
18,
18,
13,
13,
13,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
14,
13,
0,
13,
17,
3,
4,
13,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
13,
13
] |
[
[
198,
3
],
[
198,
12
],
[
189,
14
],
[
187,
18
],
[
21,
20
],
[
187,
23
],
[
28,
25
],
[
190,
26
],
[
20,
27
],
[
165,
33
],
[
38,
37
],
[
187,
42
],
[
199,
43
],
[
37,
46
],
[
192,
48
],
[
52,
51
],
[
193,
54
],
[
187,
56
],
[
183,
59
],
[
168,
61
],
[
66,
65
],
[
187,
68
],
[
199,
73
],
[
201,
75
],
[
83,
78
],
[
202,
80
],
[
86,
85
],
[
187,
90
],
[
199,
91
],
[
85,
95
],
[
51,
96
],
[
180,
98
],
[
195,
101
],
[
109,
104
],
[
202,
106
],
[
181,
107
],
[
184,
107
],
[
196,
108
],
[
169,
108
],
[
174,
111
],
[
115,
114
],
[
187,
117
],
[
120,
119
],
[
199,
122
],
[
202,
129
],
[
114,
130
],
[
119,
131
],
[
25,
134
],
[
190,
135
],
[
114,
136
],
[
119,
137
],
[
202,
142
],
[
114,
143
],
[
119,
144
],
[
25,
147
],
[
190,
148
],
[
114,
149
],
[
119,
150
],
[
177,
153
],
[
171,
158
],
[
172,
163
],
[
166,
163
],
[
165,
166
],
[
168,
169
],
[
171,
172
],
[
174,
175
],
[
177,
178
],
[
180,
181
],
[
183,
184
],
[
198,
187
],
[
189,
190
],
[
192,
193
],
[
195,
196
],
[
198,
199
],
[
201,
202
]
] |
[
"from itertools import combinations\nH,W = map(int,input().split())\ngrid = [0] * H\nfor i in range(H):\n grid[i] = list(input())\nres = 'Impossible'\n# 1は右、0は下\nmove_indexes = [i for i in range(H+W-2)]\n# 移動回数W+Hの中からH回縦移動を選ぶ\nfor y_move in combinations(move_indexes,H-1):\n now_y, now_x = 0,0\n reached = [[0]*W for _ in range(H)]\n reached[0][0] = 1\n for i in range(H+W-2):\n # うまくやれば*1/8にはなる\n if i in y_move:\n now_y += 1\n else:\n now_x += 1\n reached[now_y][now_x] = 1\n can = True\n for i in range(H):\n for j in range(W):\n if (not reached[i][j] and grid[i][j]=='#') or (reached[i][j] and grid[i][j] == '.'):\n can = False\n if can:\n res = 'Possible'\n break\n\nprint(res)\n\n",
"from itertools import combinations",
"H,W = map(int,input().split())",
"H",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"grid = [0] * H",
"grid",
"[0] * H",
"[0]",
"0",
"H",
"for i in range(H):\n grid[i] = list(input())",
"i",
"range(H)",
"range",
"H",
"grid[i] = list(input())",
"grid[i]",
"grid",
"i",
"list(input())",
"list",
"input()",
"input",
"res = 'Impossible'",
"res",
"'Impossible'",
"i for i in range(H+W-2)",
"for i in range(H+W-2)",
"i",
"range(H+W-2)",
"range",
"H+W-2",
"H+W",
"H",
"W",
"2",
"for i in range(H+W-2)",
"i",
"move_indexes = [i for i in range(H+W-2)]",
"move_indexes",
"[i for i in range(H+W-2)]",
"for y_move in combinations(move_indexes,H-1):\n now_y, now_x = 0,0\n reached = [[0]*W for _ in range(H)]\n reached[0][0] = 1\n for i in range(H+W-2):\n # うまくやれば*1/8にはなる\n if i in y_move:\n now_y += 1\n else:\n now_x += 1\n reached[now_y][now_x] = 1\n can = True\n for i in range(H):\n for j in range(W):\n if (not reached[i][j] and grid[i][j]=='#') or (reached[i][j] and grid[i][j] == '.'):\n can = False\n if can:\n res = 'Possible'\n break",
"y_move",
"combinations(move_indexes,H-1)",
"combinations",
"move_indexes",
"H-1",
"H",
"1",
"now_y, now_x = 0,0",
"now_y",
"0",
"now_x",
"0",
"[0]*W for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"[0]*W",
"[0]",
"0",
"W",
"reached = [[0]*W for _ in range(H)]",
"reached",
"[[0]*W for _ in range(H)]",
"reached[0][0] = 1",
"reached[0][0]",
"[0]",
"reached",
"0",
"0",
"1",
"for i in range(H+W-2):\n # うまくやれば*1/8にはなる\n if i in y_move:\n now_y += 1\n else:\n now_x += 1\n reached[now_y][now_x] = 1\n ",
"i",
"range(H+W-2)",
"range",
"H+W-2",
"H+W",
"H",
"W",
"2",
"if i in y_move:\n now_y += 1\n else:\n now_x += 1\n ",
"i in y_move",
"i",
"y_move",
"now_y += 1",
"now_y",
"1",
"now_x += 1",
"now_x",
"1",
"reached[now_y][now_x] = 1",
"reached[now_y][now_x]",
"[now_y]",
"reached",
"now_y",
"now_x",
"1",
"can = True",
"can",
"True",
"for i in range(H):\n for j in range(W):\n if (not reached[i][j] and grid[i][j]=='#') or (reached[i][j] and grid[i][j] == '.'):\n can = False\n ",
"i",
"range(H)",
"range",
"H",
"for j in range(W):\n if (not reached[i][j] and grid[i][j]=='#') or (reached[i][j] and grid[i][j] == '.'):\n can = False\n ",
"j",
"range(W)",
"range",
"W",
"if (not reached[i][j] and grid[i][j]=='#') or (reached[i][j] and grid[i][j] == '.'):\n can = False\n ",
"(not reached[i][j] and grid[i][j]=='#') or (reached[i][j] and grid[i][j] == '.')",
"not reached[i][j] and grid[i][j]=='#'",
"not reached[i][j]",
"reached[i][j]",
"[i]",
"reached",
"i",
"j",
"grid[i][j]=='#'",
"grid[i][j]",
"[i]",
"grid",
"i",
"j",
"'#'",
"reached[i][j] and grid[i][j] == '.'",
"reached[i][j]",
"[i]",
"reached",
"i",
"j",
"grid[i][j] == '.'",
"grid[i][j]",
"[i]",
"grid",
"i",
"j",
"'.'",
"can = False",
"can",
"False",
"if can:\n res = 'Possible'\n break",
"can",
"res = 'Possible'",
"res",
"'Possible'",
"break",
"print(res)",
"print",
"res",
"res = 'Impossible'",
"'Impossible'",
"res",
"now_x = 0,0",
"0",
"now_x",
"res = 'Possible'",
"'Possible'",
"res",
"can = True",
"True",
"can",
"can = False",
"False",
"can",
"now_y += 1",
"1",
"now_y",
"now_y, now_x = 0,0",
"0",
"now_y",
"H,W = map(int,input().split())",
"map(int,input().split())",
"H",
"grid = [0] * H",
"[0] * H",
"grid",
"move_indexes = [i for i in range(H+W-2)]",
"[i for i in range(H+W-2)]",
"move_indexes",
"now_x += 1",
"1",
"now_x",
"W = map(int,input().split())",
"map(int,input().split())",
"W",
"reached = [[0]*W for _ in range(H)]",
"[[0]*W for _ in range(H)]",
"reached"
] |
from itertools import combinations
H,W = map(int,input().split())
grid = [0] * H
for i in range(H):
grid[i] = list(input())
res = 'Impossible'
# 1は右、0は下
move_indexes = [i for i in range(H+W-2)]
# 移動回数W+Hの中からH回縦移動を選ぶ
for y_move in combinations(move_indexes,H-1):
now_y, now_x = 0,0
reached = [[0]*W for _ in range(H)]
reached[0][0] = 1
for i in range(H+W-2):
# うまくやれば*1/8にはなる
if i in y_move:
now_y += 1
else:
now_x += 1
reached[now_y][now_x] = 1
can = True
for i in range(H):
for j in range(W):
if (not reached[i][j] and grid[i][j]=='#') or (reached[i][j] and grid[i][j] == '.'):
can = False
if can:
res = 'Possible'
break
print(res)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
14,
2,
13,
17,
0,
13,
13,
0,
13,
13,
14,
2,
2,
13,
13,
17,
0,
13,
13,
0,
13,
17,
3,
4,
18,
13,
13,
39,
13,
13,
28,
13,
4,
13,
17,
13,
14,
40,
18,
18,
13,
2,
13,
17,
17,
18,
18,
13,
13,
17,
0,
13,
17,
14,
13,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
13,
13,
10,
17,
13,
10,
39,
13,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13
] |
[
[
134,
2
],
[
134,
11
],
[
15,
14
],
[
135,
17
],
[
140,
22
],
[
143,
25
],
[
125,
28
],
[
32,
31
],
[
135,
34
],
[
146,
36
],
[
149,
39
],
[
43,
42
],
[
117,
45
],
[
141,
50
],
[
31,
51
],
[
42,
52
],
[
147,
56
],
[
129,
56
],
[
128,
59
],
[
42,
60
],
[
119,
62
],
[
42,
63
],
[
42,
67
],
[
150,
68
],
[
138,
68
],
[
120,
68
],
[
137,
71
],
[
42,
72
],
[
131,
74
],
[
126,
79
],
[
86,
85
],
[
135,
89
],
[
126,
94
],
[
85,
96
],
[
126,
101
],
[
85,
102
],
[
122,
105
],
[
134,
117
],
[
42,
119
],
[
119,
120
],
[
122,
123
],
[
125,
126
],
[
42,
128
],
[
128,
129
],
[
131,
132
],
[
134,
135
],
[
42,
137
],
[
137,
138
],
[
140,
141
],
[
143,
144
],
[
146,
147
],
[
149,
150
]
] |
[
"H,W=map(int,input().split())\nA=[input() for i in range(H)]\n\nIsPossible=True\nres=[]\nfor y in range(H):\n left=-1\n right=0\n for x in range(W):\n if A[y][x]=='#':\n if left<0:\n left=x\n right=x\n else:\n if x-right==1:\n right=x\n else:\n IsPossible=False\n break\n res.append((left,right))\n\nfor y in range(1,H):\n if res[y-1][1]!=res[y][0]:\n IsPossible=False\n\nif IsPossible:\n print('Possible')\nelse:\n print('Impossible')",
"H,W=map(int,input().split())",
"H",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"input() for i in range(H)",
"for i in range(H)",
"i",
"range(H)",
"range",
"H",
"for i in range(H)",
"input()",
"input",
"A=[input() for i in range(H)]",
"A",
"[input() for i in range(H)]",
"IsPossible=True",
"IsPossible",
"True",
"res=[]",
"res",
"[]",
"for y in range(H):\n left=-1\n right=0\n for x in range(W):\n if A[y][x]=='#':\n if left<0:\n left=x\n right=x\n else:\n if x-right==1:\n right=x\n else:\n IsPossible=False\n break\n res.append((left,right))",
"y",
"range(H)",
"range",
"H",
"left=-1",
"left",
"-1",
"right=0",
"right",
"0",
"for x in range(W):\n if A[y][x]=='#':\n if left<0:\n left=x\n right=x\n else:\n if x-right==1:\n right=x\n else:\n IsPossible=False\n break\n ",
"x",
"range(W)",
"range",
"W",
"if A[y][x]=='#':\n if left<0:\n left=x\n right=x\n else:\n if x-right==1:\n right=x\n else:\n IsPossible=False\n break\n ",
"A[y][x]=='#'",
"A[y][x]",
"[y]",
"A",
"y",
"x",
"'#'",
"if left<0:\n left=x\n right=x\n else:\n if x-right==1:\n right=x\n else:\n IsPossible=False\n break\n ",
"left<0",
"left",
"0",
"left=x",
"left",
"x",
"right=x",
"right",
"x",
"if x-right==1:\n right=x\n else:\n IsPossible=False\n break\n ",
"x-right==1",
"x-right",
"x",
"right",
"1",
"right=x",
"right",
"x",
"IsPossible=False",
"IsPossible",
"False",
"break",
"res.append((left,right))",
"res.append",
"res",
"append",
"(left,right)",
"left",
"right",
"for y in range(1,H):\n if res[y-1][1]!=res[y][0]:\n IsPossible=False",
"y",
"range(1,H)",
"range",
"1",
"H",
"if res[y-1][1]!=res[y][0]:\n IsPossible=False",
"res[y-1][1]!=res[y][0]",
"res[y-1][1]",
"[y-1]",
"res",
"y-1",
"y",
"1",
"1",
"res[y][0]",
"[y]",
"res",
"y",
"0",
"IsPossible=False",
"IsPossible",
"False",
"if IsPossible:\n print('Possible')\nelse:\n print('Impossible')",
"IsPossible",
"print('Possible')",
"print",
"'Possible'",
"print('Impossible')",
"print",
"'Impossible'",
"W=map(int,input().split())",
"map(int,input().split())",
"W",
"right=x",
"x",
"right",
"IsPossible=False",
"False",
"IsPossible",
"res=[]",
"[]",
"res",
"left=x",
"x",
"left",
"IsPossible=False",
"False",
"IsPossible",
"H,W=map(int,input().split())",
"map(int,input().split())",
"H",
"right=x",
"x",
"right",
"A=[input() for i in range(H)]",
"[input() for i in range(H)]",
"A",
"IsPossible=True",
"True",
"IsPossible",
"left=-1",
"-1",
"left",
"right=0",
"0",
"right"
] |
H,W=map(int,input().split())
A=[input() for i in range(H)]
IsPossible=True
res=[]
for y in range(H):
left=-1
right=0
for x in range(W):
if A[y][x]=='#':
if left<0:
left=x
right=x
else:
if x-right==1:
right=x
else:
IsPossible=False
break
res.append((left,right))
for y in range(1,H):
if res[y-1][1]!=res[y][0]:
IsPossible=False
if IsPossible:
print('Possible')
else:
print('Impossible')
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
2,
13,
17,
28,
13,
4,
13,
2,
13,
17,
14,
2,
2,
2,
18,
18,
13,
13,
13,
17,
2,
18,
18,
13,
2,
13,
17,
13,
17,
2,
18,
18,
13,
13,
2,
13,
17,
17,
0,
13,
17,
14,
2,
2,
2,
18,
18,
13,
13,
13,
17,
2,
18,
18,
13,
2,
13,
17,
13,
17,
2,
18,
18,
13,
13,
2,
13,
17,
17,
0,
13,
17,
28,
13,
4,
13,
17,
13,
28,
13,
4,
13,
17,
13,
14,
2,
2,
2,
18,
18,
13,
13,
13,
17,
2,
18,
18,
13,
2,
13,
17,
13,
17,
2,
18,
18,
13,
13,
2,
13,
17,
17,
0,
13,
17,
4,
13,
8,
2,
13,
17,
17,
17,
10,
13,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] |
[
[
179,
2
],
[
179,
11
],
[
15,
14
],
[
174,
17
],
[
158,
22
],
[
176,
25
],
[
161,
28
],
[
32,
31
],
[
174,
35
],
[
39,
38
],
[
180,
42
],
[
159,
50
],
[
31,
51
],
[
38,
52
],
[
159,
57
],
[
31,
59
],
[
38,
61
],
[
159,
66
],
[
31,
67
],
[
38,
69
],
[
167,
73
],
[
159,
81
],
[
31,
82
],
[
38,
83
],
[
159,
88
],
[
31,
90
],
[
38,
92
],
[
159,
97
],
[
31,
98
],
[
38,
100
],
[
164,
104
],
[
108,
107
],
[
174,
111
],
[
114,
113
],
[
180,
117
],
[
159,
124
],
[
107,
125
],
[
113,
126
],
[
159,
131
],
[
107,
133
],
[
113,
135
],
[
159,
140
],
[
107,
141
],
[
113,
143
],
[
170,
147
],
[
171,
153
],
[
165,
153
],
[
168,
153
],
[
162,
153
],
[
158,
159
],
[
161,
162
],
[
164,
165
],
[
167,
168
],
[
170,
171
],
[
179,
174
],
[
176,
177
],
[
179,
180
]
] |
[
"H,W=map(int, input().split())\na = [input() for i in range(H)]\n\nans=0\ncnt=0\n \nfor i in range(H-1):\n for j in range(W-1):\n if a[i][j] == '#' and a[i+1][j] == '#' and a[i][j+1] == '#':\n cnt+=1\n elif a[i][j] == '#' and a[i+1][j] == '.' and a[i][j+1] == '.':\n cnt+=1\n\n \nfor i in range(1,H):\n for j in range(1,W):\n if a[i][j] == '#' and a[i-1][j] == '.' and a[i][j-1] == '.':\n cnt+=1\n\n \nprint('Impossible' if cnt>0 else 'Possible')",
"H,W=map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"input() for i in range(H)",
"for i in range(H)",
"i",
"range(H)",
"range",
"H",
"for i in range(H)",
"input()",
"input",
"a = [input() for i in range(H)]",
"a",
"[input() for i in range(H)]",
"ans=0",
"ans",
"0",
"cnt=0",
"cnt",
"0",
"for i in range(H-1):\n for j in range(W-1):\n if a[i][j] == '#' and a[i+1][j] == '#' and a[i][j+1] == '#':\n cnt+=1\n elif a[i][j] == '#' and a[i+1][j] == '.' and a[i][j+1] == '.':\n cnt+=1\n\n ",
"i",
"range(H-1)",
"range",
"H-1",
"H",
"1",
"for j in range(W-1):\n if a[i][j] == '#' and a[i+1][j] == '#' and a[i][j+1] == '#':\n cnt+=1\n elif a[i][j] == '#' and a[i+1][j] == '.' and a[i][j+1] == '.':\n cnt+=1\n\n ",
"j",
"range(W-1)",
"range",
"W-1",
"W",
"1",
"if a[i][j] == '#' and a[i+1][j] == '#' and a[i][j+1] == '#':\n cnt+=1\n elif a[i][j] == '#' and a[i+1][j] == '.' and a[i][j+1] == '.':\n cnt+=1\n\n ",
"a[i][j] == '#' and a[i+1][j] == '#' and a[i][j+1] == '#'",
"a[i][j] == '#' and a[i+1][j] == '#'",
"a[i][j] == '#'",
"a[i][j]",
"[i]",
"a",
"i",
"j",
"'#'",
"a[i+1][j] == '#'",
"a[i+1][j]",
"[i+1]",
"a",
"i+1",
"i",
"1",
"j",
"'#'",
"a[i][j+1] == '#'",
"a[i][j+1]",
"[i]",
"a",
"i",
"j+1",
"j",
"1",
"'#'",
"cnt+=1",
"cnt",
"1",
"elif a[i][j] == '#' and a[i+1][j] == '.' and a[i][j+1] == '.':\n cnt+=1\n\n ",
"a[i][j] == '#' and a[i+1][j] == '.' and a[i][j+1] == '.'",
"a[i][j] == '#' and a[i+1][j] == '.'",
"a[i][j] == '#'",
"a[i][j]",
"[i]",
"a",
"i",
"j",
"'#'",
"a[i+1][j] == '.'",
"a[i+1][j]",
"[i+1]",
"a",
"i+1",
"i",
"1",
"j",
"'.'",
"a[i][j+1] == '.'",
"a[i][j+1]",
"[i]",
"a",
"i",
"j+1",
"j",
"1",
"'.'",
"cnt+=1",
"cnt",
"1",
"for i in range(1,H):\n for j in range(1,W):\n if a[i][j] == '#' and a[i-1][j] == '.' and a[i][j-1] == '.':\n cnt+=1\n\n ",
"i",
"range(1,H)",
"range",
"1",
"H",
"for j in range(1,W):\n if a[i][j] == '#' and a[i-1][j] == '.' and a[i][j-1] == '.':\n cnt+=1\n\n ",
"j",
"range(1,W)",
"range",
"1",
"W",
"if a[i][j] == '#' and a[i-1][j] == '.' and a[i][j-1] == '.':\n cnt+=1\n\n ",
"a[i][j] == '#' and a[i-1][j] == '.' and a[i][j-1] == '.'",
"a[i][j] == '#' and a[i-1][j] == '.'",
"a[i][j] == '#'",
"a[i][j]",
"[i]",
"a",
"i",
"j",
"'#'",
"a[i-1][j] == '.'",
"a[i-1][j]",
"[i-1]",
"a",
"i-1",
"i",
"1",
"j",
"'.'",
"a[i][j-1] == '.'",
"a[i][j-1]",
"[i]",
"a",
"i",
"j-1",
"j",
"1",
"'.'",
"cnt+=1",
"cnt",
"1",
"print('Impossible' if cnt>0 else 'Possible')",
"print",
"'Impossible' if cnt>0 else 'Possible'",
"cnt>0",
"cnt",
"0",
"'Impossible'",
"'Possible'",
"a = [input() for i in range(H)]",
"[input() for i in range(H)]",
"a",
"cnt=0",
"0",
"cnt",
"cnt+=1",
"1",
"cnt",
"cnt+=1",
"1",
"cnt",
"cnt+=1",
"1",
"cnt",
"H,W=map(int, input().split())",
"map(int, input().split())",
"H",
"ans=0",
"0",
"ans",
"W=map(int, input().split())",
"map(int, input().split())",
"W"
] |
H,W=map(int, input().split())
a = [input() for i in range(H)]
ans=0
cnt=0
for i in range(H-1):
for j in range(W-1):
if a[i][j] == '#' and a[i+1][j] == '#' and a[i][j+1] == '#':
cnt+=1
elif a[i][j] == '#' and a[i+1][j] == '.' and a[i][j+1] == '.':
cnt+=1
for i in range(1,H):
for j in range(1,W):
if a[i][j] == '#' and a[i-1][j] == '.' and a[i][j-1] == '.':
cnt+=1
print('Impossible' if cnt>0 else 'Possible')
|
[
7,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
28,
13,
4,
13,
17,
13,
41,
28,
13,
13,
4,
13,
18,
13,
2,
13,
17,
2,
13,
17,
4,
13,
0,
13,
13,
41,
28,
13,
13,
4,
13,
18,
13,
13,
2,
13,
17,
4,
13,
0,
13,
13,
14,
2,
2,
4,
13,
2,
4,
13,
13,
4,
13,
13,
17,
2,
18,
13,
17,
18,
13,
17,
9,
4,
13,
17,
4,
13,
4,
13,
17,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13
] |
[
[
103,
3
],
[
103,
12
],
[
16,
15
],
[
98,
18
],
[
106,
23
],
[
27,
26
],
[
98,
30
],
[
107,
38
],
[
26,
40
],
[
26,
46
],
[
109,
48
],
[
107,
57
],
[
26,
58
],
[
26,
63
],
[
100,
65
],
[
110,
75
],
[
101,
78
],
[
110,
82
],
[
101,
85
],
[
103,
98
],
[
100,
101
],
[
103,
104
],
[
106,
107
],
[
109,
110
]
] |
[
"\"\"\"\ni-1行目の右端のマスとi行目の左端のマスが隣接しており、\nそれらの行においてはそれ以外のマスは隣接していないこと。\n\n以上を満たした場合に'Possible'を出力すればよさそう。\n\"\"\"\nH, W = map(int, input().split())\ntable = [input() for _ in range(H)]\nfor i in range(1, H):\n li_pre = [i for i, x in enumerate(table[i - 1]) if x == \"#\"]\n li_now = [i for i, x in enumerate(table[i]) if x == \"#\"]\n if len(set(li_pre) & set(li_now)) == 1 and li_pre[-1] == li_now[0]:\n continue\n else:\n print('Impossible')\n exit()\nprint('Possible')",
"\"\"\"\ni-1行目の右端のマスとi行目の左端のマスが隣接しており、\nそれらの行においてはそれ以外のマスは隣接していないこと。\n\n以上を満たした場合に'Possible'を出力すればよさそう。\n\"\"\"",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"input() for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"input()",
"input",
"table = [input() for _ in range(H)]",
"table",
"[input() for _ in range(H)]",
"for i in range(1, H):\n li_pre = [i for i, x in enumerate(table[i - 1]) if x == \"#\"]\n li_now = [i for i, x in enumerate(table[i]) if x == \"#\"]\n if len(set(li_pre) & set(li_now)) == 1 and li_pre[-1] == li_now[0]:\n continue\n else:\n print('Impossible')\n exit()",
"i",
"range(1, H)",
"range",
"1",
"H",
"i for i, x in enumerate(table[i - 1]) if x == \"#\"",
"for i, x in enumerate(table[i - 1]) if x == \"#\"",
"i",
"x",
"enumerate(table[i - 1])",
"enumerate",
"table[i - 1]",
"table",
"i - 1",
"i",
"1",
"x == \"#\"",
"x",
"\"#\"",
"if x == \"#\"",
"i",
"li_pre = [i for i, x in enumerate(table[i - 1]) if x == \"#\"]",
"li_pre",
"[i for i, x in enumerate(table[i - 1]) if x == \"#\"]",
"i for i, x in enumerate(table[i]) if x == \"#\"",
"for i, x in enumerate(table[i]) if x == \"#\"",
"i",
"x",
"enumerate(table[i])",
"enumerate",
"table[i]",
"table",
"i",
"x == \"#\"",
"x",
"\"#\"",
"if x == \"#\"",
"i",
"li_now = [i for i, x in enumerate(table[i]) if x == \"#\"]",
"li_now",
"[i for i, x in enumerate(table[i]) if x == \"#\"]",
"if len(set(li_pre) & set(li_now)) == 1 and li_pre[-1] == li_now[0]:\n continue\n else:\n print('Impossible')\n exit()",
"len(set(li_pre) & set(li_now)) == 1 and li_pre[-1] == li_now[0]",
"len(set(li_pre) & set(li_now)) == 1",
"len(set(li_pre) & set(li_now))",
"len",
"set(li_pre) & set(li_now)",
"set(li_pre)",
"set",
"li_pre",
"set(li_now)",
"set",
"li_now",
"1",
"li_pre[-1] == li_now[0]",
"li_pre[-1]",
"li_pre",
"-1",
"li_now[0]",
"li_now",
"0",
"continue",
"print('Impossible')",
"print",
"'Impossible'",
"exit()",
"exit",
"print('Possible')",
"print",
"'Possible'",
"H, W = map(int, input().split())",
"map(int, input().split())",
"H",
"li_now = [i for i, x in enumerate(table[i]) if x == \"#\"]",
"[i for i, x in enumerate(table[i]) if x == \"#\"]",
"li_now",
"W = map(int, input().split())",
"map(int, input().split())",
"W",
"table = [input() for _ in range(H)]",
"[input() for _ in range(H)]",
"table",
"li_pre = [i for i, x in enumerate(table[i - 1]) if x == \"#\"]",
"[i for i, x in enumerate(table[i - 1]) if x == \"#\"]",
"li_pre"
] |
"""
i-1行目の右端のマスとi行目の左端のマスが隣接しており、
それらの行においてはそれ以外のマスは隣接していないこと。
以上を満たした場合に'Possible'を出力すればよさそう。
"""
H, W = map(int, input().split())
table = [input() for _ in range(H)]
for i in range(1, H):
li_pre = [i for i, x in enumerate(table[i - 1]) if x == "#"]
li_now = [i for i, x in enumerate(table[i]) if x == "#"]
if len(set(li_pre) & set(li_now)) == 1 and li_pre[-1] == li_now[0]:
continue
else:
print('Impossible')
exit()
print('Possible')
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
18,
4,
13,
13,
17,
4,
13,
8,
2,
13,
2,
2,
13,
13,
17,
17,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
41,
2
],
[
41,
11
],
[
35,
13
],
[
36,
26
],
[
42,
29
],
[
39,
30
],
[
35,
36
],
[
41,
39
],
[
41,
42
]
] |
[
"h, w = map(int, input().split())\na = sum(input().count('#') for _ in range(h))\nprint('Possible' if a == h + w - 1 else 'Impossible')",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"a = sum(input().count('#') for _ in range(h))",
"a",
"sum(input().count('#') for _ in range(h))",
"sum",
"input().count('#')",
"().count",
"()",
"input",
"count",
"'#'",
"print('Possible' if a == h + w - 1 else 'Impossible')",
"print",
"'Possible' if a == h + w - 1 else 'Impossible'",
"a == h + w - 1",
"a",
"h + w - 1",
"h + w",
"h",
"w",
"1",
"'Possible'",
"'Impossible'",
"a = sum(input().count('#') for _ in range(h))",
"sum(input().count('#') for _ in range(h))",
"a",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h"
] |
h, w = map(int, input().split())
a = sum(input().count('#') for _ in range(h))
print('Possible' if a == h + w - 1 else 'Impossible')
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
13,
28,
13,
13,
14,
2,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13
] |
[
[
55,
2
],
[
55,
11
],
[
15,
14
],
[
53,
17
],
[
46,
22
],
[
49,
25
],
[
29,
28
],
[
47,
28
],
[
32,
31
],
[
28,
31
],
[
31,
35
],
[
50,
39
],
[
53,
42
],
[
56,
43
],
[
46,
47
],
[
49,
50
],
[
55,
53
],
[
55,
56
]
] |
[
"h,w=map(int,input().split())\na=[input()for _ in range(h)]\nc=0\nfor i in a:\n for j in i:\n if j==\"#\":c+=1\nif c==h+w-1:print(\"Possible\")\nelse:print(\"Impossible\")",
"h,w=map(int,input().split())",
"h",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"input()for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"input()",
"input",
"a=[input()for _ in range(h)]",
"a",
"[input()for _ in range(h)]",
"c=0",
"c",
"0",
"for i in a:\n for j in i:\n if j==\"#\":c+=1",
"i",
"a",
"for j in i:\n if j==\"#\":c+=1",
"j",
"i",
"if j==\"#\":",
"j==\"#\"",
"j",
"\"#\"",
"if c==h+w-1:print(\"Possible\")\nelse:print(\"Impossible\")",
"c==h+w-1",
"c",
"h+w-1",
"h+w",
"h",
"w",
"1",
"a=[input()for _ in range(h)]",
"[input()for _ in range(h)]",
"a",
"c=0",
"0",
"c",
"h,w=map(int,input().split())",
"map(int,input().split())",
"h",
"w=map(int,input().split())",
"map(int,input().split())",
"w"
] |
h,w=map(int,input().split())
a=[input()for _ in range(h)]
c=0
for i in a:
for j in i:
if j=="#":c+=1
if c==h+w-1:print("Possible")
else:print("Impossible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
28,
13,
13,
14,
2,
13,
17,
0,
13,
17,
4,
13,
8,
2,
13,
2,
2,
13,
13,
17,
17,
17,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
59,
2
],
[
59,
11
],
[
50,
13
],
[
17,
16
],
[
60,
19
],
[
53,
21
],
[
26,
25
],
[
54,
25
],
[
25,
29
],
[
47,
32
],
[
48,
38
],
[
51,
38
],
[
60,
41
],
[
57,
42
],
[
47,
48
],
[
50,
51
],
[
53,
54
],
[
59,
57
],
[
59,
60
]
] |
[
"h, w = map(int, input().split())\ncount = 0\nfor i in range(h):\n a = input()\n for char in a:\n if char == '#':\n count += 1\nprint('Possible' if count == h + w - 1 else 'Impossible')",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"count = 0",
"count",
"0",
"for i in range(h):\n a = input()\n for char in a:\n if char == '#':\n count += 1",
"i",
"range(h)",
"range",
"h",
"a = input()",
"a",
"input()",
"input",
"for char in a:\n if char == '#':\n count += 1",
"char",
"a",
"if char == '#':\n count += 1",
"char == '#'",
"char",
"'#'",
"count += 1",
"count",
"1",
"print('Possible' if count == h + w - 1 else 'Impossible')",
"print",
"'Possible' if count == h + w - 1 else 'Impossible'",
"count == h + w - 1",
"count",
"h + w - 1",
"h + w",
"h",
"w",
"1",
"'Possible'",
"'Impossible'",
"count += 1",
"1",
"count",
"count = 0",
"0",
"count",
"a = input()",
"input()",
"a",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h"
] |
h, w = map(int, input().split())
count = 0
for i in range(h):
a = input()
for char in a:
if char == '#':
count += 1
print('Possible' if count == h + w - 1 else 'Impossible')
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
17,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
18,
18,
13,
13,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13
] |
[
[
68,
2
],
[
68,
12
],
[
16,
15
],
[
69,
18
],
[
65,
25
],
[
59,
28
],
[
32,
31
],
[
69,
34
],
[
71,
36
],
[
66,
40
],
[
31,
41
],
[
72,
46
],
[
60,
46
],
[
69,
49
],
[
63,
50
],
[
59,
60
],
[
68,
63
],
[
65,
66
],
[
68,
69
],
[
71,
72
]
] |
[
"N,M=map(int,input().split(' '))\nmaze = [list(input()) for i in range(N)]\ntmp = 0\nfor i in range(N):\n tmp += maze[i].count('#')\nif tmp == N+M-1:\n print('Possible')\nelse:\n print('Impossible')",
"N,M=map(int,input().split(' '))",
"N",
"map(int,input().split(' '))",
"map",
"int",
"input().split(' ')",
"().split",
"()",
"input",
"split",
"' '",
"M",
"list(input()) for i in range(N)",
"for i in range(N)",
"i",
"range(N)",
"range",
"N",
"for i in range(N)",
"list(input())",
"list",
"input()",
"input",
"maze = [list(input()) for i in range(N)]",
"maze",
"[list(input()) for i in range(N)]",
"tmp = 0",
"tmp",
"0",
"for i in range(N):\n tmp += maze[i].count('#')",
"i",
"range(N)",
"range",
"N",
"tmp += maze[i].count('#')",
"tmp",
"maze[i].count('#')",
"[i].count",
"[i]",
"maze",
"i",
"count",
"'#'",
"if tmp == N+M-1:\n print('Possible')\nelse:\n print('Impossible')",
"tmp == N+M-1",
"tmp",
"N+M-1",
"N+M",
"N",
"M",
"1",
"print('Possible')",
"print",
"'Possible'",
"print('Impossible')",
"print",
"'Impossible'",
"tmp = 0",
"0",
"tmp",
"M=map(int,input().split(' '))",
"map(int,input().split(' '))",
"M",
"maze = [list(input()) for i in range(N)]",
"[list(input()) for i in range(N)]",
"maze",
"N,M=map(int,input().split(' '))",
"map(int,input().split(' '))",
"N",
"tmp += maze[i].count('#')",
"maze[i].count('#')",
"tmp"
] |
N,M=map(int,input().split(' '))
maze = [list(input()) for i in range(N)]
tmp = 0
for i in range(N):
tmp += maze[i].count('#')
if tmp == N+M-1:
print('Possible')
else:
print('Impossible')
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
17,
14,
2,
40,
18,
18,
13,
13,
13,
17,
2,
17,
18,
18,
13,
13,
39,
13,
0,
13,
17,
3,
28,
13,
4,
13,
13,
13,
14,
40,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
13,
0,
13,
17,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
3,
14,
2,
2,
2,
13,
2,
13,
17,
2,
13,
2,
13,
17,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
14,
13,
3,
14,
13,
4,
13,
17,
4,
13,
17,
10,
17,
13,
10,
13,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13
] |
[
[
159,
2
],
[
159,
11
],
[
15,
14
],
[
160,
17
],
[
147,
22
],
[
138,
25
],
[
144,
28
],
[
32,
31
],
[
160,
34
],
[
129,
36
],
[
148,
43
],
[
31,
44
],
[
139,
45
],
[
133,
45
],
[
148,
51
],
[
31,
52
],
[
156,
56
],
[
61,
60
],
[
139,
63
],
[
133,
63
],
[
136,
64
],
[
130,
67
],
[
154,
67
],
[
148,
72
],
[
31,
73
],
[
60,
74
],
[
132,
77
],
[
60,
78
],
[
153,
80
],
[
148,
86
],
[
31,
87
],
[
60,
88
],
[
141,
91
],
[
31,
98
],
[
160,
100
],
[
60,
103
],
[
136,
105
],
[
148,
110
],
[
31,
111
],
[
60,
112
],
[
150,
115
],
[
129,
130
],
[
60,
132
],
[
132,
133
],
[
159,
136
],
[
138,
139
],
[
141,
142
],
[
144,
145
],
[
147,
148
],
[
150,
151
],
[
153,
154
],
[
156,
157
],
[
159,
160
]
] |
[
"h, w = map(int, input().split())\na = [input() for _ in range(h)]\nnow = 0\nng = 0\nfor i in range(h):\n # print(now)\n # 限界まで伸ばせる点を探し、それより先に#がないことを確認\n extended = 0\n if a[i][now] != \"#\" or \"#\" in a[i][:now]:\n ng = 1\n # print(i, now)\n break\n for j in range(now, w):\n if not extended:\n if a[i][j] == \"#\":\n now = j\n else:\n extended = 1\n else:\n if a[i][j] == \"#\":\n #print(i, j)\n ng = 1\n break\n if i == h - 1 and j == w - 1 and a[i][j] == \".\":\n ng = 1\n if ng:\n break\nif ng:\n print(\"Impossible\")\nelse:\n print(\"Possible\")",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"input() for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"input()",
"input",
"a = [input() for _ in range(h)]",
"a",
"[input() for _ in range(h)]",
"now = 0",
"now",
"0",
"ng = 0",
"ng",
"0",
"for i in range(h):\n # print(now)\n # 限界まで伸ばせる点を探し、それより先に#がないことを確認\n extended = 0\n if a[i][now] != \"#\" or \"#\" in a[i][:now]:\n ng = 1\n # print(i, now)\n break\n for j in range(now, w):\n if not extended:\n if a[i][j] == \"#\":\n now = j\n else:\n extended = 1\n else:\n if a[i][j] == \"#\":\n #print(i, j)\n ng = 1\n break\n if i == h - 1 and j == w - 1 and a[i][j] == \".\":\n ng = 1\n if ng:\n break",
"i",
"range(h)",
"range",
"h",
"extended = 0",
"extended",
"0",
"if a[i][now] != \"#\" or \"#\" in a[i][:now]:\n ng = 1\n # print(i, now)\n break\n ",
"a[i][now] != \"#\" or \"#\" in a[i][:now]",
"a[i][now] != \"#\"",
"a[i][now]",
"[i]",
"a",
"i",
"now",
"\"#\"",
"\"#\" in a[i][:now]",
"\"#\"",
"a[i][:now]",
"[i]",
"a",
"i",
":now",
"now",
"ng = 1",
"ng",
"1",
"break",
"for j in range(now, w):\n if not extended:\n if a[i][j] == \"#\":\n now = j\n else:\n extended = 1\n else:\n if a[i][j] == \"#\":\n #print(i, j)\n ng = 1\n break\n if i == h - 1 and j == w - 1 and a[i][j] == \".\":\n ng = 1\n ",
"j",
"range(now, w)",
"range",
"now",
"w",
"if not extended:\n if a[i][j] == \"#\":\n now = j\n else:\n extended = 1\n else:\n if a[i][j] == \"#\":\n #print(i, j)\n ng = 1\n break\n ",
"not extended",
"extended",
"if a[i][j] == \"#\":\n now = j\n else:\n extended = 1\n ",
"a[i][j] == \"#\"",
"a[i][j]",
"[i]",
"a",
"i",
"j",
"\"#\"",
"now = j",
"now",
"j",
"extended = 1",
"extended",
"1",
"if a[i][j] == \"#\":\n #print(i, j)\n ng = 1\n break\n ",
"a[i][j] == \"#\"",
"a[i][j]",
"[i]",
"a",
"i",
"j",
"\"#\"",
"ng = 1",
"ng",
"1",
"break",
"if i == h - 1 and j == w - 1 and a[i][j] == \".\":\n ng = 1\n ",
"i == h - 1 and j == w - 1 and a[i][j] == \".\"",
"i == h - 1 and j == w - 1",
"i == h - 1",
"i",
"h - 1",
"h",
"1",
"j == w - 1",
"j",
"w - 1",
"w",
"1",
"a[i][j] == \".\"",
"a[i][j]",
"[i]",
"a",
"i",
"j",
"\".\"",
"ng = 1",
"ng",
"1",
"if ng:\n break",
"ng",
"break",
"if ng:\n print(\"Impossible\")\nelse:\n print(\"Possible\")",
"ng",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"print(\"Possible\")",
"print",
"\"Possible\"",
"extended = 0",
"0",
"extended",
"now = j",
"j",
"now",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"now = 0",
"0",
"now",
"ng = 1",
"1",
"ng",
"ng = 0",
"0",
"ng",
"a = [input() for _ in range(h)]",
"[input() for _ in range(h)]",
"a",
"ng = 1",
"1",
"ng",
"extended = 1",
"1",
"extended",
"ng = 1",
"1",
"ng",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h"
] |
h, w = map(int, input().split())
a = [input() for _ in range(h)]
now = 0
ng = 0
for i in range(h):
# print(now)
# 限界まで伸ばせる点を探し、それより先に#がないことを確認
extended = 0
if a[i][now] != "#" or "#" in a[i][:now]:
ng = 1
# print(i, now)
break
for j in range(now, w):
if not extended:
if a[i][j] == "#":
now = j
else:
extended = 1
else:
if a[i][j] == "#":
#print(i, j)
ng = 1
break
if i == h - 1 and j == w - 1 and a[i][j] == ".":
ng = 1
if ng:
break
if ng:
print("Impossible")
else:
print("Possible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
0,
13,
4,
18,
13,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13
] |
[
[
49,
2
],
[
49,
11
],
[
58,
13
],
[
17,
16
],
[
50,
19
],
[
52,
21
],
[
55,
25
],
[
53,
28
],
[
56,
33
],
[
59,
33
],
[
50,
36
],
[
47,
37
],
[
49,
47
],
[
49,
50
],
[
52,
53
],
[
55,
56
],
[
58,
59
]
] |
[
"H, W = map(int, input().split())\nans = 0\nfor _ in range(H):\n a = input()\n ans += a.count(\"#\")\nif ans == H+W-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"ans = 0",
"ans",
"0",
"for _ in range(H):\n a = input()\n ans += a.count(\"#\")",
"_",
"range(H)",
"range",
"H",
"a = input()",
"a",
"input()",
"input",
"ans += a.count(\"#\")",
"ans",
"a.count(\"#\")",
"a.count",
"a",
"count",
"\"#\"",
"if ans == H+W-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"ans == H+W-1",
"ans",
"H+W-1",
"H+W",
"H",
"W",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"W = map(int, input().split())",
"map(int, input().split())",
"W",
"H, W = map(int, input().split())",
"map(int, input().split())",
"H",
"a = input()",
"input()",
"a",
"ans += a.count(\"#\")",
"a.count(\"#\")",
"ans",
"ans = 0",
"0",
"ans"
] |
H, W = map(int, input().split())
ans = 0
for _ in range(H):
a = input()
ans += a.count("#")
if ans == H+W-1:
print("Possible")
else:
print("Impossible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
18,
18,
13,
13,
13,
17,
4,
13,
8,
2,
13,
2,
2,
13,
13,
17,
17,
17,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13
] |
[
[
68,
2
],
[
68,
11
],
[
15,
14
],
[
63,
17
],
[
65,
24
],
[
56,
27
],
[
31,
30
],
[
63,
33
],
[
59,
35
],
[
66,
39
],
[
30,
40
],
[
60,
47
],
[
57,
47
],
[
63,
50
],
[
69,
51
],
[
56,
57
],
[
59,
60
],
[
68,
63
],
[
65,
66
],
[
68,
69
]
] |
[
"H, W = map(int, input().split())\nA = [list(input()) for _ in range(H)]\n\ncnt = 0\nfor i in range(H):\n cnt += A[i].count(\"#\")\nprint(\"Possible\" if cnt == H + W - 1 else \"Impossible\")",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"list(input()) for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"list(input())",
"list",
"input()",
"input",
"A = [list(input()) for _ in range(H)]",
"A",
"[list(input()) for _ in range(H)]",
"cnt = 0",
"cnt",
"0",
"for i in range(H):\n cnt += A[i].count(\"#\")",
"i",
"range(H)",
"range",
"H",
"cnt += A[i].count(\"#\")",
"cnt",
"A[i].count(\"#\")",
"[i].count",
"[i]",
"A",
"i",
"count",
"\"#\"",
"print(\"Possible\" if cnt == H + W - 1 else \"Impossible\")",
"print",
"\"Possible\" if cnt == H + W - 1 else \"Impossible\"",
"cnt == H + W - 1",
"cnt",
"H + W - 1",
"H + W",
"H",
"W",
"1",
"\"Possible\"",
"\"Impossible\"",
"cnt = 0",
"0",
"cnt",
"cnt += A[i].count(\"#\")",
"A[i].count(\"#\")",
"cnt",
"H, W = map(int, input().split())",
"map(int, input().split())",
"H",
"A = [list(input()) for _ in range(H)]",
"[list(input()) for _ in range(H)]",
"A",
"W = map(int, input().split())",
"map(int, input().split())",
"W"
] |
H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]
cnt = 0
for i in range(H):
cnt += A[i].count("#")
print("Possible" if cnt == H + W - 1 else "Impossible")
|
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
18,
13,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13
] |
[
[
55,
3
],
[
55,
12
],
[
61,
14
],
[
18,
17
],
[
53,
20
],
[
58,
22
],
[
49,
28
],
[
59,
31
],
[
62,
32
],
[
50,
32
],
[
50,
36
],
[
62,
36
],
[
53,
39
],
[
56,
40
],
[
49,
50
],
[
55,
53
],
[
55,
56
],
[
58,
59
],
[
61,
62
]
] |
[
"from itertools import chain\n\nH, W = map(int, input().split())\ncount = 0\nfor _ in range(H):\n l = list(input())\n count += l.count(\"#\")\n\nif count == H+W - 1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"from itertools import chain",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"count = 0",
"count",
"0",
"for _ in range(H):\n l = list(input())\n count += l.count(\"#\")",
"_",
"range(H)",
"range",
"H",
"l = list(input())",
"l",
"list(input())",
"list",
"input()",
"input",
"count += l.count(\"#\")",
"count",
"l.count(\"#\")",
"l.count",
"l",
"count",
"\"#\"",
"if count == H+W - 1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"count == H+W - 1",
"count",
"H+W - 1",
"H+W",
"H",
"W",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"count += l.count(\"#\")",
"l.count(\"#\")",
"count",
"H, W = map(int, input().split())",
"map(int, input().split())",
"H",
"W = map(int, input().split())",
"map(int, input().split())",
"W",
"l = list(input())",
"list(input())",
"l",
"count = 0",
"0",
"count"
] |
from itertools import chain
H, W = map(int, input().split())
count = 0
for _ in range(H):
l = list(input())
count += l.count("#")
if count == H+W - 1:
print("Possible")
else:
print("Impossible")
|
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
0,
13,
4,
13,
39,
39,
17,
17,
39,
39,
17,
17,
0,
13,
17,
42,
13,
0,
13,
4,
18,
13,
13,
13,
13,
14,
2,
39,
13,
13,
39,
2,
13,
17,
2,
13,
17,
28,
13,
13,
13,
0,
18,
18,
13,
13,
13,
17,
3,
28,
13,
13,
39,
39,
17,
17,
39,
17,
17,
0,
13,
2,
13,
13,
13,
2,
13,
13,
14,
2,
2,
2,
2,
40,
17,
13,
13,
2,
40,
17,
13,
13,
2,
18,
18,
13,
13,
13,
17,
40,
39,
13,
13,
13,
4,
18,
13,
13,
39,
13,
13,
4,
18,
13,
13,
39,
13,
13,
2,
13,
39,
39,
13,
13,
14,
4,
13,
2,
17,
13,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
4,
13,
10,
2,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13
] |
[
[
175,
3
],
[
175,
12
],
[
16,
15
],
[
158,
18
],
[
163,
25
],
[
166,
28
],
[
178,
40
],
[
172,
45
],
[
167,
48
],
[
172,
50
],
[
172,
51
],
[
158,
59
],
[
176,
62
],
[
74,
69
],
[
164,
71
],
[
160,
87
],
[
155,
89
],
[
181,
91
],
[
173,
93
],
[
161,
102
],
[
158,
103
],
[
182,
107
],
[
176,
108
],
[
164,
112
],
[
161,
113
],
[
182,
114
],
[
179,
120
],
[
179,
123
],
[
167,
130
],
[
170,
136
],
[
172,
155
],
[
175,
158
],
[
160,
161
],
[
163,
164
],
[
166,
167
],
[
172,
170
],
[
172,
173
],
[
175,
176
],
[
178,
179
],
[
181,
182
]
] |
[
"from collections import deque\n\n\nH, W = map(int, input().split())\nfield = [list(input()) for _ in range(H)]\nq = deque([(0, 0, [(0, 0)])])\nvisited = {(0, 0)}\nwhile q:\n i, j, path = q.popleft()\n if (i, j) == (H - 1, W - 1):\n for pi, pj in path:\n field[pi][pj] = \".\"\n break\n for di, dj in ((1, 0), (0, 1)):\n ni, nj = i + di, j + dj\n if (\n 0 <= ni < H\n and 0 <= nj < W\n and field[ni][nj] == \"#\"\n and (ni, nj) not in visited\n ):\n visited.add((ni, nj))\n q.append((ni, nj, path + [(ni, nj)]))\n\nif any(\"#\" in row for row in field):\n print(\"Impossible\")\nelse:\n print(\"Possible\")",
"from collections import deque",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"list(input()) for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"list(input())",
"list",
"input()",
"input",
"field = [list(input()) for _ in range(H)]",
"field",
"[list(input()) for _ in range(H)]",
"q = deque([(0, 0, [(0, 0)])])",
"q",
"deque([(0, 0, [(0, 0)])])",
"deque",
"[(0, 0, [(0, 0)])]",
"(0, 0, [(0, 0)])",
"0",
"0",
"[(0, 0)]",
"(0, 0)",
"0",
"0",
"visited = {(0, 0)}",
"visited",
"{(0, 0)}",
"while q:\n i, j, path = q.popleft()\n if (i, j) == (H - 1, W - 1):\n for pi, pj in path:\n field[pi][pj] = \".\"\n break\n for di, dj in ((1, 0), (0, 1)):\n ni, nj = i + di, j + dj\n if (\n 0 <= ni < H\n and 0 <= nj < W\n and field[ni][nj] == \"#\"\n and (ni, nj) not in visited\n ):\n visited.add((ni, nj))\n q.append((ni, nj, path + [(ni, nj)]))",
"q",
"i, j, path = q.popleft()",
"i",
"q.popleft()",
"q.popleft",
"q",
"popleft",
"j",
"path",
"if (i, j) == (H - 1, W - 1):\n for pi, pj in path:\n field[pi][pj] = \".\"\n break\n ",
"(i, j) == (H - 1, W - 1)",
"(i, j)",
"i",
"j",
"(H - 1, W - 1)",
"H - 1",
"H",
"1",
"W - 1",
"W",
"1",
"for pi, pj in path:\n field[pi][pj] = \".\"\n ",
"pi",
"pj",
"path",
"field[pi][pj] = \".\"",
"field[pi][pj]",
"[pi]",
"field",
"pi",
"pj",
"\".\"",
"break",
"for di, dj in ((1, 0), (0, 1)):\n ni, nj = i + di, j + dj\n if (\n 0 <= ni < H\n and 0 <= nj < W\n and field[ni][nj] == \"#\"\n and (ni, nj) not in visited\n ):\n visited.add((ni, nj))\n q.append((ni, nj, path + [(ni, nj)]))",
"di",
"dj",
"((1, 0), (0, 1))",
"(1, 0)",
"1",
"0",
"(0, 1)",
"0",
"1",
"ni, nj = i + di, j + dj",
"ni",
"i + di",
"i",
"di",
"nj",
"j + dj",
"j",
"dj",
"if (\n 0 <= ni < H\n and 0 <= nj < W\n and field[ni][nj] == \"#\"\n and (ni, nj) not in visited\n ):\n visited.add((ni, nj))\n q.append((ni, nj, path + [(ni, nj)]))",
"0 <= ni < H\n and 0 <= nj < W\n and field[ni][nj] == \"#\"\n and (ni, nj) not in visited",
"0 <= ni < H\n and 0 <= nj < W\n and field[ni][nj] == \"#\"",
"0 <= ni < H\n and 0 <= nj < W",
"0 <= ni < H",
"0 <= ni",
"0",
"ni",
"H",
"0 <= nj < W",
"0 <= nj",
"0",
"nj",
"W",
"field[ni][nj] == \"#\"",
"field[ni][nj]",
"[ni]",
"field",
"ni",
"nj",
"\"#\"",
"(ni, nj) not in visited",
"(ni, nj)",
"ni",
"nj",
"visited",
"visited.add((ni, nj))",
"visited.add",
"visited",
"add",
"(ni, nj)",
"ni",
"nj",
"q.append((ni, nj, path + [(ni, nj)]))",
"q.append",
"q",
"append",
"(ni, nj, path + [(ni, nj)])",
"ni",
"nj",
"path + [(ni, nj)]",
"path",
"[(ni, nj)]",
"(ni, nj)",
"ni",
"nj",
"if any(\"#\" in row for row in field):\n print(\"Impossible\")\nelse:\n print(\"Possible\")",
"any(\"#\" in row for row in field)",
"any",
"\"#\" in row",
"\"#\"",
"row",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"print(\"Possible\")",
"print",
"\"Possible\"",
"i, j, path = q.popleft()",
"q.popleft()",
"i",
"H, W = map(int, input().split())",
"map(int, input().split())",
"H",
"ni, nj = i + di, j + dj",
"i + di",
"ni",
"field = [list(input()) for _ in range(H)]",
"[list(input()) for _ in range(H)]",
"field",
"q = deque([(0, 0, [(0, 0)])])",
"deque([(0, 0, [(0, 0)])])",
"q",
"path = q.popleft()",
"q.popleft()",
"path",
"j, path = q.popleft()",
"q.popleft()",
"j",
"W = map(int, input().split())",
"map(int, input().split())",
"W",
"visited = {(0, 0)}",
"{(0, 0)}",
"visited",
"nj = i + di, j + dj",
"j + dj",
"nj"
] |
from collections import deque
H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]
q = deque([(0, 0, [(0, 0)])])
visited = {(0, 0)}
while q:
i, j, path = q.popleft()
if (i, j) == (H - 1, W - 1):
for pi, pj in path:
field[pi][pj] = "."
break
for di, dj in ((1, 0), (0, 1)):
ni, nj = i + di, j + dj
if (
0 <= ni < H
and 0 <= nj < W
and field[ni][nj] == "#"
and (ni, nj) not in visited
):
visited.add((ni, nj))
q.append((ni, nj, path + [(ni, nj)]))
if any("#" in row for row in field):
print("Impossible")
else:
print("Possible")
|
[
7,
0,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
12,
13,
41,
0,
13,
17,
14,
2,
2,
2,
13,
17,
13,
2,
18,
18,
13,
2,
13,
17,
13,
17,
4,
13,
2,
13,
17,
13,
14,
2,
2,
2,
13,
17,
13,
2,
18,
18,
13,
13,
2,
13,
17,
17,
4,
13,
13,
2,
13,
17,
23,
13,
23,
13,
0,
13,
17,
14,
2,
18,
18,
13,
17,
17,
17,
4,
13,
17,
4,
13,
4,
13,
17,
17,
14,
2,
13,
13,
4,
13,
17,
4,
13,
17,
10,
17,
13,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
12,
13,
10,
17,
13
] |
[
[
148,
2
],
[
151,
5
],
[
151,
14
],
[
18,
17
],
[
146,
20
],
[
139,
25
],
[
157,
28
],
[
32,
31
],
[
146,
34
],
[
37,
36
],
[
152,
39
],
[
140,
44
],
[
31,
45
],
[
36,
46
],
[
142,
49
],
[
56,
55
],
[
102,
61
],
[
146,
63
],
[
140,
67
],
[
102,
69
],
[
104,
71
],
[
102,
76
],
[
104,
78
],
[
104,
83
],
[
152,
85
],
[
140,
89
],
[
102,
90
],
[
104,
92
],
[
102,
97
],
[
104,
99
],
[
102,
102
],
[
104,
104
],
[
136,
106
],
[
140,
112
],
[
155,
122
],
[
143,
127
],
[
158,
127
],
[
137,
128
],
[
149,
128
],
[
136,
137
],
[
139,
140
],
[
142,
143
],
[
151,
146
],
[
148,
149
],
[
151,
152
],
[
157,
158
]
] |
[
"\ncnt = 0\nH, W = map(int, input().split())\nA = [input() for _ in range(H)]\n\ndef_cnt = 0\nfor h in range(H):\n for w in range(W):\n if A[h][w] == '#':\n def_cnt += 1\n\ndef dfs(h, w):\n global cnt\n cnt += 1\n if h+1 < H and A[h+1][w] == '#':\n dfs(h+1, w)\n elif w+1 < W and A[h][w+1] == '#':\n dfs(h, w+1)\n\ncnt = 0\n\nif A[0][0] == '.':\n print('Impossible')\n exit()\n\ndfs(0, 0)\nif def_cnt == cnt:\n print('Possible')\nelse:\n print('Impossible')",
"cnt = 0",
"cnt",
"0",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"input() for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"input()",
"input",
"A = [input() for _ in range(H)]",
"A",
"[input() for _ in range(H)]",
"def_cnt = 0",
"def_cnt",
"0",
"for h in range(H):\n for w in range(W):\n if A[h][w] == '#':\n def_cnt += 1",
"h",
"range(H)",
"range",
"H",
"for w in range(W):\n if A[h][w] == '#':\n def_cnt += 1",
"w",
"range(W)",
"range",
"W",
"if A[h][w] == '#':\n def_cnt += 1",
"A[h][w] == '#'",
"A[h][w]",
"[h]",
"A",
"h",
"w",
"'#'",
"def_cnt += 1",
"def_cnt",
"1",
"def dfs(h, w):\n global cnt\n cnt += 1\n if h+1 < H and A[h+1][w] == '#':\n dfs(h+1, w)\n elif w+1 < W and A[h][w+1] == '#':\n dfs(h, w+1)",
"dfs",
"global cnt",
"cnt += 1",
"cnt",
"1",
"if h+1 < H and A[h+1][w] == '#':\n dfs(h+1, w)\n elif w+1 < W and A[h][w+1] == '#':\n dfs(h, w+1)",
"h+1 < H and A[h+1][w] == '#'",
"h+1 < H",
"h+1",
"h",
"1",
"H",
"A[h+1][w] == '#'",
"A[h+1][w]",
"[h+1]",
"A",
"h+1",
"h",
"1",
"w",
"'#'",
"dfs(h+1, w)",
"dfs",
"h+1",
"h",
"1",
"w",
"elif w+1 < W and A[h][w+1] == '#':\n dfs(h, w+1)",
"w+1 < W and A[h][w+1] == '#'",
"w+1 < W",
"w+1",
"w",
"1",
"W",
"A[h][w+1] == '#'",
"A[h][w+1]",
"[h]",
"A",
"h",
"w+1",
"w",
"1",
"'#'",
"dfs(h, w+1)",
"dfs",
"h",
"w+1",
"w",
"1",
"h",
"h",
"w",
"w",
"cnt = 0",
"cnt",
"0",
"if A[0][0] == '.':\n print('Impossible')\n exit()",
"A[0][0] == '.'",
"A[0][0]",
"[0]",
"A",
"0",
"0",
"'.'",
"print('Impossible')",
"print",
"'Impossible'",
"exit()",
"exit",
"dfs(0, 0)",
"dfs",
"0",
"0",
"if def_cnt == cnt:\n print('Possible')\nelse:\n print('Impossible')",
"def_cnt == cnt",
"def_cnt",
"cnt",
"print('Possible')",
"print",
"'Possible'",
"print('Impossible')",
"print",
"'Impossible'",
"cnt = 0",
"0",
"cnt",
"A = [input() for _ in range(H)]",
"[input() for _ in range(H)]",
"A",
"def_cnt += 1",
"1",
"def_cnt",
"H, W = map(int, input().split())",
"map(int, input().split())",
"H",
"cnt = 0",
"0",
"cnt",
"W = map(int, input().split())",
"map(int, input().split())",
"W",
"def dfs(h, w):\n global cnt\n cnt += 1\n if h+1 < H and A[h+1][w] == '#':\n dfs(h+1, w)\n elif w+1 < W and A[h][w+1] == '#':\n dfs(h, w+1)",
"def dfs(h, w):\n global cnt\n cnt += 1\n if h+1 < H and A[h+1][w] == '#':\n dfs(h+1, w)\n elif w+1 < W and A[h][w+1] == '#':\n dfs(h, w+1)",
"dfs",
"def_cnt = 0",
"0",
"def_cnt"
] |
cnt = 0
H, W = map(int, input().split())
A = [input() for _ in range(H)]
def_cnt = 0
for h in range(H):
for w in range(W):
if A[h][w] == '#':
def_cnt += 1
def dfs(h, w):
global cnt
cnt += 1
if h+1 < H and A[h+1][w] == '#':
dfs(h+1, w)
elif w+1 < W and A[h][w+1] == '#':
dfs(h, w+1)
cnt = 0
if A[0][0] == '.':
print('Impossible')
exit()
dfs(0, 0)
if def_cnt == cnt:
print('Possible')
else:
print('Impossible')
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
39,
17,
17,
0,
18,
18,
13,
17,
17,
17,
42,
17,
14,
2,
2,
18,
13,
17,
2,
13,
17,
2,
18,
13,
17,
2,
13,
17,
14,
2,
2,
18,
13,
17,
2,
13,
17,
2,
18,
18,
13,
2,
18,
13,
17,
17,
18,
13,
17,
17,
0,
18,
18,
13,
2,
18,
13,
17,
17,
18,
13,
17,
17,
0,
13,
39,
2,
18,
13,
17,
17,
18,
13,
17,
14,
2,
2,
18,
13,
17,
2,
13,
17,
2,
18,
18,
13,
18,
13,
17,
2,
18,
13,
17,
17,
17,
0,
18,
18,
13,
18,
13,
17,
2,
18,
13,
17,
17,
17,
0,
13,
39,
18,
13,
17,
2,
18,
13,
17,
17,
14,
2,
2,
2,
18,
13,
17,
2,
13,
17,
2,
18,
18,
13,
2,
18,
13,
17,
17,
18,
13,
17,
17,
2,
2,
18,
13,
17,
2,
13,
17,
2,
18,
18,
13,
18,
13,
17,
2,
18,
13,
17,
17,
17,
3,
14,
2,
2,
2,
2,
18,
13,
17,
2,
13,
17,
2,
18,
13,
17,
2,
13,
17,
2,
18,
18,
13,
18,
13,
17,
2,
18,
13,
17,
17,
17,
2,
2,
2,
18,
13,
17,
2,
13,
17,
2,
18,
13,
17,
2,
13,
17,
2,
18,
18,
13,
2,
18,
13,
17,
17,
18,
13,
17,
17,
3,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
3,
14,
2,
13,
17,
14,
2,
13,
17,
4,
13,
17,
4,
13,
17,
10,
13,
13,
10,
4,
13,
10,
17,
13,
10,
39,
13,
10,
17,
13,
10,
4,
13,
10,
39,
13,
10,
39,
13
] |
[
[
312,
2
],
[
312,
11
],
[
15,
14
],
[
301,
17
],
[
297,
27
],
[
315,
30
],
[
40,
35
],
[
298,
37
],
[
316,
47
],
[
319,
47
],
[
307,
47
],
[
301,
50
],
[
316,
54
],
[
319,
54
],
[
307,
54
],
[
313,
57
],
[
316,
63
],
[
319,
63
],
[
307,
63
],
[
301,
66
],
[
298,
71
],
[
316,
74
],
[
319,
74
],
[
307,
74
],
[
316,
78
],
[
319,
78
],
[
307,
78
],
[
93,
82
],
[
298,
84
],
[
316,
87
],
[
319,
87
],
[
307,
87
],
[
316,
91
],
[
319,
91
],
[
307,
91
],
[
306,
95
],
[
316,
99
],
[
319,
99
],
[
307,
99
],
[
316,
103
],
[
319,
103
],
[
307,
103
],
[
316,
109
],
[
319,
109
],
[
307,
109
],
[
313,
112
],
[
298,
117
],
[
316,
119
],
[
319,
119
],
[
307,
119
],
[
316,
123
],
[
319,
123
],
[
307,
123
],
[
139,
128
],
[
298,
130
],
[
316,
132
],
[
319,
132
],
[
307,
132
],
[
316,
136
],
[
319,
136
],
[
307,
136
],
[
318,
141
],
[
316,
144
],
[
319,
144
],
[
307,
144
],
[
316,
148
],
[
319,
148
],
[
307,
148
],
[
316,
156
],
[
319,
156
],
[
307,
156
],
[
301,
159
],
[
298,
164
],
[
316,
167
],
[
319,
167
],
[
307,
167
],
[
316,
171
],
[
319,
171
],
[
307,
171
],
[
316,
177
],
[
319,
177
],
[
307,
177
],
[
313,
180
],
[
298,
185
],
[
316,
187
],
[
319,
187
],
[
307,
187
],
[
316,
191
],
[
319,
191
],
[
307,
191
],
[
316,
202
],
[
319,
202
],
[
307,
202
],
[
301,
205
],
[
316,
209
],
[
319,
209
],
[
307,
209
],
[
313,
212
],
[
298,
217
],
[
316,
219
],
[
319,
219
],
[
307,
219
],
[
316,
223
],
[
319,
223
],
[
307,
223
],
[
316,
231
],
[
319,
231
],
[
307,
231
],
[
313,
234
],
[
316,
238
],
[
319,
238
],
[
307,
238
],
[
301,
241
],
[
298,
246
],
[
316,
249
],
[
319,
249
],
[
307,
249
],
[
316,
253
],
[
319,
253
],
[
307,
253
],
[
303,
258
],
[
262,
261
],
[
301,
264
],
[
267,
266
],
[
313,
269
],
[
298,
274
],
[
261,
275
],
[
266,
276
],
[
309,
279
],
[
310,
284
],
[
304,
284
],
[
310,
288
],
[
304,
288
],
[
297,
298
],
[
312,
301
],
[
303,
304
],
[
306,
307
],
[
309,
310
],
[
312,
313
],
[
315,
316
],
[
318,
319
]
] |
[
"H,W = map(int,input().split())\nA = [list(input().strip()) for _ in range(H)]\nx = [0,0]\nA[0][0] = \".\"\nwhile True:\n if x[0]==H-1 and x[1]==W-1:break\n if x[0]<H-1 and A[x[0]+1][x[1]]==\"#\":\n A[x[0]+1][x[1]]=\".\"\n x = [x[0]+1,x[1]]\n elif x[1]<W-1 and A[x[0]][x[1]+1]==\"#\":\n A[x[0]][x[1]+1]=\".\"\n x = [x[0],x[1]+1]\n elif (x[0]<H-1 and A[x[0]+1][x[1]]==\".\") and (x[1]<W-1 and A[x[0]][x[1]+1]==\".\"):\n break\n elif (x[0]==H-1 and x[1]<W-1 and A[x[0]][x[1]+1]==\".\") or (x[1]==W-1 and x[0]<H-1 and A[x[0]+1][x[1]]==\".\"):\n break\nflag = 0\nfor i in range(H):\n for j in range(W):\n if A[i][j]==\"#\":\n flag = 1\n break\n if flag==1:break\nif flag==0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"H,W = map(int,input().split())",
"H",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"list(input().strip()) for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"list(input().strip())",
"list",
"input().strip()",
"().strip",
"()",
"input",
"strip",
"A = [list(input().strip()) for _ in range(H)]",
"A",
"[list(input().strip()) for _ in range(H)]",
"x = [0,0]",
"x",
"[0,0]",
"0",
"0",
"A[0][0] = \".\"",
"A[0][0]",
"[0]",
"A",
"0",
"0",
"\".\"",
"while True:\n if x[0]==H-1 and x[1]==W-1:break\n if x[0]<H-1 and A[x[0]+1][x[1]]==\"#\":\n A[x[0]+1][x[1]]=\".\"\n x = [x[0]+1,x[1]]\n elif x[1]<W-1 and A[x[0]][x[1]+1]==\"#\":\n A[x[0]][x[1]+1]=\".\"\n x = [x[0],x[1]+1]\n elif (x[0]<H-1 and A[x[0]+1][x[1]]==\".\") and (x[1]<W-1 and A[x[0]][x[1]+1]==\".\"):\n break\n elif (x[0]==H-1 and x[1]<W-1 and A[x[0]][x[1]+1]==\".\") or (x[1]==W-1 and x[0]<H-1 and A[x[0]+1][x[1]]==\".\"):\n break",
"True",
"if x[0]==H-1 and x[1]==W-1:break\n ",
"x[0]==H-1 and x[1]==W-1",
"x[0]==H-1",
"x[0]",
"x",
"0",
"H-1",
"H",
"1",
"x[1]==W-1",
"x[1]",
"x",
"1",
"W-1",
"W",
"1",
"if x[0]<H-1 and A[x[0]+1][x[1]]==\"#\":\n A[x[0]+1][x[1]]=\".\"\n x = [x[0]+1,x[1]]\n elif x[1]<W-1 and A[x[0]][x[1]+1]==\"#\":\n A[x[0]][x[1]+1]=\".\"\n x = [x[0],x[1]+1]\n elif (x[0]<H-1 and A[x[0]+1][x[1]]==\".\") and (x[1]<W-1 and A[x[0]][x[1]+1]==\".\"):\n break\n elif (x[0]==H-1 and x[1]<W-1 and A[x[0]][x[1]+1]==\".\") or (x[1]==W-1 and x[0]<H-1 and A[x[0]+1][x[1]]==\".\"):\n break",
"x[0]<H-1 and A[x[0]+1][x[1]]==\"#\"",
"x[0]<H-1",
"x[0]",
"x",
"0",
"H-1",
"H",
"1",
"A[x[0]+1][x[1]]==\"#\"",
"A[x[0]+1][x[1]]",
"[x[0]+1]",
"A",
"x[0]+1",
"x[0]",
"x",
"0",
"1",
"x[1]",
"x",
"1",
"\"#\"",
"A[x[0]+1][x[1]]=\".\"",
"A[x[0]+1][x[1]]",
"[x[0]+1]",
"A",
"x[0]+1",
"x[0]",
"x",
"0",
"1",
"x[1]",
"x",
"1",
"\".\"",
"x = [x[0]+1,x[1]]",
"x",
"[x[0]+1,x[1]]",
"x[0]+1",
"x[0]",
"x",
"0",
"1",
"x[1]",
"x",
"1",
"elif x[1]<W-1 and A[x[0]][x[1]+1]==\"#\":\n A[x[0]][x[1]+1]=\".\"\n x = [x[0],x[1]+1]\n ",
"x[1]<W-1 and A[x[0]][x[1]+1]==\"#\"",
"x[1]<W-1",
"x[1]",
"x",
"1",
"W-1",
"W",
"1",
"A[x[0]][x[1]+1]==\"#\"",
"A[x[0]][x[1]+1]",
"[x[0]]",
"A",
"x[0]",
"x",
"0",
"x[1]+1",
"x[1]",
"x",
"1",
"1",
"\"#\"",
"A[x[0]][x[1]+1]=\".\"",
"A[x[0]][x[1]+1]",
"[x[0]]",
"A",
"x[0]",
"x",
"0",
"x[1]+1",
"x[1]",
"x",
"1",
"1",
"\".\"",
"x = [x[0],x[1]+1]",
"x",
"[x[0],x[1]+1]",
"x[0]",
"x",
"0",
"x[1]+1",
"x[1]",
"x",
"1",
"1",
"elif (x[0]<H-1 and A[x[0]+1][x[1]]==\".\") and (x[1]<W-1 and A[x[0]][x[1]+1]==\".\"):\n break\n ",
"(x[0]<H-1 and A[x[0]+1][x[1]]==\".\") and (x[1]<W-1 and A[x[0]][x[1]+1]==\".\")",
"x[0]<H-1 and A[x[0]+1][x[1]]==\".\"",
"x[0]<H-1",
"x[0]",
"x",
"0",
"H-1",
"H",
"1",
"A[x[0]+1][x[1]]==\".\"",
"A[x[0]+1][x[1]]",
"[x[0]+1]",
"A",
"x[0]+1",
"x[0]",
"x",
"0",
"1",
"x[1]",
"x",
"1",
"\".\"",
"x[1]<W-1 and A[x[0]][x[1]+1]==\".\"",
"x[1]<W-1",
"x[1]",
"x",
"1",
"W-1",
"W",
"1",
"A[x[0]][x[1]+1]==\".\"",
"A[x[0]][x[1]+1]",
"[x[0]]",
"A",
"x[0]",
"x",
"0",
"x[1]+1",
"x[1]",
"x",
"1",
"1",
"\".\"",
"break",
"elif (x[0]==H-1 and x[1]<W-1 and A[x[0]][x[1]+1]==\".\") or (x[1]==W-1 and x[0]<H-1 and A[x[0]+1][x[1]]==\".\"):\n break",
"(x[0]==H-1 and x[1]<W-1 and A[x[0]][x[1]+1]==\".\") or (x[1]==W-1 and x[0]<H-1 and A[x[0]+1][x[1]]==\".\")",
"x[0]==H-1 and x[1]<W-1 and A[x[0]][x[1]+1]==\".\"",
"x[0]==H-1 and x[1]<W-1",
"x[0]==H-1",
"x[0]",
"x",
"0",
"H-1",
"H",
"1",
"x[1]<W-1",
"x[1]",
"x",
"1",
"W-1",
"W",
"1",
"A[x[0]][x[1]+1]==\".\"",
"A[x[0]][x[1]+1]",
"[x[0]]",
"A",
"x[0]",
"x",
"0",
"x[1]+1",
"x[1]",
"x",
"1",
"1",
"\".\"",
"x[1]==W-1 and x[0]<H-1 and A[x[0]+1][x[1]]==\".\"",
"x[1]==W-1 and x[0]<H-1",
"x[1]==W-1",
"x[1]",
"x",
"1",
"W-1",
"W",
"1",
"x[0]<H-1",
"x[0]",
"x",
"0",
"H-1",
"H",
"1",
"A[x[0]+1][x[1]]==\".\"",
"A[x[0]+1][x[1]]",
"[x[0]+1]",
"A",
"x[0]+1",
"x[0]",
"x",
"0",
"1",
"x[1]",
"x",
"1",
"\".\"",
"break",
"flag = 0",
"flag",
"0",
"for i in range(H):\n for j in range(W):\n if A[i][j]==\"#\":\n flag = 1\n break\n if flag==1:break",
"i",
"range(H)",
"range",
"H",
"for j in range(W):\n if A[i][j]==\"#\":\n flag = 1\n break\n ",
"j",
"range(W)",
"range",
"W",
"if A[i][j]==\"#\":\n flag = 1\n break\n ",
"A[i][j]==\"#\"",
"A[i][j]",
"[i]",
"A",
"i",
"j",
"\"#\"",
"flag = 1",
"flag",
"1",
"break",
"if flag==1:b",
"flag==1",
"flag",
"1",
"if flag==0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"flag==0",
"flag",
"0",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"A = [list(input().strip()) for _ in range(H)]",
"[list(input().strip()) for _ in range(H)]",
"A",
"H,W = map(int,input().split())",
"map(int,input().split())",
"H",
"flag = 0",
"0",
"flag",
"x = [x[0]+1,x[1]]",
"[x[0]+1,x[1]]",
"x",
"flag = 1",
"1",
"flag",
"W = map(int,input().split())",
"map(int,input().split())",
"W",
"x = [0,0]",
"[0,0]",
"x",
"x = [x[0],x[1]+1]",
"[x[0],x[1]+1]",
"x"
] |
H,W = map(int,input().split())
A = [list(input().strip()) for _ in range(H)]
x = [0,0]
A[0][0] = "."
while True:
if x[0]==H-1 and x[1]==W-1:break
if x[0]<H-1 and A[x[0]+1][x[1]]=="#":
A[x[0]+1][x[1]]="."
x = [x[0]+1,x[1]]
elif x[1]<W-1 and A[x[0]][x[1]+1]=="#":
A[x[0]][x[1]+1]="."
x = [x[0],x[1]+1]
elif (x[0]<H-1 and A[x[0]+1][x[1]]==".") and (x[1]<W-1 and A[x[0]][x[1]+1]=="."):
break
elif (x[0]==H-1 and x[1]<W-1 and A[x[0]][x[1]+1]==".") or (x[1]==W-1 and x[0]<H-1 and A[x[0]+1][x[1]]=="."):
break
flag = 0
for i in range(H):
for j in range(W):
if A[i][j]=="#":
flag = 1
break
if flag==1:break
if flag==0:
print("Possible")
else:
print("Impossible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
0,
13,
39,
17,
17,
0,
13,
17,
0,
13,
17,
42,
40,
13,
39,
2,
13,
17,
2,
13,
17,
0,
13,
13,
13,
14,
2,
2,
13,
2,
13,
17,
2,
18,
18,
13,
13,
2,
13,
17,
17,
0,
13,
17,
0,
13,
39,
2,
13,
17,
13,
14,
2,
2,
13,
2,
13,
17,
2,
18,
18,
13,
2,
13,
17,
13,
17,
0,
13,
17,
0,
13,
39,
13,
2,
13,
17,
14,
2,
2,
13,
17,
2,
18,
18,
13,
13,
2,
13,
17,
17,
0,
13,
17,
14,
2,
2,
13,
17,
2,
18,
18,
13,
2,
13,
17,
13,
17,
0,
13,
17,
14,
2,
40,
13,
17,
40,
13,
17,
4,
13,
17,
3,
0,
13,
17,
0,
13,
17,
0,
13,
17,
28,
13,
13,
0,
13,
4,
18,
13,
13,
17,
14,
40,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
39,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
39,
13,
10,
39,
13,
10,
39,
13,
10,
13,
13
] |
[
[
195,
2
],
[
195,
11
],
[
225,
13
],
[
17,
16
],
[
196,
19
],
[
226,
22
],
[
231,
27
],
[
198,
32
],
[
204,
35
],
[
232,
39
],
[
184,
39
],
[
229,
39
],
[
193,
42
],
[
196,
45
],
[
234,
48
],
[
232,
49
],
[
184,
49
],
[
229,
49
],
[
234,
50
],
[
235,
54
],
[
193,
56
],
[
226,
61
],
[
202,
62
],
[
235,
64
],
[
189,
68
],
[
228,
71
],
[
235,
74
],
[
202,
80
],
[
196,
82
],
[
226,
87
],
[
202,
89
],
[
235,
91
],
[
219,
94
],
[
183,
97
],
[
202,
101
],
[
235,
106
],
[
226,
111
],
[
202,
112
],
[
235,
114
],
[
186,
118
],
[
202,
123
],
[
226,
128
],
[
202,
130
],
[
235,
132
],
[
213,
135
],
[
220,
140
],
[
190,
140
],
[
205,
140
],
[
211,
140
],
[
214,
143
],
[
187,
143
],
[
199,
143
],
[
223,
143
],
[
222,
150
],
[
210,
153
],
[
207,
156
],
[
160,
159
],
[
226,
159
],
[
216,
162
],
[
159,
165
],
[
217,
170
],
[
208,
170
],
[
196,
173
],
[
193,
174
],
[
183,
184
],
[
186,
187
],
[
189,
190
],
[
195,
193
],
[
195,
196
],
[
198,
199
],
[
232,
201
],
[
184,
201
],
[
229,
201
],
[
234,
202
],
[
204,
205
],
[
207,
208
],
[
210,
211
],
[
213,
214
],
[
216,
217
],
[
219,
220
],
[
222,
223
],
[
225,
226
],
[
228,
229
],
[
231,
232
],
[
232,
234
],
[
184,
234
],
[
229,
234
],
[
234,
235
]
] |
[
"h, w = map(int, input().split())\na = []\nfor _ in range(h):\n a.append(input())\n\npos = (0, 0)\npre = 1\nnxt = 0\nwhile pos!=(w-1, h-1):\n x, y = pos\n if x<w-1 and a[y][x+1]=='#':\n nxt += 1\n pos = (x+1, y)\n if y<h-1 and a[y+1][x]=='#':\n nxt += 1\n pos = (x, y+1)\n if x>0 and a[y][x-1]=='#':\n pre += 1\n if y>0 and a[y-1][x]=='#':\n pre += 1\n if nxt!=1 or pre!=1:\n print('Impossible')\n break\n pre = 0\n nxt = 0\nelse:\n tmp = 0\n for i in a:\n tmp += i.count('#')\n if tmp!=h+w-1:\n print('Impossible')\n else:\n print('Possible')",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"a = []",
"a",
"[]",
"for _ in range(h):\n a.append(input())",
"_",
"range(h)",
"range",
"h",
"a.append(input())",
"a.append",
"a",
"append",
"input()",
"input",
"pos = (0, 0)",
"pos",
"(0, 0)",
"0",
"0",
"pre = 1",
"pre",
"1",
"nxt = 0",
"nxt",
"0",
"while pos!=(w-1, h-1):\n x, y = pos\n if x<w-1 and a[y][x+1]=='#':\n nxt += 1\n pos = (x+1, y)\n if y<h-1 and a[y+1][x]=='#':\n nxt += 1\n pos = (x, y+1)\n if x>0 and a[y][x-1]=='#':\n pre += 1\n if y>0 and a[y-1][x]=='#':\n pre += 1\n if nxt!=1 or pre!=1:\n print('Impossible')\n break\n pre = 0\n nxt = 0\nelse:\n tmp = 0\n for i in a:\n tmp += i.count('#')\n if tmp!=h+w-1:\n print('Impossible')\n else:\n print('Possible')",
"pos!=(w-1, h-1)",
"pos",
"(w-1, h-1)",
"w-1",
"w",
"1",
"h-1",
"h",
"1",
"x, y = pos",
"x",
"pos",
"y",
"if x<w-1 and a[y][x+1]=='#':\n nxt += 1\n pos = (x+1, y)\n ",
"x<w-1 and a[y][x+1]=='#'",
"x<w-1",
"x",
"w-1",
"w",
"1",
"a[y][x+1]=='#'",
"a[y][x+1]",
"[y]",
"a",
"y",
"x+1",
"x",
"1",
"'#'",
"nxt += 1",
"nxt",
"1",
"pos = (x+1, y)",
"pos",
"(x+1, y)",
"x+1",
"x",
"1",
"y",
"if y<h-1 and a[y+1][x]=='#':\n nxt += 1\n pos = (x, y+1)\n ",
"y<h-1 and a[y+1][x]=='#'",
"y<h-1",
"y",
"h-1",
"h",
"1",
"a[y+1][x]=='#'",
"a[y+1][x]",
"[y+1]",
"a",
"y+1",
"y",
"1",
"x",
"'#'",
"nxt += 1",
"nxt",
"1",
"pos = (x, y+1)",
"pos",
"(x, y+1)",
"x",
"y+1",
"y",
"1",
"if x>0 and a[y][x-1]=='#':\n pre += 1\n ",
"x>0 and a[y][x-1]=='#'",
"x>0",
"x",
"0",
"a[y][x-1]=='#'",
"a[y][x-1]",
"[y]",
"a",
"y",
"x-1",
"x",
"1",
"'#'",
"pre += 1",
"pre",
"1",
"if y>0 and a[y-1][x]=='#':\n pre += 1\n ",
"y>0 and a[y-1][x]=='#'",
"y>0",
"y",
"0",
"a[y-1][x]=='#'",
"a[y-1][x]",
"[y-1]",
"a",
"y-1",
"y",
"1",
"x",
"'#'",
"pre += 1",
"pre",
"1",
"if nxt!=1 or pre!=1:\n print('Impossible')\n break\n ",
"nxt!=1 or pre!=1",
"nxt!=1",
"nxt",
"1",
"pre!=1",
"pre",
"1",
"print('Impossible')",
"print",
"'Impossible'",
"break",
"pre = 0",
"pre",
"0",
"nxt = 0",
"nxt",
"0",
"tmp = 0",
"tmp",
"0",
"for i in a:\n tmp += i.count('#')\n ",
"i",
"a",
"tmp += i.count('#')",
"tmp",
"i.count('#')",
"i.count",
"i",
"count",
"'#'",
"if tmp!=h+w-1:\n print('Impossible')\n else:\n print('Possible')",
"tmp!=h+w-1",
"tmp",
"h+w-1",
"h+w",
"h",
"w",
"1",
"print('Impossible')",
"print",
"'Impossible'",
"print('Possible')",
"print",
"'Possible'",
"pos = (x, y+1)",
"(x, y+1)",
"pos",
"pre += 1",
"1",
"pre",
"nxt += 1",
"1",
"nxt",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h",
"pre = 1",
"1",
"pre",
"y = pos",
"pos",
"y",
"nxt = 0",
"0",
"nxt",
"tmp = 0",
"0",
"tmp",
"nxt = 0",
"0",
"nxt",
"pre += 1",
"1",
"pre",
"tmp += i.count('#')",
"i.count('#')",
"tmp",
"nxt += 1",
"1",
"nxt",
"pre = 0",
"0",
"pre",
"a = []",
"[]",
"a",
"pos = (x+1, y)",
"(x+1, y)",
"pos",
"pos = (0, 0)",
"(0, 0)",
"pos",
"x, y = pos",
"pos",
"x"
] |
h, w = map(int, input().split())
a = []
for _ in range(h):
a.append(input())
pos = (0, 0)
pre = 1
nxt = 0
while pos!=(w-1, h-1):
x, y = pos
if x<w-1 and a[y][x+1]=='#':
nxt += 1
pos = (x+1, y)
if y<h-1 and a[y+1][x]=='#':
nxt += 1
pos = (x, y+1)
if x>0 and a[y][x-1]=='#':
pre += 1
if y>0 and a[y-1][x]=='#':
pre += 1
if nxt!=1 or pre!=1:
print('Impossible')
break
pre = 0
nxt = 0
else:
tmp = 0
for i in a:
tmp += i.count('#')
if tmp!=h+w-1:
print('Impossible')
else:
print('Possible')
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
0,
13,
4,
18,
13,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13
] |
[
[
55,
2
],
[
55,
11
],
[
52,
13
],
[
17,
16
],
[
50,
19
],
[
46,
21
],
[
58,
25
],
[
47,
28
],
[
53,
29
],
[
59,
29
],
[
59,
33
],
[
53,
33
],
[
50,
36
],
[
56,
37
],
[
46,
47
],
[
55,
50
],
[
52,
53
],
[
55,
56
],
[
58,
59
]
] |
[
"H, W = map(int, input().split())\ncount = 0\nfor _ in range(H):\n a = input()\n count += a.count('#')\n \nif count == H + W - 1:\n print('Possible')\nelse:\n print('Impossible')",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"count = 0",
"count",
"0",
"for _ in range(H):\n a = input()\n count += a.count('#')\n ",
"_",
"range(H)",
"range",
"H",
"a = input()",
"a",
"input()",
"input",
"count += a.count('#')",
"count",
"a.count('#')",
"a.count",
"a",
"count",
"'#'",
"if count == H + W - 1:\n print('Possible')\nelse:\n print('Impossible')",
"count == H + W - 1",
"count",
"H + W - 1",
"H + W",
"H",
"W",
"1",
"print('Possible')",
"print",
"'Possible'",
"print('Impossible')",
"print",
"'Impossible'",
"a = input()",
"input()",
"a",
"H, W = map(int, input().split())",
"map(int, input().split())",
"H",
"count = 0",
"0",
"count",
"W = map(int, input().split())",
"map(int, input().split())",
"W",
"count += a.count('#')",
"a.count('#')",
"count"
] |
H, W = map(int, input().split())
count = 0
for _ in range(H):
a = input()
count += a.count('#')
if count == H + W - 1:
print('Possible')
else:
print('Impossible')
|
[
7,
15,
12,
13,
0,
13,
4,
13,
4,
18,
13,
13,
13,
0,
18,
18,
13,
18,
13,
17,
18,
13,
17,
17,
42,
13,
0,
13,
4,
18,
13,
13,
13,
28,
13,
4,
13,
17,
0,
13,
2,
13,
18,
13,
13,
0,
13,
2,
13,
18,
13,
13,
14,
40,
2,
2,
40,
17,
13,
13,
2,
40,
17,
13,
13,
9,
14,
2,
18,
18,
13,
13,
13,
17,
9,
14,
40,
18,
18,
13,
13,
13,
17,
9,
4,
18,
13,
13,
39,
13,
13,
0,
18,
18,
13,
13,
13,
2,
18,
18,
13,
13,
13,
17,
23,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
39,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
18,
13,
13,
4,
13,
4,
13,
0,
13,
4,
18,
18,
13,
13,
13,
17,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
0,
13,
39,
17,
17,
0,
13,
39,
17,
17,
4,
13,
39,
17,
17,
14,
2,
2,
18,
18,
13,
2,
13,
17,
2,
13,
17,
17,
13,
4,
13,
17,
4,
13,
17,
10,
17,
13,
10,
39,
13,
10,
39,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
12,
13,
10,
13,
13,
10,
4,
13
] |
[
[
6,
5
],
[
5,
10
],
[
105,
12
],
[
23,
14
],
[
105,
18
],
[
105,
21
],
[
28,
27
],
[
5,
30
],
[
28,
32
],
[
35,
34
],
[
40,
39
],
[
27,
41
],
[
34,
44
],
[
47,
46
],
[
32,
48
],
[
34,
51
],
[
39,
58
],
[
46,
63
],
[
46,
71
],
[
39,
72
],
[
92,
77
],
[
46,
80
],
[
39,
81
],
[
5,
86
],
[
97,
92
],
[
46,
95
],
[
39,
96
],
[
32,
101
],
[
27,
102
],
[
105,
105
],
[
224,
107
],
[
224,
116
],
[
120,
119
],
[
210,
122
],
[
215,
126
],
[
200,
129
],
[
133,
132
],
[
210,
135
],
[
140,
137
],
[
216,
138
],
[
132,
139
],
[
212,
145
],
[
137,
148
],
[
216,
149
],
[
132,
150
],
[
156,
155
],
[
210,
158
],
[
221,
162
],
[
203,
165
],
[
206,
170
],
[
219,
175
],
[
222,
184
],
[
210,
186
],
[
225,
189
],
[
213,
192
],
[
201,
192
],
[
200,
201
],
[
203,
204
],
[
206,
207
],
[
224,
210
],
[
212,
213
],
[
215,
216
],
[
221,
222
],
[
224,
225
]
] |
[
"from collections import deque\n\n\ndef bfs(start):\n Q = deque()\n Q.append(start)\n dist[start[1]][start[0]] = 0\n\n while Q:\n x, y = Q.popleft()\n\n for i in range(2):\n nx = x + dx[i]\n ny = y + dy[i]\n\n if not(0 <= nx < W and 0 <= ny < H):\n continue\n if G[ny][nx] == '.':\n continue\n if dist[ny][nx] != -1:\n continue\n\n Q.append((nx, ny))\n dist[ny][nx] = dist[y][x] + 1\n\n\nH, W = map(int, input().split())\nG = [[] for _ in range(H)]\n\nn = 0\nfor i in range(H):\n G[i] = list(input())\n n += G[i].count('#')\n\ndist = [[-1 for _ in range(W)] for _ in range(H)]\ndx = [1, 0] # 斜めも含むならその方向もプラス\ndy = [0, 1]\n\nbfs((0, 0))\n\nif dist[H - 1][W - 1] + 1 == n:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"from collections import deque",
"def bfs(start):\n Q = deque()\n Q.append(start)\n dist[start[1]][start[0]] = 0\n\n while Q:\n x, y = Q.popleft()\n\n for i in range(2):\n nx = x + dx[i]\n ny = y + dy[i]\n\n if not(0 <= nx < W and 0 <= ny < H):\n continue\n if G[ny][nx] == '.':\n continue\n if dist[ny][nx] != -1:\n continue\n\n Q.append((nx, ny))\n dist[ny][nx] = dist[y][x] + 1",
"bfs",
"Q = deque()",
"Q",
"deque()",
"deque",
"Q.append(start)",
"Q.append",
"Q",
"append",
"start",
"dist[start[1]][start[0]] = 0",
"dist[start[1]][start[0]]",
"[start[1]]",
"dist",
"start[1]",
"start",
"1",
"start[0]",
"start",
"0",
"0",
"while Q:\n x, y = Q.popleft()\n\n for i in range(2):\n nx = x + dx[i]\n ny = y + dy[i]\n\n if not(0 <= nx < W and 0 <= ny < H):\n continue\n if G[ny][nx] == '.':\n continue\n if dist[ny][nx] != -1:\n continue\n\n Q.append((nx, ny))\n dist[ny][nx] = dist[y][x] + 1",
"Q",
"x, y = Q.popleft()",
"x",
"Q.popleft()",
"Q.popleft",
"Q",
"popleft",
"y",
"for i in range(2):\n nx = x + dx[i]\n ny = y + dy[i]\n\n if not(0 <= nx < W and 0 <= ny < H):\n continue\n if G[ny][nx] == '.':\n continue\n if dist[ny][nx] != -1:\n continue\n\n Q.append((nx, ny))\n dist[ny][nx] = dist[y][x] + 1",
"i",
"range(2)",
"range",
"2",
"nx = x + dx[i]",
"nx",
"x + dx[i]",
"x",
"dx[i]",
"dx",
"i",
"ny = y + dy[i]",
"ny",
"y + dy[i]",
"y",
"dy[i]",
"dy",
"i",
"if not(0 <= nx < W and 0 <= ny < H):\n continue\n ",
"not(0 <= nx < W and 0 <= ny < H)",
"0 <= nx < W and 0 <= ny < H",
"0 <= nx < W",
"0 <= nx",
"0",
"nx",
"W",
"0 <= ny < H",
"0 <= ny",
"0",
"ny",
"H",
"continue",
"if G[ny][nx] == '.':\n continue\n ",
"G[ny][nx] == '.'",
"G[ny][nx]",
"[ny]",
"G",
"ny",
"nx",
"'.'",
"continue",
"if dist[ny][nx] != -1:\n continue\n\n ",
"dist[ny][nx] != -1",
"dist[ny][nx]",
"[ny]",
"dist",
"ny",
"nx",
"-1",
"continue",
"Q.append((nx, ny))",
"Q.append",
"Q",
"append",
"(nx, ny)",
"nx",
"ny",
"dist[ny][nx] = dist[y][x] + 1",
"dist[ny][nx]",
"[ny]",
"dist",
"ny",
"nx",
"dist[y][x] + 1",
"dist[y][x]",
"[y]",
"dist",
"y",
"x",
"1",
"start",
"start",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"[] for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"[]",
"G = [[] for _ in range(H)]",
"G",
"[[] for _ in range(H)]",
"n = 0",
"n",
"0",
"for i in range(H):\n G[i] = list(input())\n n += G[i].count('#')",
"i",
"range(H)",
"range",
"H",
"G[i] = list(input())",
"G[i]",
"G",
"i",
"list(input())",
"list",
"input()",
"input",
"n += G[i].count('#')",
"n",
"G[i].count('#')",
"[i].count",
"[i]",
"G",
"i",
"count",
"'#'",
"[-1 for _ in range(W)] for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"[-1 for _ in range(W)]",
"dist = [[-1 for _ in range(W)] for _ in range(H)]",
"dist",
"[[-1 for _ in range(W)] for _ in range(H)]",
"dx = [1, 0]",
"dx",
"[1, 0]",
"1",
"0",
"dy = [0, 1]",
"dy",
"[0, 1]",
"0",
"1",
"bfs((0, 0))",
"bfs",
"(0, 0)",
"0",
"0",
"if dist[H - 1][W - 1] + 1 == n:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"dist[H - 1][W - 1] + 1 == n",
"dist[H - 1][W - 1] + 1",
"dist[H - 1][W - 1]",
"[H - 1]",
"dist",
"H - 1",
"H",
"1",
"W - 1",
"W",
"1",
"1",
"n",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"n = 0",
"0",
"n",
"dx = [1, 0]",
"[1, 0]",
"dx",
"dy = [0, 1]",
"[0, 1]",
"dy",
"H, W = map(int, input().split())",
"map(int, input().split())",
"H",
"n += G[i].count('#')",
"G[i].count('#')",
"n",
"G = [[] for _ in range(H)]",
"[[] for _ in range(H)]",
"G",
"def bfs(start):\n Q = deque()\n Q.append(start)\n dist[start[1]][start[0]] = 0\n\n while Q:\n x, y = Q.popleft()\n\n for i in range(2):\n nx = x + dx[i]\n ny = y + dy[i]\n\n if not(0 <= nx < W and 0 <= ny < H):\n continue\n if G[ny][nx] == '.':\n continue\n if dist[ny][nx] != -1:\n continue\n\n Q.append((nx, ny))\n dist[ny][nx] = dist[y][x] + 1",
"def bfs(start):\n Q = deque()\n Q.append(start)\n dist[start[1]][start[0]] = 0\n\n while Q:\n x, y = Q.popleft()\n\n for i in range(2):\n nx = x + dx[i]\n ny = y + dy[i]\n\n if not(0 <= nx < W and 0 <= ny < H):\n continue\n if G[ny][nx] == '.':\n continue\n if dist[ny][nx] != -1:\n continue\n\n Q.append((nx, ny))\n dist[ny][nx] = dist[y][x] + 1",
"bfs",
"dist = [[-1 for _ in range(W)] for _ in range(H)]",
"[[-1 for _ in range(W)] for _ in range(H)]",
"dist",
"W = map(int, input().split())",
"map(int, input().split())",
"W"
] |
from collections import deque
def bfs(start):
Q = deque()
Q.append(start)
dist[start[1]][start[0]] = 0
while Q:
x, y = Q.popleft()
for i in range(2):
nx = x + dx[i]
ny = y + dy[i]
if not(0 <= nx < W and 0 <= ny < H):
continue
if G[ny][nx] == '.':
continue
if dist[ny][nx] != -1:
continue
Q.append((nx, ny))
dist[ny][nx] = dist[y][x] + 1
H, W = map(int, input().split())
G = [[] for _ in range(H)]
n = 0
for i in range(H):
G[i] = list(input())
n += G[i].count('#')
dist = [[-1 for _ in range(W)] for _ in range(H)]
dx = [1, 0] # 斜めも含むならその方向もプラス
dy = [0, 1]
bfs((0, 0))
if dist[H - 1][W - 1] + 1 == n:
print("Possible")
else:
print("Impossible")
|
[
7,
15,
12,
13,
15,
0,
13,
18,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
2,
13,
17,
0,
13,
13,
0,
13,
4,
13,
39,
28,
13,
4,
13,
17,
2,
13,
17,
0,
18,
13,
13,
2,
2,
17,
4,
18,
4,
13,
13,
17,
17,
4,
18,
13,
13,
39,
17,
17,
42,
2,
4,
13,
13,
17,
0,
13,
4,
18,
13,
13,
13,
14,
2,
2,
2,
2,
18,
18,
13,
2,
13,
17,
13,
17,
2,
18,
18,
13,
13,
2,
13,
17,
17,
2,
18,
18,
13,
2,
13,
17,
2,
13,
17,
17,
2,
18,
18,
13,
2,
13,
17,
2,
13,
17,
17,
4,
13,
17,
4,
13,
14,
2,
18,
18,
13,
2,
13,
17,
13,
17,
4,
18,
13,
13,
39,
2,
13,
17,
13,
14,
2,
18,
18,
13,
13,
2,
13,
17,
17,
4,
18,
13,
13,
39,
13,
2,
13,
17,
4,
13,
17,
4,
13,
10,
12,
13
] |
[
[
7,
6
],
[
12,
11
],
[
6,
18
],
[
12,
20
],
[
24,
23
],
[
11,
27
],
[
20,
34
],
[
38,
37
],
[
41,
40
],
[
46,
45
],
[
11,
50
],
[
56,
53
],
[
37,
54
],
[
45,
55
],
[
6,
62
],
[
40,
68
],
[
40,
77
],
[
81,
80
],
[
40,
83
],
[
81,
85
],
[
37,
93
],
[
80,
95
],
[
85,
97
],
[
37,
102
],
[
80,
103
],
[
85,
105
],
[
37,
111
],
[
80,
113
],
[
85,
116
],
[
37,
122
],
[
80,
124
],
[
85,
127
],
[
37,
139
],
[
80,
141
],
[
85,
143
],
[
40,
147
],
[
80,
151
],
[
37,
158
],
[
80,
159
],
[
85,
161
],
[
40,
166
],
[
85,
171
],
[
180,
177
]
] |
[
"from sys import stdin\n\ndef main():\n from collections import deque\n input = stdin.readline\n\n h, w = map(int, input().split())\n cm = [[\".\"] * (w + 2) for _ in range(h + 2)]\n que = deque([])\n for i in range(1, h + 1):\n cm[i] = \".\" + input().rstrip('\\n') + \".\"\n que.append([1, 1])\n while len(que) > 0:\n y, x = que.popleft()\n if (cm[y + 1][x] == \"#\" and cm[y][x + 1] == \"#\") or cm[y + 1][x - 1] == \"#\" or cm[y - 1][x + 1] == \"#\":\n print('Impossible')\n exit()\n if cm[y + 1][x] == \"#\":\n que.append([y + 1, x])\n if cm[y][x + 1] == \"#\":\n que.append([y, x + 1])\n print('Possible')\nmain()",
"from sys import stdin",
"def main():\n from collections import deque\n input = stdin.readline\n\n h, w = map(int, input().split())\n cm = [[\".\"] * (w + 2) for _ in range(h + 2)]\n que = deque([])\n for i in range(1, h + 1):\n cm[i] = \".\" + input().rstrip('\\n') + \".\"\n que.append([1, 1])\n while len(que) > 0:\n y, x = que.popleft()\n if (cm[y + 1][x] == \"#\" and cm[y][x + 1] == \"#\") or cm[y + 1][x - 1] == \"#\" or cm[y - 1][x + 1] == \"#\":\n print('Impossible')\n exit()\n if cm[y + 1][x] == \"#\":\n que.append([y + 1, x])\n if cm[y][x + 1] == \"#\":\n que.append([y, x + 1])\n print('Possible')",
"main",
"from collections import deque",
"input = stdin.readline",
"input",
"stdin.readline",
"stdin",
"readline",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"[\".\"] * (w + 2) for _ in range(h + 2)",
"for _ in range(h + 2)",
"_",
"range(h + 2)",
"range",
"h + 2",
"h",
"2",
"for _ in range(h + 2)",
"[\".\"] * (w + 2)",
"[\".\"]",
"\".\"",
"w + 2",
"w",
"2",
"cm = [[\".\"] * (w + 2) for _ in range(h + 2)]",
"cm",
"[[\".\"] * (w + 2) for _ in range(h + 2)]",
"que = deque([])",
"que",
"deque([])",
"deque",
"[]",
"for i in range(1, h + 1):\n cm[i] = \".\" + input().rstrip('\\n') + \".\"\n ",
"i",
"range(1, h + 1)",
"range",
"1",
"h + 1",
"h",
"1",
"cm[i] = \".\" + input().rstrip('\\n') + \".\"",
"cm[i]",
"cm",
"i",
"\".\" + input().rstrip('\\n') + \".\"",
"\".\" + input().rstrip('\\n')",
"\".\"",
"input().rstrip('\\n')",
"().rstrip",
"()",
"input",
"rstrip",
"'\\n'",
"\".\"",
"que.append([1, 1])",
"que.append",
"que",
"append",
"[1, 1]",
"1",
"1",
"while len(que) > 0:\n y, x = que.popleft()\n if (cm[y + 1][x] == \"#\" and cm[y][x + 1] == \"#\") or cm[y + 1][x - 1] == \"#\" or cm[y - 1][x + 1] == \"#\":\n print('Impossible')\n exit()\n if cm[y + 1][x] == \"#\":\n que.append([y + 1, x])\n if cm[y][x + 1] == \"#\":\n que.append([y, x + 1])\n ",
"len(que) > 0",
"len(que)",
"len",
"que",
"0",
"y, x = que.popleft()",
"y",
"que.popleft()",
"que.popleft",
"que",
"popleft",
"x",
"if (cm[y + 1][x] == \"#\" and cm[y][x + 1] == \"#\") or cm[y + 1][x - 1] == \"#\" or cm[y - 1][x + 1] == \"#\":\n print('Impossible')\n exit()\n ",
"(cm[y + 1][x] == \"#\" and cm[y][x + 1] == \"#\") or cm[y + 1][x - 1] == \"#\" or cm[y - 1][x + 1] == \"#\"",
"(cm[y + 1][x] == \"#\" and cm[y][x + 1] == \"#\") or cm[y + 1][x - 1] == \"#\"",
"cm[y + 1][x] == \"#\" and cm[y][x + 1] == \"#\"",
"cm[y + 1][x] == \"#\"",
"cm[y + 1][x]",
"[y + 1]",
"cm",
"y + 1",
"y",
"1",
"x",
"\"#\"",
"cm[y][x + 1] == \"#\"",
"cm[y][x + 1]",
"[y]",
"cm",
"y",
"x + 1",
"x",
"1",
"\"#\"",
"cm[y + 1][x - 1] == \"#\"",
"cm[y + 1][x - 1]",
"[y + 1]",
"cm",
"y + 1",
"y",
"1",
"x - 1",
"x",
"1",
"\"#\"",
"cm[y - 1][x + 1] == \"#\"",
"cm[y - 1][x + 1]",
"[y - 1]",
"cm",
"y - 1",
"y",
"1",
"x + 1",
"x",
"1",
"\"#\"",
"print('Impossible')",
"print",
"'Impossible'",
"exit()",
"exit",
"if cm[y + 1][x] == \"#\":\n que.append([y + 1, x])\n ",
"cm[y + 1][x] == \"#\"",
"cm[y + 1][x]",
"[y + 1]",
"cm",
"y + 1",
"y",
"1",
"x",
"\"#\"",
"que.append([y + 1, x])",
"que.append",
"que",
"append",
"[y + 1, x]",
"y + 1",
"y",
"1",
"x",
"if cm[y][x + 1] == \"#\":\n que.append([y, x + 1])\n ",
"cm[y][x + 1] == \"#\"",
"cm[y][x + 1]",
"[y]",
"cm",
"y",
"x + 1",
"x",
"1",
"\"#\"",
"que.append([y, x + 1])",
"que.append",
"que",
"append",
"[y, x + 1]",
"y",
"x + 1",
"x",
"1",
"print('Possible')",
"print",
"'Possible'",
"main()",
"main",
"def main():\n from collections import deque\n input = stdin.readline\n\n h, w = map(int, input().split())\n cm = [[\".\"] * (w + 2) for _ in range(h + 2)]\n que = deque([])\n for i in range(1, h + 1):\n cm[i] = \".\" + input().rstrip('\\n') + \".\"\n que.append([1, 1])\n while len(que) > 0:\n y, x = que.popleft()\n if (cm[y + 1][x] == \"#\" and cm[y][x + 1] == \"#\") or cm[y + 1][x - 1] == \"#\" or cm[y - 1][x + 1] == \"#\":\n print('Impossible')\n exit()\n if cm[y + 1][x] == \"#\":\n que.append([y + 1, x])\n if cm[y][x + 1] == \"#\":\n que.append([y, x + 1])\n print('Possible')",
"def main():\n from collections import deque\n input = stdin.readline\n\n h, w = map(int, input().split())\n cm = [[\".\"] * (w + 2) for _ in range(h + 2)]\n que = deque([])\n for i in range(1, h + 1):\n cm[i] = \".\" + input().rstrip('\\n') + \".\"\n que.append([1, 1])\n while len(que) > 0:\n y, x = que.popleft()\n if (cm[y + 1][x] == \"#\" and cm[y][x + 1] == \"#\") or cm[y + 1][x - 1] == \"#\" or cm[y - 1][x + 1] == \"#\":\n print('Impossible')\n exit()\n if cm[y + 1][x] == \"#\":\n que.append([y + 1, x])\n if cm[y][x + 1] == \"#\":\n que.append([y, x + 1])\n print('Possible')",
"main"
] |
from sys import stdin
def main():
from collections import deque
input = stdin.readline
h, w = map(int, input().split())
cm = [["."] * (w + 2) for _ in range(h + 2)]
que = deque([])
for i in range(1, h + 1):
cm[i] = "." + input().rstrip('\n') + "."
que.append([1, 1])
while len(que) > 0:
y, x = que.popleft()
if (cm[y + 1][x] == "#" and cm[y][x + 1] == "#") or cm[y + 1][x - 1] == "#" or cm[y - 1][x + 1] == "#":
print('Impossible')
exit()
if cm[y + 1][x] == "#":
que.append([y + 1, x])
if cm[y][x + 1] == "#":
que.append([y, x + 1])
print('Possible')
main()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
0,
18,
13,
13,
13,
0,
13,
17,
13,
17,
0,
13,
17,
13,
17,
42,
40,
2,
2,
13,
2,
13,
17,
2,
13,
2,
13,
17,
14,
40,
2,
2,
13,
17,
2,
13,
17,
14,
2,
2,
13,
13,
2,
13,
13,
4,
13,
17,
4,
13,
0,
13,
13,
13,
13,
14,
40,
2,
2,
13,
17,
2,
13,
17,
14,
2,
18,
18,
13,
13,
2,
13,
17,
17,
0,
18,
18,
13,
13,
13,
17,
0,
13,
17,
9,
14,
40,
2,
2,
13,
17,
2,
13,
17,
14,
2,
18,
18,
13,
2,
13,
17,
13,
17,
0,
18,
18,
13,
13,
13,
17,
0,
13,
17,
9,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
14,
2,
2,
13,
2,
13,
17,
2,
13,
2,
13,
17,
0,
13,
17,
14,
13,
4,
13,
17,
4,
13,
17,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
13,
13,
10,
17,
13,
10,
2,
13,
10,
17,
13
] |
[
[
201,
2
],
[
201,
11
],
[
225,
13
],
[
202,
17
],
[
20,
19
],
[
202,
22
],
[
195,
24
],
[
33,
30
],
[
226,
31
],
[
19,
32
],
[
196,
33
],
[
210,
35
],
[
192,
37
],
[
207,
40
],
[
213,
42
],
[
211,
48
],
[
190,
48
],
[
199,
50
],
[
193,
53
],
[
223,
53
],
[
202,
55
],
[
211,
61
],
[
190,
61
],
[
193,
64
],
[
223,
64
],
[
208,
69
],
[
205,
69
],
[
211,
70
],
[
190,
70
],
[
214,
72
],
[
220,
72
],
[
193,
73
],
[
223,
73
],
[
204,
80
],
[
211,
81
],
[
190,
81
],
[
219,
82
],
[
193,
83
],
[
223,
83
],
[
211,
88
],
[
190,
88
],
[
199,
91
],
[
226,
97
],
[
193,
98
],
[
223,
98
],
[
211,
100
],
[
190,
100
],
[
109,
104
],
[
226,
106
],
[
193,
107
],
[
223,
107
],
[
211,
108
],
[
190,
108
],
[
189,
111
],
[
193,
118
],
[
223,
118
],
[
202,
121
],
[
226,
127
],
[
193,
129
],
[
223,
129
],
[
190,
131
],
[
211,
131
],
[
139,
134
],
[
226,
136
],
[
193,
137
],
[
223,
137
],
[
190,
138
],
[
211,
138
],
[
222,
141
],
[
228,
145
],
[
149,
148
],
[
202,
151
],
[
154,
153
],
[
199,
156
],
[
30,
160
],
[
226,
161
],
[
148,
162
],
[
153,
163
],
[
148,
168
],
[
202,
170
],
[
153,
173
],
[
199,
175
],
[
216,
178
],
[
189,
190
],
[
192,
193
],
[
195,
196
],
[
201,
199
],
[
201,
202
],
[
211,
204
],
[
190,
204
],
[
204,
205
],
[
207,
208
],
[
210,
211
],
[
213,
214
],
[
216,
217
],
[
193,
219
],
[
223,
219
],
[
219,
220
],
[
222,
223
],
[
225,
226
],
[
228,
229
]
] |
[
"h, w = map(int, input().split())\na = [0] * h\nfor i in range(h):\n aa = list(input())\n a[i] = aa\n\nx, y = 0, 0\npx, py = 0, 0\nwhile not (x == w-1 and y == h-1):\n if not (x == 0 and y == 0):\n if px == x and py == y:\n print('Impossible')\n exit()\n px, py = x, y\n # → を検索\n if not x+1 > w-1:\n if a[y][x+1] == '#':\n a[y][x] = '.'\n x += 1\n continue\n # ↓ を検索\n if not y+1 > h-1:\n if a[y+1][x] == '#':\n a[y][x] = '.'\n y += 1\n continue\n\nans = True\n\nfor i in range(h):\n for j in range(w):\n if a[i][j] == '#':\n if i == h-1 and j == w-1:\n pass\n else:\n ans = False\n\nif ans:\n print('Possible')\nelse:\n print('Impossible')",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"a = [0] * h",
"a",
"[0] * h",
"[0]",
"0",
"h",
"for i in range(h):\n aa = list(input())\n a[i] = aa",
"i",
"range(h)",
"range",
"h",
"aa = list(input())",
"aa",
"list(input())",
"list",
"input()",
"input",
"a[i] = aa",
"a[i]",
"a",
"i",
"aa",
"x, y = 0, 0",
"x",
"0",
"y",
"0",
"px, py = 0, 0",
"px",
"0",
"py",
"0",
"while not (x == w-1 and y == h-1):\n if not (x == 0 and y == 0):\n if px == x and py == y:\n print('Impossible')\n exit()\n px, py = x, y\n # → を検索\n if not x+1 > w-1:\n if a[y][x+1] == '#':\n a[y][x] = '.'\n x += 1\n continue\n # ↓ を検索\n if not y+1 > h-1:\n if a[y+1][x] == '#':\n a[y][x] = '.'\n y += 1\n continue",
"not (x == w-1 and y == h-1)",
"x == w-1 and y == h-1",
"x == w-1",
"x",
"w-1",
"w",
"1",
"y == h-1",
"y",
"h-1",
"h",
"1",
"if not (x == 0 and y == 0):\n if px == x and py == y:\n print('Impossible')\n exit()\n ",
"not (x == 0 and y == 0)",
"x == 0 and y == 0",
"x == 0",
"x",
"0",
"y == 0",
"y",
"0",
"if px == x and py == y:\n print('Impossible')\n exit()\n ",
"px == x and py == y",
"px == x",
"px",
"x",
"py == y",
"py",
"y",
"print('Impossible')",
"print",
"'Impossible'",
"exit()",
"exit",
"px, py = x, y",
"px",
"x",
"py",
"y",
"if not x+1 > w-1:\n if a[y][x+1] == '#':\n a[y][x] = '.'\n x += 1\n continue\n # ↓ を検索\n ",
"not x+1 > w-1",
"x+1 > w-1",
"x+1",
"x",
"1",
"w-1",
"w",
"1",
"if a[y][x+1] == '#':\n a[y][x] = '.'\n x += 1\n continue\n # ↓ を検索\n ",
"a[y][x+1] == '#'",
"a[y][x+1]",
"[y]",
"a",
"y",
"x+1",
"x",
"1",
"'#'",
"a[y][x] = '.'",
"a[y][x]",
"[y]",
"a",
"y",
"x",
"'.'",
"x += 1",
"x",
"1",
"continue",
"if not y+1 > h-1:\n if a[y+1][x] == '#':\n a[y][x] = '.'\n y += 1\n continue",
"not y+1 > h-1",
"y+1 > h-1",
"y+1",
"y",
"1",
"h-1",
"h",
"1",
"if a[y+1][x] == '#':\n a[y][x] = '.'\n y += 1\n continue",
"a[y+1][x] == '#'",
"a[y+1][x]",
"[y+1]",
"a",
"y+1",
"y",
"1",
"x",
"'#'",
"a[y][x] = '.'",
"a[y][x]",
"[y]",
"a",
"y",
"x",
"'.'",
"y += 1",
"y",
"1",
"continue",
"ans = True",
"ans",
"True",
"for i in range(h):\n for j in range(w):\n if a[i][j] == '#':\n if i == h-1 and j == w-1:\n pass\n else:\n ans = False",
"i",
"range(h)",
"range",
"h",
"for j in range(w):\n if a[i][j] == '#':\n if i == h-1 and j == w-1:\n pass\n else:\n ans = False",
"j",
"range(w)",
"range",
"w",
"if a[i][j] == '#':\n if i == h-1 and j == w-1:\n pass\n else:\n ans = False",
"a[i][j] == '#'",
"a[i][j]",
"[i]",
"a",
"i",
"j",
"'#'",
"if i == h-1 and j == w-1:\n pass\n else:\n ans = False",
"i == h-1 and j == w-1",
"i == h-1",
"i",
"h-1",
"h",
"1",
"j == w-1",
"j",
"w-1",
"w",
"1",
"ans = False",
"ans",
"False",
"if ans:\n print('Possible')\nelse:\n print('Impossible')",
"ans",
"print('Possible')",
"print",
"'Possible'",
"print('Impossible')",
"print",
"'Impossible'",
"x += 1",
"1",
"x",
"y = 0, 0",
"0",
"y",
"aa = list(input())",
"list(input())",
"aa",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h",
"px, py = x, y",
"x",
"px",
"px, py = 0, 0",
"0",
"px",
"x, y = 0, 0",
"0",
"x",
"py = 0, 0",
"0",
"py",
"ans = False",
"False",
"ans",
"py = x, y",
"y",
"py",
"y += 1",
"1",
"y",
"a = [0] * h",
"[0] * h",
"a",
"ans = True",
"True",
"ans"
] |
h, w = map(int, input().split())
a = [0] * h
for i in range(h):
aa = list(input())
a[i] = aa
x, y = 0, 0
px, py = 0, 0
while not (x == w-1 and y == h-1):
if not (x == 0 and y == 0):
if px == x and py == y:
print('Impossible')
exit()
px, py = x, y
# → を検索
if not x+1 > w-1:
if a[y][x+1] == '#':
a[y][x] = '.'
x += 1
continue
# ↓ を検索
if not y+1 > h-1:
if a[y+1][x] == '#':
a[y][x] = '.'
y += 1
continue
ans = True
for i in range(h):
for j in range(w):
if a[i][j] == '#':
if i == h-1 and j == w-1:
pass
else:
ans = False
if ans:
print('Possible')
else:
print('Impossible')
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
41,
28,
13,
4,
13,
13,
2,
18,
18,
13,
13,
13,
17,
4,
13,
0,
13,
13,
28,
13,
4,
13,
2,
4,
13,
13,
17,
14,
2,
2,
18,
13,
13,
17,
18,
13,
2,
13,
17,
9,
15,
13,
4,
13,
17,
4,
18,
13,
13,
14,
2,
13,
18,
13,
17,
0,
13,
18,
13,
17,
15,
13,
4,
13,
17,
4,
18,
13,
13,
4,
13,
17,
10,
17,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13,
10,
18,
13,
10,
4,
13
] |
[
[
120,
2
],
[
120,
11
],
[
15,
14
],
[
115,
17
],
[
108,
22
],
[
105,
25
],
[
29,
28
],
[
115,
31
],
[
35,
34
],
[
121,
37
],
[
109,
41
],
[
28,
42
],
[
34,
43
],
[
34,
46
],
[
111,
48
],
[
52,
51
],
[
112,
57
],
[
112,
63
],
[
51,
64
],
[
112,
67
],
[
51,
69
],
[
106,
83
],
[
118,
83
],
[
112,
85
],
[
117,
88
],
[
112,
90
],
[
105,
106
],
[
108,
109
],
[
111,
112
],
[
120,
115
],
[
117,
118
],
[
120,
121
]
] |
[
"h, w = map(int, input().split())\na = [input() for _i in range(h)]\np = 0\nfor i in range(h):\n x = [j for j in range(w) if a[i][j]==\"#\"]\n for j in range(len(x)-1):\n if x[j]+1==x[j+1]:\n continue\n else:\n import sys\n print(\"Impossible\")\n sys.exit()\n if p==x[0]:\n p = x[-1]\n else:\n import sys\n print(\"Impossible\")\n sys.exit()\nprint(\"Possible\")",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"input() for _i in range(h)",
"for _i in range(h)",
"_i",
"range(h)",
"range",
"h",
"for _i in range(h)",
"input()",
"input",
"a = [input() for _i in range(h)]",
"a",
"[input() for _i in range(h)]",
"p = 0",
"p",
"0",
"for i in range(h):\n x = [j for j in range(w) if a[i][j]==\"#\"]\n for j in range(len(x)-1):\n if x[j]+1==x[j+1]:\n continue\n else:\n import sys\n print(\"Impossible\")\n sys.exit()\n if p==x[0]:\n p = x[-1]\n else:\n import sys\n print(\"Impossible\")\n sys.exit()",
"i",
"range(h)",
"range",
"h",
"j for j in range(w) if a[i][j]==\"#\"",
"for j in range(w) if a[i][j]==\"#\"",
"j",
"range(w)",
"range",
"w",
"a[i][j]==\"#\"",
"a[i][j]",
"[i]",
"a",
"i",
"j",
"\"#\"",
"if a[i][j]==\"#\"",
"j",
"x = [j for j in range(w) if a[i][j]==\"#\"]",
"x",
"[j for j in range(w) if a[i][j]==\"#\"]",
"for j in range(len(x)-1):\n if x[j]+1==x[j+1]:\n continue\n else:\n import sys\n print(\"Impossible\")\n sys.exit()\n ",
"j",
"range(len(x)-1)",
"range",
"len(x)-1",
"len(x)",
"len",
"x",
"1",
"if x[j]+1==x[j+1]:\n continue\n else:\n import sys\n print(\"Impossible\")\n sys.exit()\n ",
"x[j]+1==x[j+1]",
"x[j]+1",
"x[j]",
"x",
"j",
"1",
"x[j+1]",
"x",
"j+1",
"j",
"1",
"continue",
"import sys",
"sys",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"sys.exit()",
"sys.exit",
"sys",
"exit",
"if p==x[0]:\n p = x[-1]\n else:\n import sys\n print(\"Impossible\")\n sys.exit()",
"p==x[0]",
"p",
"x[0]",
"x",
"0",
"p = x[-1]",
"p",
"x[-1]",
"x",
"-1",
"import sys",
"sys",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"sys.exit()",
"sys.exit",
"sys",
"exit",
"print(\"Possible\")",
"print",
"\"Possible\"",
"p = 0",
"0",
"p",
"a = [input() for _i in range(h)]",
"[input() for _i in range(h)]",
"a",
"x = [j for j in range(w) if a[i][j]==\"#\"]",
"[j for j in range(w) if a[i][j]==\"#\"]",
"x",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h",
"p = x[-1]",
"x[-1]",
"p",
"w = map(int, input().split())",
"map(int, input().split())",
"w"
] |
h, w = map(int, input().split())
a = [input() for _i in range(h)]
p = 0
for i in range(h):
x = [j for j in range(w) if a[i][j]=="#"]
for j in range(len(x)-1):
if x[j]+1==x[j+1]:
continue
else:
import sys
print("Impossible")
sys.exit()
if p==x[0]:
p = x[-1]
else:
import sys
print("Impossible")
sys.exit()
print("Possible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
0,
13,
17,
0,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
14,
2,
2,
2,
13,
13,
2,
2,
13,
13,
17,
2,
2,
2,
13,
13,
17,
2,
13,
13,
0,
13,
13,
0,
13,
13,
0,
13,
17,
4,
13,
13,
10,
17,
13,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
13,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13
] |
[
[
104,
2
],
[
104,
11
],
[
15,
14
],
[
96,
17
],
[
107,
24
],
[
86,
27
],
[
98,
30
],
[
110,
33
],
[
37,
36
],
[
96,
39
],
[
42,
41
],
[
105,
44
],
[
108,
49
],
[
36,
50
],
[
41,
51
],
[
36,
57
],
[
87,
58
],
[
90,
58
],
[
41,
61
],
[
99,
62
],
[
102,
62
],
[
36,
67
],
[
87,
68
],
[
90,
68
],
[
41,
71
],
[
99,
72
],
[
102,
72
],
[
89,
74
],
[
36,
75
],
[
101,
77
],
[
41,
78
],
[
92,
80
],
[
93,
84
],
[
111,
84
],
[
86,
87
],
[
36,
89
],
[
89,
90
],
[
92,
93
],
[
104,
96
],
[
98,
99
],
[
41,
101
],
[
101,
102
],
[
104,
105
],
[
107,
108
],
[
110,
111
]
] |
[
"H,W=map(int,input().split())\nA=[list(input()) for _ in range(H)]\nh=0\nw=0\nans=\"Possible\"\nfor i in range(H):\n for j in range(W):\n if A[i][j]==\"#\":\n if (i==h and j-w<2) or (i-h<2 and j==w):\n h=i\n w=j\n else:\n ans=\"Impossible\"\nprint(ans)",
"H,W=map(int,input().split())",
"H",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"list(input()) for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"list(input())",
"list",
"input()",
"input",
"A=[list(input()) for _ in range(H)]",
"A",
"[list(input()) for _ in range(H)]",
"h=0",
"h",
"0",
"w=0",
"w",
"0",
"ans=\"Possible\"",
"ans",
"\"Possible\"",
"for i in range(H):\n for j in range(W):\n if A[i][j]==\"#\":\n if (i==h and j-w<2) or (i-h<2 and j==w):\n h=i\n w=j\n else:\n ans=\"Impossible\"",
"i",
"range(H)",
"range",
"H",
"for j in range(W):\n if A[i][j]==\"#\":\n if (i==h and j-w<2) or (i-h<2 and j==w):\n h=i\n w=j\n else:\n ans=\"Impossible\"",
"j",
"range(W)",
"range",
"W",
"if A[i][j]==\"#\":\n if (i==h and j-w<2) or (i-h<2 and j==w):\n h=i\n w=j\n else:\n ans=\"Impossible\"",
"A[i][j]==\"#\"",
"A[i][j]",
"[i]",
"A",
"i",
"j",
"\"#\"",
"if (i==h and j-w<2) or (i-h<2 and j==w):\n h=i\n w=j\n else:\n ans=\"Impossible\"",
"(i==h and j-w<2) or (i-h<2 and j==w)",
"i==h and j-w<2",
"i==h",
"i",
"h",
"j-w<2",
"j-w",
"j",
"w",
"2",
"i-h<2 and j==w",
"i-h<2",
"i-h",
"i",
"h",
"2",
"j==w",
"j",
"w",
"h=i",
"h",
"i",
"w=j",
"w",
"j",
"ans=\"Impossible\"",
"ans",
"\"Impossible\"",
"print(ans)",
"print",
"ans",
"h=0",
"0",
"h",
"h=i",
"i",
"h",
"ans=\"Impossible\"",
"\"Impossible\"",
"ans",
"H,W=map(int,input().split())",
"map(int,input().split())",
"H",
"w=0",
"0",
"w",
"w=j",
"j",
"w",
"W=map(int,input().split())",
"map(int,input().split())",
"W",
"A=[list(input()) for _ in range(H)]",
"[list(input()) for _ in range(H)]",
"A",
"ans=\"Possible\"",
"\"Possible\"",
"ans"
] |
H,W=map(int,input().split())
A=[list(input()) for _ in range(H)]
h=0
w=0
ans="Possible"
for i in range(H):
for j in range(W):
if A[i][j]=="#":
if (i==h and j-w<2) or (i-h<2 and j==w):
h=i
w=j
else:
ans="Impossible"
print(ans)
|
[
7,
15,
13,
13,
13,
13,
15,
15,
15,
15,
13,
12,
13,
12,
13,
12,
13,
12,
13,
0,
13,
4,
13,
13,
41,
28,
13,
4,
13,
13,
4,
2,
4,
13,
17,
0,
13,
13,
4,
18,
13,
13,
2,
17,
2,
13,
17,
0,
13,
17,
0,
13,
17,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
2,
13,
17,
0,
13,
13,
14,
2,
18,
18,
13,
17,
17,
17,
4,
13,
17,
4,
13,
42,
2,
2,
13,
13,
2,
13,
13,
0,
18,
18,
13,
13,
13,
17,
14,
2,
2,
2,
2,
18,
18,
13,
13,
13,
18,
18,
13,
2,
13,
17,
13,
18,
18,
13,
13,
2,
13,
17,
18,
18,
13,
2,
13,
17,
2,
13,
17,
17,
4,
13,
17,
4,
13,
14,
2,
2,
13,
2,
13,
17,
2,
13,
2,
13,
17,
3,
14,
2,
18,
18,
13,
2,
13,
17,
13,
17,
0,
13,
17,
14,
2,
18,
18,
13,
13,
2,
13,
17,
17,
0,
13,
17,
4,
13,
17,
4,
13,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
40,
18,
18,
13,
13,
13,
18,
18,
13,
13,
13,
4,
13,
17,
4,
13,
4,
13,
17,
10,
12,
13,
10,
13,
13,
10,
12,
13,
10,
12,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
12,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
13,
13
] |
[
[
243,
20
],
[
214,
22
],
[
243,
23
],
[
27,
26
],
[
244,
29
],
[
220,
33
],
[
246,
36
],
[
247,
40
],
[
232,
45
],
[
237,
48
],
[
237,
51
],
[
56,
55
],
[
244,
59
],
[
232,
66
],
[
216,
69
],
[
247,
75
],
[
226,
87
],
[
241,
87
],
[
244,
88
],
[
238,
90
],
[
229,
90
],
[
232,
91
],
[
98,
93
],
[
217,
95
],
[
226,
96
],
[
241,
96
],
[
238,
97
],
[
229,
97
],
[
247,
106
],
[
226,
107
],
[
241,
107
],
[
238,
108
],
[
229,
108
],
[
247,
111
],
[
226,
113
],
[
241,
113
],
[
238,
115
],
[
229,
115
],
[
247,
118
],
[
226,
119
],
[
241,
119
],
[
238,
121
],
[
229,
121
],
[
247,
125
],
[
226,
127
],
[
241,
127
],
[
238,
130
],
[
229,
130
],
[
226,
141
],
[
241,
141
],
[
244,
143
],
[
238,
146
],
[
229,
146
],
[
232,
148
],
[
247,
155
],
[
226,
157
],
[
241,
157
],
[
238,
159
],
[
229,
159
],
[
240,
162
],
[
247,
168
],
[
226,
169
],
[
241,
169
],
[
238,
171
],
[
229,
171
],
[
228,
175
],
[
184,
183
],
[
244,
186
],
[
189,
188
],
[
232,
191
],
[
247,
196
],
[
183,
197
],
[
188,
198
],
[
93,
199
],
[
217,
201
],
[
183,
202
],
[
188,
203
],
[
216,
217
],
[
237,
226
],
[
228,
229
],
[
243,
232
],
[
237,
238
],
[
240,
241
],
[
243,
244
],
[
246,
247
]
] |
[
"import bisect,copy,heapq,string\nfrom collections import *\nfrom math import *\nfrom itertools import *\nimport sys\ndef input() : return sys.stdin.readline().strip()\ndef INT() : return int(input())\ndef MAP() : return map(int,input().split())\ndef LIST() : return list(MAP())\n\nh, w = MAP()\na = [input()+'.' for i in range(h)]\na.append(\".\"*(w+1))\ni = j = 0\nb = [['.']*(w+1) for i in range(h+1)]\n\nif a[0][0] == '.':\n print(\"Impossible\")\n exit()\nelse:\n while i < h or j < w:\n b[i][j] = '#'\n \n if a[i][j] == a[i+1][j] == a[i][j+1] == a[i+1][j+1] == '#':\n print(\"Impossible\")\n exit()\n\n if i == h-1 and j == w-1:\n break\n elif a[i+1][j] == '#':\n i += 1\n elif a[i][j+1] == '#':\n j += 1\n else: \n print(\"Impossible\")\n exit()\n\n for i in range(h):\n for j in range(w):\n if a[i][j] != b[i][j]:\n print(\"Impossible\")\n exit()\n print(\"Possible\")",
"import bisect,copy,heapq,string",
"bisect",
"copy",
"heapq",
"string",
"from collections import *",
"from math import *",
"from itertools import *",
"import sys",
"sys",
"def input() : return sys.stdin.readline().strip()",
"input",
"def INT() : return int(input())",
"INT",
"def MAP() : return map(int,input().split())",
"MAP",
"def LIST() : return list(MAP())",
"LIST",
"h, w = MAP()",
"h",
"MAP()",
"MAP",
"w",
"input()+'.' for i in range(h)",
"for i in range(h)",
"i",
"range(h)",
"range",
"h",
"for i in range(h)",
"input()+'.'",
"input()",
"input",
"'.'",
"a = [input()+'.' for i in range(h)]",
"a",
"[input()+'.' for i in range(h)]",
"a.append(\".\"*(w+1))",
"a.append",
"a",
"append",
"\".\"*(w+1)",
"\".\"",
"w+1",
"w",
"1",
"i = j = 0",
"i",
"0",
"= j = 0",
"j",
"0",
"['.']*(w+1) for i in range(h+1)",
"for i in range(h+1)",
"i",
"range(h+1)",
"range",
"h+1",
"h",
"1",
"for i in range(h+1)",
"['.']*(w+1)",
"['.']",
"'.'",
"w+1",
"w",
"1",
"b = [['.']*(w+1) for i in range(h+1)]",
"b",
"[['.']*(w+1) for i in range(h+1)]",
"if a[0][0] == '.':\n print(\"Impossible\")\n exit()\nelse:\n while i < h or j < w:\n b[i][j] = '#'\n \n if a[i][j] == a[i+1][j] == a[i][j+1] == a[i+1][j+1] == '#':\n print(\"Impossible\")\n exit()\n\n if i == h-1 and j == w-1:\n break\n elif a[i+1][j] == '#':\n i += 1\n elif a[i][j+1] == '#':\n j += 1\n else: \n print(\"Impossible\")\n exit()\n\n for i in range(h):\n for j in range(w):\n if a[i][j] != b[i][j]:\n print(\"Impossible\")\n exit()\n print(\"Possible\")",
"a[0][0] == '.'",
"a[0][0]",
"[0]",
"a",
"0",
"0",
"'.'",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"exit()",
"exit",
"while i < h or j < w:\n b[i][j] = '#'\n \n if a[i][j] == a[i+1][j] == a[i][j+1] == a[i+1][j+1] == '#':\n print(\"Impossible\")\n exit()\n\n if i == h-1 and j == w-1:\n break\n elif a[i+1][j] == '#':\n i += 1\n elif a[i][j+1] == '#':\n j += 1\n else: \n print(\"Impossible\")\n exit()\n\n ",
"i < h or j < w",
"i < h",
"i",
"h",
"j < w",
"j",
"w",
"b[i][j] = '#'",
"b[i][j]",
"[i]",
"b",
"i",
"j",
"'#'",
"if a[i][j] == a[i+1][j] == a[i][j+1] == a[i+1][j+1] == '#':\n print(\"Impossible\")\n exit()\n\n ",
"a[i][j] == a[i+1][j] == a[i][j+1] == a[i+1][j+1] == '#'",
"a[i][j] == a[i+1][j] == a[i][j+1] == a[i+1][j+1]",
"a[i][j] == a[i+1][j] == a[i][j+1]",
"a[i][j] == a[i+1][j]",
"a[i][j]",
"[i]",
"a",
"i",
"j",
"a[i+1][j]",
"[i+1]",
"a",
"i+1",
"i",
"1",
"j",
"a[i][j+1]",
"[i]",
"a",
"i",
"j+1",
"j",
"1",
"a[i+1][j+1]",
"[i+1]",
"a",
"i+1",
"i",
"1",
"j+1",
"j",
"1",
"'#'",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"exit()",
"exit",
"if i == h-1 and j == w-1:\n break\n elif a[i+1][j] == '#':\n i += 1\n elif a[i][j+1] == '#':\n j += 1\n else: \n print(\"Impossible\")\n exit()\n\n ",
"i == h-1 and j == w-1",
"i == h-1",
"i",
"h-1",
"h",
"1",
"j == w-1",
"j",
"w-1",
"w",
"1",
"break",
"elif a[i+1][j] == '#':\n i += 1\n ",
"a[i+1][j] == '#'",
"a[i+1][j]",
"[i+1]",
"a",
"i+1",
"i",
"1",
"j",
"'#'",
"i += 1",
"i",
"1",
"elif a[i][j+1] == '#':\n j += 1\n ",
"a[i][j+1] == '#'",
"a[i][j+1]",
"[i]",
"a",
"i",
"j+1",
"j",
"1",
"'#'",
"j += 1",
"j",
"1",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"exit()",
"exit",
"for i in range(h):\n for j in range(w):\n if a[i][j] != b[i][j]:\n print(\"Impossible\")\n exit()\n ",
"i",
"range(h)",
"range",
"h",
"for j in range(w):\n if a[i][j] != b[i][j]:\n print(\"Impossible\")\n exit()\n ",
"j",
"range(w)",
"range",
"w",
"if a[i][j] != b[i][j]:\n print(\"Impossible\")\n exit()\n ",
"a[i][j] != b[i][j]",
"a[i][j]",
"[i]",
"a",
"i",
"j",
"b[i][j]",
"[i]",
"b",
"i",
"j",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"exit()",
"exit",
"print(\"Possible\")",
"print",
"\"Possible\"",
"def MAP() : return map(int,input().split())",
"def MAP() : return map(int,input().split())",
"MAP",
"b = [['.']*(w+1) for i in range(h+1)]",
"[['.']*(w+1) for i in range(h+1)]",
"b",
"def input() : return sys.stdin.readline().strip()",
"def input() : return sys.stdin.readline().strip()",
"input",
"def INT() : return int(input())",
"def INT() : return int(input())",
"INT",
"i = j = 0",
"0",
"i",
"j += 1",
"1",
"j",
"w = MAP()",
"MAP()",
"w",
"def LIST() : return list(MAP())",
"def LIST() : return list(MAP())",
"LIST",
"j = 0",
"0",
"j",
"i += 1",
"1",
"i",
"h, w = MAP()",
"MAP()",
"h",
"a = [input()+'.' for i in range(h)]",
"[input()+'.' for i in range(h)]",
"a"
] |
import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
def input() : return sys.stdin.readline().strip()
def INT() : return int(input())
def MAP() : return map(int,input().split())
def LIST() : return list(MAP())
h, w = MAP()
a = [input()+'.' for i in range(h)]
a.append("."*(w+1))
i = j = 0
b = [['.']*(w+1) for i in range(h+1)]
if a[0][0] == '.':
print("Impossible")
exit()
else:
while i < h or j < w:
b[i][j] = '#'
if a[i][j] == a[i+1][j] == a[i][j+1] == a[i+1][j+1] == '#':
print("Impossible")
exit()
if i == h-1 and j == w-1:
break
elif a[i+1][j] == '#':
i += 1
elif a[i][j+1] == '#':
j += 1
else:
print("Impossible")
exit()
for i in range(h):
for j in range(w):
if a[i][j] != b[i][j]:
print("Impossible")
exit()
print("Possible")
|
[
7,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
2,
13,
17,
2,
13,
17,
14,
2,
2,
18,
18,
13,
2,
13,
17,
13,
17,
2,
18,
18,
13,
13,
2,
13,
17,
17,
14,
2,
2,
13,
2,
13,
17,
2,
13,
2,
13,
17,
14,
2,
2,
18,
18,
13,
2,
13,
17,
13,
17,
2,
18,
18,
13,
13,
2,
13,
17,
17,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
0,
13,
17,
14,
40,
13,
17,
14,
2,
18,
18,
13,
2,
13,
17,
13,
17,
14,
40,
13,
17,
14,
2,
18,
18,
13,
13,
2,
13,
17,
17,
14,
40,
13,
2,
13,
17,
14,
2,
18,
18,
13,
2,
13,
17,
13,
17,
14,
40,
13,
2,
13,
17,
14,
2,
18,
18,
13,
13,
2,
13,
17,
17,
14,
2,
40,
13,
17,
40,
13,
17,
14,
2,
13,
17,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13
] |
[
[
4,
3
],
[
190,
11
],
[
190,
20
],
[
193,
22
],
[
187,
25
],
[
29,
28
],
[
191,
31
],
[
34,
33
],
[
185,
36
],
[
28,
40
],
[
33,
43
],
[
194,
50
],
[
28,
52
],
[
33,
54
],
[
194,
59
],
[
28,
60
],
[
33,
62
],
[
28,
68
],
[
191,
70
],
[
33,
73
],
[
185,
75
],
[
194,
82
],
[
28,
84
],
[
33,
86
],
[
194,
91
],
[
28,
92
],
[
33,
94
],
[
194,
101
],
[
28,
102
],
[
33,
103
],
[
199,
106
],
[
199,
109
],
[
28,
113
],
[
194,
119
],
[
28,
121
],
[
33,
123
],
[
33,
127
],
[
194,
133
],
[
28,
134
],
[
33,
136
],
[
28,
141
],
[
191,
143
],
[
194,
149
],
[
28,
151
],
[
33,
153
],
[
33,
157
],
[
185,
159
],
[
194,
165
],
[
28,
166
],
[
33,
168
],
[
200,
174
],
[
197,
177
],
[
188,
181
],
[
190,
185
],
[
187,
188
],
[
190,
191
],
[
193,
194
],
[
199,
197
],
[
199,
200
]
] |
[
"h, w = map(int, input().split()); a = [input() for _ in range(h)]; z = 0\nfor i in range(h):\n for j in range(w):\n if i == 0 and j == 0:\n if a[i+1][j] == \"#\" and a[i][j+1] == \"#\": print(\"Impossible\"); z = 1; break\n elif i == h-1 and j == w-1:\n if a[i-1][j] == \"#\" and a[i][j-1] == \"#\": print(\"Impossible\"); z = 1; break\n else:\n if a[i][j] == \"#\":\n x = y = 0\n if i != 0:\n if a[i-1][j] == \"#\": x += 1\n if j != 0:\n if a[i][j-1] == \"#\": x += 1\n if i != h-1:\n if a[i+1][j] == \"#\": y += 1\n if j != w-1:\n if a[i][j+1] == \"#\": y += 1\n if x != 1 or y != 1: print(\"Impossible\"); z = 1; break\n if z == 1: break\nelse: print(\"Possible\")",
"input() for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"input()",
"input",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"a = [input() for _ in range(h)]",
"a",
"[input() for _ in range(h)]",
"z = 0",
"z",
"0",
"for i in range(h):\n for j in range(w):\n if i == 0 and j == 0:\n if a[i+1][j] == \"#\" and a[i][j+1] == \"#\": print(\"Impossible\"); z = 1; break\n elif i == h-1 and j == w-1:\n if a[i-1][j] == \"#\" and a[i][j-1] == \"#\": print(\"Impossible\"); z = 1; break\n else:\n if a[i][j] == \"#\":\n x = y = 0\n if i != 0:\n if a[i-1][j] == \"#\": x += 1\n if j != 0:\n if a[i][j-1] == \"#\": x += 1\n if i != h-1:\n if a[i+1][j] == \"#\": y += 1\n if j != w-1:\n if a[i][j+1] == \"#\": y += 1\n if x != 1 or y != 1: print(\"Impossible\"); z = 1; break\n if z == 1: break\nelse: print(\"Possible\")",
"i",
"range(h)",
"range",
"h",
"for j in range(w):\n if i == 0 and j == 0:\n if a[i+1][j] == \"#\" and a[i][j+1] == \"#\": print(\"Impossible\"); z = 1; break\n elif i == h-1 and j == w-1:\n if a[i-1][j] == \"#\" and a[i][j-1] == \"#\": print(\"Impossible\"); z = 1; break\n else:\n if a[i][j] == \"#\":\n x = y = 0\n if i != 0:\n if a[i-1][j] == \"#\": x += 1\n if j != 0:\n if a[i][j-1] == \"#\": x += 1\n if i != h-1:\n if a[i+1][j] == \"#\": y += 1\n if j != w-1:\n if a[i][j+1] == \"#\": y += 1\n if x != 1 or y != 1: print(\"Impossible\"); z = 1; break\n ",
"j",
"range(w)",
"range",
"w",
"if i == 0 and j == 0:\n if a[i+1][j] == \"#\" and a[i][j+1] == \"#\": print(\"Impossible\"); z = 1; break\n elif i == h-1 and j == w-1:\n if a[i-1][j] == \"#\" and a[i][j-1] == \"#\": print(\"Impossible\"); z = 1; break\n else:\n if a[i][j] == \"#\":\n x = y = 0\n if i != 0:\n if a[i-1][j] == \"#\": x += 1\n if j != 0:\n if a[i][j-1] == \"#\": x += 1\n if i != h-1:\n if a[i+1][j] == \"#\": y += 1\n if j != w-1:\n if a[i][j+1] == \"#\": y += 1\n if x != 1 or y != 1: print(\"Impossible\"); z = 1; break\n ",
"i == 0 and j == 0",
"i == 0",
"i",
"0",
"j == 0",
"j",
"0",
"if a[i+1][j] == \"#\" and a[i][j+1] == \"#\": print(\"Impossible\"); z = 1; break\n ",
"a[i+1][j] == \"#\" and a[i][j+1] == \"#\"",
"a[i+1][j] == \"#\"",
"a[i+1][j]",
"[i+1]",
"a",
"i+1",
"i",
"1",
"j",
"\"#\"",
"a[i][j+1] == \"#\"",
"a[i][j+1]",
"[i]",
"a",
"i",
"j+1",
"j",
"1",
"\"#\"",
"elif i == h-1 and j == w-1:\n if a[i-1][j] == \"#\" and a[i][j-1] == \"#\": print(\"Impossible\"); z = 1; break\n ",
"i == h-1 and j == w-1",
"i == h-1",
"i",
"h-1",
"h",
"1",
"j == w-1",
"j",
"w-1",
"w",
"1",
"if a[i-1][j] == \"#\" and a[i][j-1] == \"#\": print(\"Impossible\"); z = 1; break\n ",
"a[i-1][j] == \"#\" and a[i][j-1] == \"#\"",
"a[i-1][j] == \"#\"",
"a[i-1][j]",
"[i-1]",
"a",
"i-1",
"i",
"1",
"j",
"\"#\"",
"a[i][j-1] == \"#\"",
"a[i][j-1]",
"[i]",
"a",
"i",
"j-1",
"j",
"1",
"\"#\"",
"if a[i][j] == \"#\":\n x = y = 0\n if i != 0:\n if a[i-1][j] == \"#\": x += 1\n if j != 0:\n if a[i][j-1] == \"#\": x += 1\n if i != h-1:\n if a[i+1][j] == \"#\": y += 1\n if j != w-1:\n if a[i][j+1] == \"#\": y += 1\n if x != 1 or y != 1: print(\"Impossible\"); z = 1; break\n ",
"a[i][j] == \"#\"",
"a[i][j]",
"[i]",
"a",
"i",
"j",
"\"#\"",
"x = y = 0",
"x",
"0",
"= y = 0",
"y",
"0",
"if i != 0:\n if a[i-1][j] == \"#\": x += 1\n ",
"i != 0",
"i",
"0",
"if a[i-1][j] == \"#\": x += 1\n ",
"a[i-1][j] == \"#\"",
"a[i-1][j]",
"[i-1]",
"a",
"i-1",
"i",
"1",
"j",
"\"#\"",
"if j != 0:\n if a[i][j-1] == \"#\": x += 1\n ",
"j != 0",
"j",
"0",
"if a[i][j-1] == \"#\": x += 1\n ",
"a[i][j-1] == \"#\"",
"a[i][j-1]",
"[i]",
"a",
"i",
"j-1",
"j",
"1",
"\"#\"",
"if i != h-1:\n if a[i+1][j] == \"#\": y += 1\n ",
"i != h-1",
"i",
"h-1",
"h",
"1",
"if a[i+1][j] == \"#\": y += 1\n ",
"a[i+1][j] == \"#\"",
"a[i+1][j]",
"[i+1]",
"a",
"i+1",
"i",
"1",
"j",
"\"#\"",
"if j != w-1:\n if a[i][j+1] == \"#\": y += 1\n ",
"j != w-1",
"j",
"w-1",
"w",
"1",
"if a[i][j+1] == \"#\": y += 1\n ",
"a[i][j+1] == \"#\"",
"a[i][j+1]",
"[i]",
"a",
"i",
"j+1",
"j",
"1",
"\"#\"",
"if x != 1 or y != 1: print(\"Impossible\"); z = 1; break\n ",
"x != 1 or y != 1",
"x != 1",
"x",
"1",
"y != 1",
"y",
"1",
"if z == 1: b",
"z == 1",
"z",
"1",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"z = 0",
"0",
"z",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h",
"a = [input() for _ in range(h)]",
"[input() for _ in range(h)]",
"a",
"y = 0",
"0",
"y",
"x = y = 0",
"0",
"x"
] |
h, w = map(int, input().split()); a = [input() for _ in range(h)]; z = 0
for i in range(h):
for j in range(w):
if i == 0 and j == 0:
if a[i+1][j] == "#" and a[i][j+1] == "#": print("Impossible"); z = 1; break
elif i == h-1 and j == w-1:
if a[i-1][j] == "#" and a[i][j-1] == "#": print("Impossible"); z = 1; break
else:
if a[i][j] == "#":
x = y = 0
if i != 0:
if a[i-1][j] == "#": x += 1
if j != 0:
if a[i][j-1] == "#": x += 1
if i != h-1:
if a[i+1][j] == "#": y += 1
if j != w-1:
if a[i][j+1] == "#": y += 1
if x != 1 or y != 1: print("Impossible"); z = 1; break
if z == 1: break
else: print("Possible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
18,
4,
13,
13,
17,
4,
13,
8,
2,
13,
2,
2,
13,
13,
17,
17,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13
] |
[
[
47,
2
],
[
47,
11
],
[
50,
13
],
[
17,
16
],
[
42,
19
],
[
44,
21
],
[
45,
32
],
[
51,
32
],
[
42,
35
],
[
48,
36
],
[
47,
42
],
[
44,
45
],
[
47,
48
],
[
50,
51
]
] |
[
"h, w = map(int, input().split())\nc = 0\nfor i in range(h):\n c += input().count('#')\nprint('Possible' if c==h+w-1 else 'Impossible')",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"c = 0",
"c",
"0",
"for i in range(h):\n c += input().count('#')",
"i",
"range(h)",
"range",
"h",
"c += input().count('#')",
"c",
"input().count('#')",
"().count",
"()",
"input",
"count",
"'#'",
"print('Possible' if c==h+w-1 else 'Impossible')",
"print",
"'Possible' if c==h+w-1 else 'Impossible'",
"c==h+w-1",
"c",
"h+w-1",
"h+w",
"h",
"w",
"1",
"'Possible'",
"'Impossible'",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h",
"c += input().count('#')",
"input().count('#')",
"c",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"c = 0",
"0",
"c"
] |
h, w = map(int, input().split())
c = 0
for i in range(h):
c += input().count('#')
print('Possible' if c==h+w-1 else 'Impossible')
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
28,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
18,
13,
13,
17,
0,
13,
4,
13,
13,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
76,
2
],
[
76,
11
],
[
70,
13
],
[
17,
16
],
[
74,
19
],
[
79,
21
],
[
28,
27
],
[
77,
30
],
[
43,
33
],
[
38,
33
],
[
80,
34
],
[
27,
35
],
[
41,
38
],
[
80,
39
],
[
27,
40
],
[
46,
43
],
[
80,
44
],
[
27,
45
],
[
67,
48
],
[
80,
51
],
[
68,
54
],
[
71,
54
],
[
77,
57
],
[
74,
58
],
[
67,
68
],
[
70,
71
],
[
76,
74
],
[
76,
77
],
[
79,
80
]
] |
[
"h, w = map(int, input().split())\n\ncount = 0\nfor i in range(h):\n a = list(input())\n for j in range(w):\n if a[j] == '#':\n a[j] = 1\n else:\n a[j] = 0\n count += sum(a)\n \nif count == w + h - 1:\n print('Possible')\nelse:\n print('Impossible')",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"count = 0",
"count",
"0",
"for i in range(h):\n a = list(input())\n for j in range(w):\n if a[j] == '#':\n a[j] = 1\n else:\n a[j] = 0\n count += sum(a)\n ",
"i",
"range(h)",
"range",
"h",
"a = list(input())",
"a",
"list(input())",
"list",
"input()",
"input",
"for j in range(w):\n if a[j] == '#':\n a[j] = 1\n else:\n a[j] = 0\n ",
"j",
"range(w)",
"range",
"w",
"if a[j] == '#':\n a[j] = 1\n else:\n a[j] = 0\n ",
"a[j] == '#'",
"a[j]",
"a",
"j",
"'#'",
"a[j] = 1",
"a[j]",
"a",
"j",
"1",
"a[j] = 0",
"a[j]",
"a",
"j",
"0",
"count += sum(a)",
"count",
"sum(a)",
"sum",
"a",
"if count == w + h - 1:\n print('Possible')\nelse:\n print('Impossible')",
"count == w + h - 1",
"count",
"w + h - 1",
"w + h",
"w",
"h",
"1",
"print('Possible')",
"print",
"'Possible'",
"print('Impossible')",
"print",
"'Impossible'",
"count += sum(a)",
"sum(a)",
"count",
"count = 0",
"0",
"count",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"a = list(input())",
"list(input())",
"a"
] |
h, w = map(int, input().split())
count = 0
for i in range(h):
a = list(input())
for j in range(w):
if a[j] == '#':
a[j] = 1
else:
a[j] = 0
count += sum(a)
if count == w + h - 1:
print('Possible')
else:
print('Impossible')
|
[
7,
15,
13,
15,
13,
15,
13,
15,
13,
15,
15,
15,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
23,
13,
23,
13,
12,
13,
23,
4,
18,
13,
13,
2,
17,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
17,
0,
13,
17,
0,
13,
4,
13,
17,
0,
13,
4,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
0,
13,
4,
18,
13,
13,
17,
0,
13,
2,
2,
13,
13,
17,
4,
13,
8,
2,
13,
13,
17,
17,
10,
12,
13,
10,
4,
13,
10,
4,
13,
10,
12,
13,
10,
39,
13,
10,
17,
13,
10,
12,
13,
10,
4,
13,
10,
12,
13,
10,
12,
13,
10,
2,
13,
10,
4,
13,
10,
12,
13,
10,
12,
13,
10,
4,
13,
10,
17,
13,
10,
12,
13,
10,
2,
13,
10,
12,
13
] |
[
[
29,
29
],
[
31,
31
],
[
130,
43
],
[
115,
50
],
[
145,
53
],
[
103,
56
],
[
133,
61
],
[
137,
63
],
[
133,
64
],
[
112,
66
],
[
70,
69
],
[
134,
72
],
[
142,
74
],
[
128,
76
],
[
121,
78
],
[
143,
81
],
[
116,
82
],
[
122,
82
],
[
151,
85
],
[
134,
88
],
[
107,
89
],
[
152,
95
],
[
122,
96
],
[
116,
96
],
[
103,
104
],
[
133,
107
],
[
112,
113
],
[
115,
116
],
[
121,
122
],
[
130,
131
],
[
133,
134
],
[
142,
143
],
[
145,
146
],
[
151,
152
]
] |
[
"import sys\nimport math\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\ndef s(): return input()\ndef k(): return int(input())\ndef S(): return input().split()\ndef I(): return map(int,input().split())\ndef X(): return list(input())\ndef L(): return list(input().split())\ndef l(): return list(map(int,input().split()))\ndef lcm(a,b): return a*b//math.gcd(a,b)\ndef gcd(*numbers): reduce(math.gcd, numbers)\nsys.setrecursionlimit(10 ** 9)\nmod = 10**9+7\ncount = 0\nans = 0\ninf = float(\"inf\")\n\nH,W = I()\nboa = []\nfor i in range(H):\n x = X()\n count += x.count(\"#\")\n\na = H+W-1\nprint(\"Possible\" if a == count else \"Impossible\")",
"import sys",
"sys",
"import math",
"math",
"import itertools",
"itertools",
"import bisect",
"bisect",
"from copy import copy",
"from collections import deque,Counter",
"from decimal import Decimal",
"def s(): return input()",
"s",
"def k(): return int(input())",
"k",
"def S(): return input().split()",
"S",
"def I(): return map(int,input().split())",
"I",
"def X(): return list(input())",
"X",
"def L(): return list(input().split())",
"L",
"def l(): return list(map(int,input().split()))",
"l",
"def lcm(a,b): return a*b//math.gcd(a,b)",
"lcm",
"a",
"a",
"b",
"b",
"def gcd(*numbers): reduce(math.gcd, numbers)",
"gcd",
"*numbers",
"sys.setrecursionlimit(10 ** 9)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 9",
"10",
"9",
"mod = 10**9+7",
"mod",
"10**9+7",
"10**9",
"10",
"9",
"7",
"count = 0",
"count",
"0",
"ans = 0",
"ans",
"0",
"inf = float(\"inf\")",
"inf",
"float(\"inf\")",
"float",
"\"inf\"",
"H,W = I()",
"H",
"I()",
"I",
"W",
"boa = []",
"boa",
"[]",
"for i in range(H):\n x = X()\n count += x.count(\"#\")",
"i",
"range(H)",
"range",
"H",
"x = X()",
"x",
"X()",
"X",
"count += x.count(\"#\")",
"count",
"x.count(\"#\")",
"x.count",
"x",
"count",
"\"#\"",
"a = H+W-1",
"a",
"H+W-1",
"H+W",
"H",
"W",
"1",
"print(\"Possible\" if a == count else \"Impossible\")",
"print",
"\"Possible\" if a == count else \"Impossible\"",
"a == count",
"a",
"count",
"\"Possible\"",
"\"Impossible\"",
"def lcm(a,b): return a*b//math.gcd(a,b)",
"def lcm(a,b): return a*b//math.gcd(a,b)",
"lcm",
"inf = float(\"inf\")",
"float(\"inf\")",
"inf",
"W = I()",
"I()",
"W",
"def L(): return list(input().split())",
"def L(): return list(input().split())",
"L",
"boa = []",
"[]",
"boa",
"count = 0",
"0",
"count",
"def S(): return input().split()",
"def S(): return input().split()",
"S",
"count += x.count(\"#\")",
"x.count(\"#\")",
"count",
"def gcd(*numbers): reduce(math.gcd, numbers)",
"def gcd(*numbers): reduce(math.gcd, numbers)",
"gcd",
"def X(): return list(input())",
"def X(): return list(input())",
"X",
"mod = 10**9+7",
"10**9+7",
"mod",
"H,W = I()",
"I()",
"H",
"def I(): return map(int,input().split())",
"def I(): return map(int,input().split())",
"I",
"def k(): return int(input())",
"def k(): return int(input())",
"k",
"x = X()",
"X()",
"x",
"ans = 0",
"0",
"ans",
"def s(): return input()",
"def s(): return input()",
"s",
"a = H+W-1",
"H+W-1",
"a",
"def l(): return list(map(int,input().split()))",
"def l(): return list(map(int,input().split()))",
"l"
] |
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")
H,W = I()
boa = []
for i in range(H):
x = X()
count += x.count("#")
a = H+W-1
print("Possible" if a == count else "Impossible")
|
[
7,
12,
13,
14,
40,
18,
18,
13,
13,
13,
13,
29,
17,
14,
2,
2,
13,
2,
13,
17,
2,
13,
2,
13,
17,
29,
17,
0,
13,
17,
14,
2,
2,
13,
17,
13,
0,
13,
2,
18,
18,
13,
2,
13,
17,
13,
13,
14,
2,
2,
13,
17,
13,
0,
13,
2,
18,
18,
13,
13,
2,
13,
17,
13,
14,
40,
13,
17,
29,
17,
14,
2,
2,
13,
17,
2,
13,
17,
29,
17,
0,
13,
17,
14,
40,
2,
13,
17,
17,
0,
13,
2,
18,
18,
13,
2,
13,
17,
13,
13,
14,
40,
2,
13,
17,
17,
0,
13,
2,
18,
18,
13,
13,
2,
13,
17,
13,
14,
2,
13,
17,
29,
17,
29,
17,
23,
13,
23,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
40,
4,
13,
13,
13,
4,
13,
17,
4,
13,
4,
13,
17,
10,
17,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
12,
13
] |
[
[
126,
8
],
[
128,
9
],
[
126,
16
],
[
128,
21
],
[
29,
28
],
[
126,
33
],
[
38,
37
],
[
126,
43
],
[
128,
45
],
[
128,
50
],
[
55,
54
],
[
126,
59
],
[
128,
61
],
[
54,
66
],
[
37,
66
],
[
28,
66
],
[
126,
73
],
[
128,
76
],
[
82,
81
],
[
126,
86
],
[
91,
90
],
[
126,
96
],
[
128,
98
],
[
128,
103
],
[
108,
107
],
[
126,
112
],
[
128,
114
],
[
107,
119
],
[
90,
119
],
[
81,
119
],
[
54,
119
],
[
37,
119
],
[
28,
119
],
[
126,
126
],
[
128,
128
],
[
193,
130
],
[
193,
141
],
[
145,
144
],
[
188,
147
],
[
190,
154
],
[
184,
157
],
[
161,
160
],
[
188,
163
],
[
166,
165
],
[
194,
168
],
[
197,
172
],
[
160,
173
],
[
165,
174
],
[
184,
185
],
[
193,
188
],
[
190,
191
],
[
193,
194
]
] |
[
"def check(h, w):\n if A[h][w] != r:\n return True\n if h == H - 1 and w == W - 1:\n return True\n cnt = 0\n if h + 1 < H:\n cnt += A[h + 1][w] == r\n if w + 1 < W:\n cnt += A[h][w + 1] == r\n if cnt != 1:\n return False\n if h == 0 and w == 0:\n return True\n cnt = 0\n if h - 1 >= 0:\n cnt += A[h - 1][w] == r\n if w - 1 >= 0:\n cnt += A[h][w - 1] == r\n if cnt == 0:\n return False\n return True\n\nH, W = list(map(int, input().split()))\nA = [list(input()) for _ in range(H)]\nr = \"#\"\n\nfor i in range(H):\n for j in range(W):\n if not check(i, j):\n print(\"Impossible\")\n exit()\n\nprint(\"Possible\")",
"def check(h, w):\n if A[h][w] != r:\n return True\n if h == H - 1 and w == W - 1:\n return True\n cnt = 0\n if h + 1 < H:\n cnt += A[h + 1][w] == r\n if w + 1 < W:\n cnt += A[h][w + 1] == r\n if cnt != 1:\n return False\n if h == 0 and w == 0:\n return True\n cnt = 0\n if h - 1 >= 0:\n cnt += A[h - 1][w] == r\n if w - 1 >= 0:\n cnt += A[h][w - 1] == r\n if cnt == 0:\n return False\n return True",
"check",
"if A[h][w] != r:\n return True\n ",
"A[h][w] != r",
"A[h][w]",
"[h]",
"A",
"h",
"w",
"r",
"return True",
"True",
"if h == H - 1 and w == W - 1:\n return True\n ",
"h == H - 1 and w == W - 1",
"h == H - 1",
"h",
"H - 1",
"H",
"1",
"w == W - 1",
"w",
"W - 1",
"W",
"1",
"return True",
"True",
"cnt = 0",
"cnt",
"0",
"if h + 1 < H:\n cnt += A[h + 1][w] == r\n ",
"h + 1 < H",
"h + 1",
"h",
"1",
"H",
"cnt += A[h + 1][w] == r",
"cnt",
"A[h + 1][w] == r",
"A[h + 1][w]",
"[h + 1]",
"A",
"h + 1",
"h",
"1",
"w",
"r",
"if w + 1 < W:\n cnt += A[h][w + 1] == r\n ",
"w + 1 < W",
"w + 1",
"w",
"1",
"W",
"cnt += A[h][w + 1] == r",
"cnt",
"A[h][w + 1] == r",
"A[h][w + 1]",
"[h]",
"A",
"h",
"w + 1",
"w",
"1",
"r",
"if cnt != 1:\n return False\n ",
"cnt != 1",
"cnt",
"1",
"return False",
"False",
"if h == 0 and w == 0:\n return True\n ",
"h == 0 and w == 0",
"h == 0",
"h",
"0",
"w == 0",
"w",
"0",
"return True",
"True",
"cnt = 0",
"cnt",
"0",
"if h - 1 >= 0:\n cnt += A[h - 1][w] == r\n ",
"h - 1 >= 0",
"h - 1",
"h",
"1",
"0",
"cnt += A[h - 1][w] == r",
"cnt",
"A[h - 1][w] == r",
"A[h - 1][w]",
"[h - 1]",
"A",
"h - 1",
"h",
"1",
"w",
"r",
"if w - 1 >= 0:\n cnt += A[h][w - 1] == r\n ",
"w - 1 >= 0",
"w - 1",
"w",
"1",
"0",
"cnt += A[h][w - 1] == r",
"cnt",
"A[h][w - 1] == r",
"A[h][w - 1]",
"[h]",
"A",
"h",
"w - 1",
"w",
"1",
"r",
"if cnt == 0:\n return False\n ",
"cnt == 0",
"cnt",
"0",
"return False",
"False",
"return True",
"True",
"h",
"h",
"w",
"w",
"H, W = list(map(int, input().split()))",
"H",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"list(input()) for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"list(input())",
"list",
"input()",
"input",
"A = [list(input()) for _ in range(H)]",
"A",
"[list(input()) for _ in range(H)]",
"r = \"#\"",
"r",
"\"#\"",
"for i in range(H):\n for j in range(W):\n if not check(i, j):\n print(\"Impossible\")\n exit()",
"i",
"range(H)",
"range",
"H",
"for j in range(W):\n if not check(i, j):\n print(\"Impossible\")\n exit()",
"j",
"range(W)",
"range",
"W",
"if not check(i, j):\n print(\"Impossible\")\n exit()",
"not check(i, j)",
"check(i, j)",
"check",
"i",
"j",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"exit()",
"exit",
"print(\"Possible\")",
"print",
"\"Possible\"",
"r = \"#\"",
"\"#\"",
"r",
"H, W = list(map(int, input().split()))",
"list(map(int, input().split()))",
"H",
"A = [list(input()) for _ in range(H)]",
"[list(input()) for _ in range(H)]",
"A",
"W = list(map(int, input().split()))",
"list(map(int, input().split()))",
"W",
"def check(h, w):\n if A[h][w] != r:\n return True\n if h == H - 1 and w == W - 1:\n return True\n cnt = 0\n if h + 1 < H:\n cnt += A[h + 1][w] == r\n if w + 1 < W:\n cnt += A[h][w + 1] == r\n if cnt != 1:\n return False\n if h == 0 and w == 0:\n return True\n cnt = 0\n if h - 1 >= 0:\n cnt += A[h - 1][w] == r\n if w - 1 >= 0:\n cnt += A[h][w - 1] == r\n if cnt == 0:\n return False\n return True",
"def check(h, w):\n if A[h][w] != r:\n return True\n if h == H - 1 and w == W - 1:\n return True\n cnt = 0\n if h + 1 < H:\n cnt += A[h + 1][w] == r\n if w + 1 < W:\n cnt += A[h][w + 1] == r\n if cnt != 1:\n return False\n if h == 0 and w == 0:\n return True\n cnt = 0\n if h - 1 >= 0:\n cnt += A[h - 1][w] == r\n if w - 1 >= 0:\n cnt += A[h][w - 1] == r\n if cnt == 0:\n return False\n return True",
"check"
] |
def check(h, w):
if A[h][w] != r:
return True
if h == H - 1 and w == W - 1:
return True
cnt = 0
if h + 1 < H:
cnt += A[h + 1][w] == r
if w + 1 < W:
cnt += A[h][w + 1] == r
if cnt != 1:
return False
if h == 0 and w == 0:
return True
cnt = 0
if h - 1 >= 0:
cnt += A[h - 1][w] == r
if w - 1 >= 0:
cnt += A[h][w - 1] == r
if cnt == 0:
return False
return True
H, W = list(map(int, input().split()))
A = [list(input()) for _ in range(H)]
r = "#"
for i in range(H):
for j in range(W):
if not check(i, j):
print("Impossible")
exit()
print("Possible")
|
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
4,
18,
4,
13,
13,
0,
13,
4,
18,
13,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
14,
2,
13,
17,
4,
13,
10,
18,
13,
10,
12,
13
] |
[
[
68,
4
],
[
14,
13
],
[
69,
20
],
[
14,
22
],
[
25,
24
],
[
28,
27
],
[
13,
30
],
[
33,
32
],
[
69,
38
],
[
42,
41
],
[
32,
44
],
[
24,
45
],
[
41,
45
],
[
41,
49
],
[
24,
49
],
[
13,
52
],
[
22,
53
],
[
72,
66
],
[
68,
69
]
] |
[
"import sys\ninput = sys.stdin.readline\n\ndef main():\n H, W = map(int, input().split())\n count = 0\n for _ in range(H):\n for row in list(input().rstrip()):\n count += row.count(\"#\")\n if count == H + W - 1:\n print(\"Possible\")\n else:\n print(\"Impossible\")\n\nif __name__ == '__main__':\n main()",
"import sys",
"sys",
"input = sys.stdin.readline",
"input",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"def main():\n H, W = map(int, input().split())\n count = 0\n for _ in range(H):\n for row in list(input().rstrip()):\n count += row.count(\"#\")\n if count == H + W - 1:\n print(\"Possible\")\n else:\n print(\"Impossible\")",
"main",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"count = 0",
"count",
"0",
"for _ in range(H):\n for row in list(input().rstrip()):\n count += row.count(\"#\")\n ",
"_",
"range(H)",
"range",
"H",
"for row in list(input().rstrip()):\n count += row.count(\"#\")\n ",
"row",
"list(input().rstrip())",
"list",
"input().rstrip()",
"().rstrip",
"()",
"input",
"rstrip",
"count += row.count(\"#\")",
"count",
"row.count(\"#\")",
"row.count",
"row",
"count",
"\"#\"",
"if count == H + W - 1:\n print(\"Possible\")\n else:\n print(\"Impossible\")",
"count == H + W - 1",
"count",
"H + W - 1",
"H + W",
"H",
"W",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"input = sys.stdin.readline",
"sys.stdin.readline",
"input",
"def main():\n H, W = map(int, input().split())\n count = 0\n for _ in range(H):\n for row in list(input().rstrip()):\n count += row.count(\"#\")\n if count == H + W - 1:\n print(\"Possible\")\n else:\n print(\"Impossible\")",
"def main():\n H, W = map(int, input().split())\n count = 0\n for _ in range(H):\n for row in list(input().rstrip()):\n count += row.count(\"#\")\n if count == H + W - 1:\n print(\"Possible\")\n else:\n print(\"Impossible\")",
"main"
] |
import sys
input = sys.stdin.readline
def main():
H, W = map(int, input().split())
count = 0
for _ in range(H):
for row in list(input().rstrip()):
count += row.count("#")
if count == H + W - 1:
print("Possible")
else:
print("Impossible")
if __name__ == '__main__':
main()
|
[
7,
41,
28,
13,
4,
13,
13,
4,
4,
18,
4,
13,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
4,
13,
8,
2,
4,
13,
13,
2,
2,
13,
13,
17,
17,
17,
10,
4,
13,
10,
4,
13
] |
[
[
4,
3
],
[
43,
15
],
[
43,
24
],
[
41,
34
],
[
44,
35
],
[
43,
41
],
[
43,
44
]
] |
[
"h,w=map(int,input().split());print(\"Possible\" if sum([input().count(\"#\") for _ in range(h)])==w+h-1 else \"Impossible\")",
"input().count(\"#\") for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"input().count(\"#\")",
"().count",
"()",
"input",
"count",
"\"#\"",
"h,w=map(int,input().split())",
"h",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"print(\"Possible\" if sum([input().count(\"#\") for _ in range(h)])==w+h-1 else \"Impossible\")",
"print",
"\"Possible\" if sum([input().count(\"#\") for _ in range(h)])==w+h-1 else \"Impossible\"",
"sum([input().count(\"#\") for _ in range(h)])==w+h-1",
"sum([input().count(\"#\") for _ in range(h)])",
"sum",
"[input().count(\"#\") for _ in range(h)]",
"w+h-1",
"w+h",
"w",
"h",
"1",
"\"Possible\"",
"\"Impossible\"",
"w=map(int,input().split())",
"map(int,input().split())",
"w",
"h,w=map(int,input().split())",
"map(int,input().split())",
"h"
] |
h,w=map(int,input().split());print("Possible" if sum([input().count("#") for _ in range(h)])==w+h-1 else "Impossible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
17,
0,
13,
39,
13,
41,
28,
13,
4,
13,
13,
4,
2,
2,
39,
17,
4,
13,
4,
13,
39,
17,
0,
13,
13,
0,
13,
2,
2,
13,
13,
13,
12,
13,
14,
2,
13,
17,
0,
13,
13,
0,
13,
2,
13,
17,
14,
2,
13,
17,
0,
13,
2,
13,
17,
0,
13,
13,
0,
13,
18,
18,
13,
2,
13,
17,
13,
0,
13,
18,
18,
13,
2,
13,
17,
13,
0,
13,
18,
18,
13,
13,
2,
13,
17,
0,
13,
18,
18,
13,
13,
2,
13,
17,
14,
2,
2,
13,
13,
2,
13,
13,
14,
2,
2,
13,
13,
17,
29,
17,
29,
17,
14,
2,
2,
2,
2,
13,
13,
17,
2,
2,
13,
17,
2,
13,
17,
2,
2,
13,
17,
2,
13,
17,
29,
17,
14,
2,
13,
17,
29,
4,
13,
13,
13,
17,
14,
2,
13,
17,
29,
4,
13,
13,
13,
17,
23,
13,
23,
13,
23,
13,
0,
13,
4,
13,
17,
17,
17,
14,
2,
13,
17,
4,
13,
17,
4,
13,
17,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
39,
13,
10,
2,
13,
10,
12,
13
] |
[
[
210,
2
],
[
210,
11
],
[
15,
14
],
[
211,
18
],
[
213,
23
],
[
29,
28
],
[
208,
31
],
[
201,
44
],
[
216,
47
],
[
214,
50
],
[
202,
51
],
[
214,
52
],
[
182,
57
],
[
61,
60
],
[
178,
61
],
[
64,
63
],
[
180,
65
],
[
182,
69
],
[
73,
72
],
[
178,
74
],
[
78,
77
],
[
180,
78
],
[
81,
80
],
[
217,
83
],
[
72,
85
],
[
60,
85
],
[
77,
87
],
[
63,
87
],
[
90,
89
],
[
217,
92
],
[
72,
94
],
[
60,
94
],
[
77,
96
],
[
63,
96
],
[
99,
98
],
[
217,
101
],
[
72,
102
],
[
60,
102
],
[
77,
104
],
[
63,
104
],
[
108,
107
],
[
217,
110
],
[
72,
111
],
[
60,
111
],
[
77,
113
],
[
63,
113
],
[
72,
118
],
[
60,
118
],
[
208,
119
],
[
77,
121
],
[
63,
121
],
[
211,
122
],
[
80,
126
],
[
107,
127
],
[
89,
138
],
[
98,
139
],
[
182,
143
],
[
80,
146
],
[
182,
150
],
[
107,
153
],
[
89,
159
],
[
72,
164
],
[
60,
164
],
[
77,
165
],
[
63,
165
],
[
98,
169
],
[
72,
174
],
[
60,
174
],
[
77,
175
],
[
63,
175
],
[
178,
178
],
[
180,
180
],
[
182,
182
],
[
204,
184
],
[
220,
186
],
[
205,
192
],
[
201,
202
],
[
204,
205
],
[
210,
208
],
[
210,
211
],
[
213,
214
],
[
216,
217
]
] |
[
"H,W = map(int, input().split())\n\nedge = [[\".\" for _ in range(W+2)]]\ncenter = [[\".\"] + list(input()) + [\".\"] for i in range(H)]\nA_array = edge + center + edge\n\ndef is_there_OK_move(before_i,before_j,before_move):\n if before_move == \"right\":\n i = before_i\n j = before_j + 1\n elif before_move == \"down\":\n i = before_i + 1\n j = before_j\n\n up = A_array[i-1][j]\n down = A_array[i+1][j]\n right = A_array[i][j+1]\n left = A_array[i][j-1]\n \n if i == H and j == W:\n if up == left == \"#\":\n return -1\n else:\n return 1\n elif (down == right == \"#\") or (before_move == \"right\" and up == \"#\") or (before_move == \"down\" and left == \"#\"):\n return -1\n else:\n if down == \"#\":\n return is_there_OK_move(i,j,\"down\")\n elif right == \"#\":\n return is_there_OK_move(i,j,\"right\")\n\n\nans = is_there_OK_move(0,1,\"down\")\n\nif ans == 1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"H,W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"\".\" for _ in range(W+2)",
"for _ in range(W+2)",
"_",
"range(W+2)",
"range",
"W+2",
"W",
"2",
"for _ in range(W+2)",
"\".\"",
"edge = [[\".\" for _ in range(W+2)]]",
"edge",
"[[\".\" for _ in range(W+2)]]",
"[\".\" for _ in range(W+2)]",
"[\".\"] + list(input()) + [\".\"] for i in range(H)",
"for i in range(H)",
"i",
"range(H)",
"range",
"H",
"for i in range(H)",
"[\".\"] + list(input()) + [\".\"]",
"[\".\"] + list(input())",
"[\".\"]",
"\".\"",
"list(input())",
"list",
"input()",
"input",
"[\".\"]",
"\".\"",
"center = [[\".\"] + list(input()) + [\".\"] for i in range(H)]",
"center",
"[[\".\"] + list(input()) + [\".\"] for i in range(H)]",
"A_array = edge + center + edge",
"A_array",
"edge + center + edge",
"edge + center",
"edge",
"center",
"edge",
"def is_there_OK_move(before_i,before_j,before_move):\n if before_move == \"right\":\n i = before_i\n j = before_j + 1\n elif before_move == \"down\":\n i = before_i + 1\n j = before_j\n\n up = A_array[i-1][j]\n down = A_array[i+1][j]\n right = A_array[i][j+1]\n left = A_array[i][j-1]\n \n if i == H and j == W:\n if up == left == \"#\":\n return -1\n else:\n return 1\n elif (down == right == \"#\") or (before_move == \"right\" and up == \"#\") or (before_move == \"down\" and left == \"#\"):\n return -1\n else:\n if down == \"#\":\n return is_there_OK_move(i,j,\"down\")\n elif right == \"#\":\n return is_there_OK_move(i,j,\"right\")",
"is_there_OK_move",
"if before_move == \"right\":\n i = before_i\n j = before_j + 1\n elif before_move == \"down\":\n i = before_i + 1\n j = before_j\n\n ",
"before_move == \"right\"",
"before_move",
"\"right\"",
"i = before_i",
"i",
"before_i",
"j = before_j + 1",
"j",
"before_j + 1",
"before_j",
"1",
"elif before_move == \"down\":\n i = before_i + 1\n j = before_j\n\n ",
"before_move == \"down\"",
"before_move",
"\"down\"",
"i = before_i + 1",
"i",
"before_i + 1",
"before_i",
"1",
"j = before_j",
"j",
"before_j",
"up = A_array[i-1][j]",
"up",
"A_array[i-1][j]",
"[i-1]",
"A_array",
"i-1",
"i",
"1",
"j",
"down = A_array[i+1][j]",
"down",
"A_array[i+1][j]",
"[i+1]",
"A_array",
"i+1",
"i",
"1",
"j",
"right = A_array[i][j+1]",
"right",
"A_array[i][j+1]",
"[i]",
"A_array",
"i",
"j+1",
"j",
"1",
"left = A_array[i][j-1]",
"left",
"A_array[i][j-1]",
"[i]",
"A_array",
"i",
"j-1",
"j",
"1",
"if i == H and j == W:\n if up == left == \"#\":\n return -1\n else:\n return 1\n elif (down == right == \"#\") or (before_move == \"right\" and up == \"#\") or (before_move == \"down\" and left == \"#\"):\n return -1\n else:\n if down == \"#\":\n return is_there_OK_move(i,j,\"down\")\n elif right == \"#\":\n return is_there_OK_move(i,j,\"right\")",
"i == H and j == W",
"i == H",
"i",
"H",
"j == W",
"j",
"W",
"if up == left == \"#\":\n return -1\n else:\n return 1\n ",
"up == left == \"#\"",
"up == left",
"up",
"left",
"\"#\"",
"return -1",
"-1",
"return 1",
"1",
"elif (down == right == \"#\") or (before_move == \"right\" and up == \"#\") or (before_move == \"down\" and left == \"#\"):\n return -1\n ",
"(down == right == \"#\") or (before_move == \"right\" and up == \"#\") or (before_move == \"down\" and left == \"#\")",
"(down == right == \"#\") or (before_move == \"right\" and up == \"#\")",
"down == right == \"#\"",
"down == right",
"down",
"right",
"\"#\"",
"before_move == \"right\" and up == \"#\"",
"before_move == \"right\"",
"before_move",
"\"right\"",
"up == \"#\"",
"up",
"\"#\"",
"before_move == \"down\" and left == \"#\"",
"before_move == \"down\"",
"before_move",
"\"down\"",
"left == \"#\"",
"left",
"\"#\"",
"return -1",
"-1",
"if down == \"#\":\n return is_there_OK_move(i,j,\"down\")\n elif right == \"#\":\n return is_there_OK_move(i,j,\"right\")",
"down == \"#\"",
"down",
"\"#\"",
"return is_there_OK_move(i,j,\"down\")",
"is_there_OK_move(i,j,\"down\")",
"is_there_OK_move",
"i",
"j",
"\"down\"",
"elif right == \"#\":\n return is_there_OK_move(i,j,\"right\")",
"right == \"#\"",
"right",
"\"#\"",
"return is_there_OK_move(i,j,\"right\")",
"is_there_OK_move(i,j,\"right\")",
"is_there_OK_move",
"i",
"j",
"\"right\"",
"before_i",
"before_i",
"before_j",
"before_j",
"before_move",
"before_move",
"ans = is_there_OK_move(0,1,\"down\")",
"ans",
"is_there_OK_move(0,1,\"down\")",
"is_there_OK_move",
"0",
"1",
"\"down\"",
"if ans == 1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"ans == 1",
"ans",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"center = [[\".\"] + list(input()) + [\".\"] for i in range(H)]",
"[[\".\"] + list(input()) + [\".\"] for i in range(H)]",
"center",
"ans = is_there_OK_move(0,1,\"down\")",
"is_there_OK_move(0,1,\"down\")",
"ans",
"H,W = map(int, input().split())",
"map(int, input().split())",
"H",
"W = map(int, input().split())",
"map(int, input().split())",
"W",
"edge = [[\".\" for _ in range(W+2)]]",
"[[\".\" for _ in range(W+2)]]",
"edge",
"A_array = edge + center + edge",
"edge + center + edge",
"A_array",
"def is_there_OK_move(before_i,before_j,before_move):\n if before_move == \"right\":\n i = before_i\n j = before_j + 1\n elif before_move == \"down\":\n i = before_i + 1\n j = before_j\n\n up = A_array[i-1][j]\n down = A_array[i+1][j]\n right = A_array[i][j+1]\n left = A_array[i][j-1]\n \n if i == H and j == W:\n if up == left == \"#\":\n return -1\n else:\n return 1\n elif (down == right == \"#\") or (before_move == \"right\" and up == \"#\") or (before_move == \"down\" and left == \"#\"):\n return -1\n else:\n if down == \"#\":\n return is_there_OK_move(i,j,\"down\")\n elif right == \"#\":\n return is_there_OK_move(i,j,\"right\")",
"def is_there_OK_move(before_i,before_j,before_move):\n if before_move == \"right\":\n i = before_i\n j = before_j + 1\n elif before_move == \"down\":\n i = before_i + 1\n j = before_j\n\n up = A_array[i-1][j]\n down = A_array[i+1][j]\n right = A_array[i][j+1]\n left = A_array[i][j-1]\n \n if i == H and j == W:\n if up == left == \"#\":\n return -1\n else:\n return 1\n elif (down == right == \"#\") or (before_move == \"right\" and up == \"#\") or (before_move == \"down\" and left == \"#\"):\n return -1\n else:\n if down == \"#\":\n return is_there_OK_move(i,j,\"down\")\n elif right == \"#\":\n return is_there_OK_move(i,j,\"right\")",
"is_there_OK_move"
] |
H,W = map(int, input().split())
edge = [["." for _ in range(W+2)]]
center = [["."] + list(input()) + ["."] for i in range(H)]
A_array = edge + center + edge
def is_there_OK_move(before_i,before_j,before_move):
if before_move == "right":
i = before_i
j = before_j + 1
elif before_move == "down":
i = before_i + 1
j = before_j
up = A_array[i-1][j]
down = A_array[i+1][j]
right = A_array[i][j+1]
left = A_array[i][j-1]
if i == H and j == W:
if up == left == "#":
return -1
else:
return 1
elif (down == right == "#") or (before_move == "right" and up == "#") or (before_move == "down" and left == "#"):
return -1
else:
if down == "#":
return is_there_OK_move(i,j,"down")
elif right == "#":
return is_there_OK_move(i,j,"right")
ans = is_there_OK_move(0,1,"down")
if ans == 1:
print("Possible")
else:
print("Impossible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
0,
13,
17,
42,
2,
13,
13,
0,
13,
17,
42,
2,
13,
13,
14,
2,
2,
18,
18,
13,
13,
2,
13,
17,
17,
2,
18,
18,
13,
2,
13,
17,
13,
17,
0,
13,
17,
0,
13,
17,
0,
13,
17,
4,
13,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
13,
13,
10,
4,
13
] |
[
[
98,
2
],
[
98,
11
],
[
15,
14
],
[
87,
17
],
[
95,
22
],
[
83,
25
],
[
77,
28
],
[
78,
32
],
[
90,
32
],
[
87,
33
],
[
80,
35
],
[
81,
39
],
[
75,
39
],
[
99,
40
],
[
96,
46
],
[
78,
47
],
[
90,
47
],
[
81,
49
],
[
75,
49
],
[
96,
55
],
[
78,
57
],
[
90,
57
],
[
81,
59
],
[
75,
59
],
[
92,
62
],
[
74,
65
],
[
89,
68
],
[
93,
72
],
[
84,
72
],
[
74,
75
],
[
77,
78
],
[
80,
81
],
[
83,
84
],
[
98,
87
],
[
89,
90
],
[
92,
93
],
[
95,
96
],
[
98,
99
]
] |
[
"H,W=map(int,input().split())\nA=[input() for _ in range(H)]\n\nans='Possible'\ni=1\nwhile i<H:\n j=1\n while j<W:\n if A[i][j-1]=='#' and A[i-1][j]=='#':\n ans='Impossible'\n j+=1\n i+=1\n\nprint(ans)",
"H,W=map(int,input().split())",
"H",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"input() for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"input()",
"input",
"A=[input() for _ in range(H)]",
"A",
"[input() for _ in range(H)]",
"ans='Possible'",
"ans",
"'Possible'",
"i=1",
"i",
"1",
"while i<H:\n j=1\n while j<W:\n if A[i][j-1]=='#' and A[i-1][j]=='#':\n ans='Impossible'\n j+=1\n i+=1",
"i<H",
"i",
"H",
"j=1",
"j",
"1",
"while j<W:\n if A[i][j-1]=='#' and A[i-1][j]=='#':\n ans='Impossible'\n j+=1\n ",
"j<W",
"j",
"W",
"if A[i][j-1]=='#' and A[i-1][j]=='#':\n ans='Impossible'\n ",
"A[i][j-1]=='#' and A[i-1][j]=='#'",
"A[i][j-1]=='#'",
"A[i][j-1]",
"[i]",
"A",
"i",
"j-1",
"j",
"1",
"'#'",
"A[i-1][j]=='#'",
"A[i-1][j]",
"[i-1]",
"A",
"i-1",
"i",
"1",
"j",
"'#'",
"ans='Impossible'",
"ans",
"'Impossible'",
"j+=1",
"j",
"1",
"i+=1",
"i",
"1",
"print(ans)",
"print",
"ans",
"j+=1",
"1",
"j",
"i=1",
"1",
"i",
"j=1",
"1",
"j",
"ans='Possible'",
"'Possible'",
"ans",
"H,W=map(int,input().split())",
"map(int,input().split())",
"H",
"i+=1",
"1",
"i",
"ans='Impossible'",
"'Impossible'",
"ans",
"A=[input() for _ in range(H)]",
"[input() for _ in range(H)]",
"A",
"W=map(int,input().split())",
"map(int,input().split())",
"W"
] |
H,W=map(int,input().split())
A=[input() for _ in range(H)]
ans='Possible'
i=1
while i<H:
j=1
while j<W:
if A[i][j-1]=='#' and A[i-1][j]=='#':
ans='Impossible'
j+=1
i+=1
print(ans)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
0,
13,
39,
28,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
4,
18,
13,
13,
17,
4,
18,
13,
13,
17,
4,
18,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
18,
13,
13,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
39,
13,
10,
39,
13,
10,
4,
13
] |
[
[
89,
2
],
[
89,
11
],
[
95,
13
],
[
17,
16
],
[
87,
19
],
[
83,
21
],
[
98,
25
],
[
29,
28
],
[
90,
31
],
[
84,
35
],
[
28,
36
],
[
99,
40
],
[
99,
45
],
[
96,
50
],
[
99,
52
],
[
92,
54
],
[
58,
57
],
[
87,
60
],
[
101,
62
],
[
96,
66
],
[
57,
67
],
[
102,
70
],
[
93,
70
],
[
87,
73
],
[
90,
74
],
[
83,
84
],
[
89,
87
],
[
89,
90
],
[
92,
93
],
[
95,
96
],
[
98,
99
],
[
101,
102
]
] |
[
"h,w=map(int,input().split())\ntable=[]\nfor _ in range(h):\n a=input()\n b=[]\n for i in range(w):\n if a[i]=='#':\n b.append(1)\n else:\n b.append(0)\n table.append(b)\nans=0\nfor i in range(h):\n ans+=sum(table[i])\nif ans==h+w-1:\n print('Possible')\nelse:\n print('Impossible')\n\n ",
"h,w=map(int,input().split())",
"h",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"table=[]",
"table",
"[]",
"for _ in range(h):\n a=input()\n b=[]\n for i in range(w):\n if a[i]=='#':\n b.append(1)\n else:\n b.append(0)\n table.append(b)",
"_",
"range(h)",
"range",
"h",
"a=input()",
"a",
"input()",
"input",
"b=[]",
"b",
"[]",
"for i in range(w):\n if a[i]=='#':\n b.append(1)\n else:\n b.append(0)\n ",
"i",
"range(w)",
"range",
"w",
"if a[i]=='#':\n b.append(1)\n else:\n b.append(0)\n ",
"a[i]=='#'",
"a[i]",
"a",
"i",
"'#'",
"b.append(1)",
"b.append",
"b",
"append",
"1",
"b.append(0)",
"b.append",
"b",
"append",
"0",
"table.append(b)",
"table.append",
"table",
"append",
"b",
"ans=0",
"ans",
"0",
"for i in range(h):\n ans+=sum(table[i])",
"i",
"range(h)",
"range",
"h",
"ans+=sum(table[i])",
"ans",
"sum(table[i])",
"sum",
"table[i]",
"table",
"i",
"if ans==h+w-1:\n print('Possible')\nelse:\n print('Impossible')\n\n ",
"ans==h+w-1",
"ans",
"h+w-1",
"h+w",
"h",
"w",
"1",
"print('Possible')",
"print",
"'Possible'",
"print('Impossible')",
"print",
"'Impossible'",
"a=input()",
"input()",
"a",
"h,w=map(int,input().split())",
"map(int,input().split())",
"h",
"w=map(int,input().split())",
"map(int,input().split())",
"w",
"ans=0",
"0",
"ans",
"table=[]",
"[]",
"table",
"b=[]",
"[]",
"b",
"ans+=sum(table[i])",
"sum(table[i])",
"ans"
] |
h,w=map(int,input().split())
table=[]
for _ in range(h):
a=input()
b=[]
for i in range(w):
if a[i]=='#':
b.append(1)
else:
b.append(0)
table.append(b)
ans=0
for i in range(h):
ans+=sum(table[i])
if ans==h+w-1:
print('Possible')
else:
print('Impossible')
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
18,
4,
13,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] |
[
[
52,
2
],
[
52,
11
],
[
49,
13
],
[
17,
16
],
[
44,
19
],
[
46,
21
],
[
47,
30
],
[
50,
30
],
[
44,
33
],
[
53,
34
],
[
52,
44
],
[
46,
47
],
[
49,
50
],
[
52,
53
]
] |
[
"H,W = map(int,input().split())\n\nres = 0\n\nfor i in range(H):\n res += input().count('#')\n\nif res == H+W-1:\n print('Possible')\nelse:\n print('Impossible')",
"H,W = map(int,input().split())",
"H",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"res = 0",
"res",
"0",
"for i in range(H):\n res += input().count('#')",
"i",
"range(H)",
"range",
"H",
"res += input().count('#')",
"res",
"input().count('#')",
"().count",
"()",
"input",
"count",
"'#'",
"if res == H+W-1:\n print('Possible')\nelse:\n print('Impossible')",
"res == H+W-1",
"res",
"H+W-1",
"H+W",
"H",
"W",
"1",
"print('Possible')",
"print",
"'Possible'",
"print('Impossible')",
"print",
"'Impossible'",
"H,W = map(int,input().split())",
"map(int,input().split())",
"H",
"res += input().count('#')",
"input().count('#')",
"res",
"res = 0",
"0",
"res",
"W = map(int,input().split())",
"map(int,input().split())",
"W"
] |
H,W = map(int,input().split())
res = 0
for i in range(H):
res += input().count('#')
if res == H+W-1:
print('Possible')
else:
print('Impossible')
|
[
7,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
13,
0,
13,
4,
18,
13,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13
] |
[
[
5,
4
],
[
5,
13
],
[
17,
16
],
[
4,
19
],
[
25,
24
],
[
28,
27
],
[
31,
30
],
[
24,
30
],
[
34,
33
],
[
30,
36
],
[
33,
41
],
[
27,
41
],
[
4,
44
],
[
13,
45
],
[
61,
58
]
] |
[
"def main():\n H, W = map(int, input().split())\n A = [input() for i in range(H)]\n\n cnt = 0\n for a in A:\n cnt += a.count(\"#\")\n\n if cnt == H + W - 1:\n print(\"Possible\")\n else:\n print(\"Impossible\")\n\n\nif __name__ == \"__main__\":\n main()",
"def main():\n H, W = map(int, input().split())\n A = [input() for i in range(H)]\n\n cnt = 0\n for a in A:\n cnt += a.count(\"#\")\n\n if cnt == H + W - 1:\n print(\"Possible\")\n else:\n print(\"Impossible\")",
"main",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"input() for i in range(H)",
"for i in range(H)",
"i",
"range(H)",
"range",
"H",
"for i in range(H)",
"input()",
"input",
"A = [input() for i in range(H)]",
"A",
"[input() for i in range(H)]",
"cnt = 0",
"cnt",
"0",
"for a in A:\n cnt += a.count(\"#\")\n\n ",
"a",
"A",
"cnt += a.count(\"#\")",
"cnt",
"a.count(\"#\")",
"a.count",
"a",
"count",
"\"#\"",
"if cnt == H + W - 1:\n print(\"Possible\")\n else:\n print(\"Impossible\")",
"cnt == H + W - 1",
"cnt",
"H + W - 1",
"H + W",
"H",
"W",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"if __name__ == \"__main__\":\n main()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"main()",
"main",
"def main():\n H, W = map(int, input().split())\n A = [input() for i in range(H)]\n\n cnt = 0\n for a in A:\n cnt += a.count(\"#\")\n\n if cnt == H + W - 1:\n print(\"Possible\")\n else:\n print(\"Impossible\")",
"def main():\n H, W = map(int, input().split())\n A = [input() for i in range(H)]\n\n cnt = 0\n for a in A:\n cnt += a.count(\"#\")\n\n if cnt == H + W - 1:\n print(\"Possible\")\n else:\n print(\"Impossible\")",
"main"
] |
def main():
H, W = map(int, input().split())
A = [input() for i in range(H)]
cnt = 0
for a in A:
cnt += a.count("#")
if cnt == H + W - 1:
print("Possible")
else:
print("Impossible")
if __name__ == "__main__":
main()
|
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
13,
0,
13,
17,
13,
17,
0,
13,
4,
13,
0,
13,
39,
17,
17,
17,
17,
0,
13,
39,
17,
17,
17,
17,
4,
18,
13,
13,
39,
13,
13,
42,
13,
0,
13,
4,
18,
13,
13,
13,
0,
18,
18,
13,
13,
13,
17,
28,
13,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
14,
2,
2,
2,
2,
13,
4,
13,
13,
2,
13,
4,
13,
13,
40,
18,
18,
13,
13,
13,
2,
18,
18,
13,
13,
13,
17,
4,
18,
13,
13,
39,
13,
13,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
40,
18,
18,
13,
13,
13,
2,
18,
18,
13,
13,
13,
17,
4,
13,
17,
4,
13,
4,
18,
13,
13,
39,
13,
13,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
42,
13,
0,
13,
4,
18,
13,
13,
13,
0,
18,
18,
13,
13,
13,
17,
28,
13,
13,
4,
13,
18,
13,
39,
17,
17,
18,
13,
39,
17,
17,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
14,
2,
2,
2,
13,
4,
13,
13,
2,
13,
4,
13,
13,
2,
18,
18,
13,
13,
13,
17,
4,
18,
13,
13,
39,
13,
13,
28,
13,
13,
4,
13,
18,
13,
39,
17,
17,
18,
13,
39,
17,
17,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
14,
2,
2,
2,
2,
13,
4,
13,
13,
2,
13,
4,
13,
13,
2,
18,
18,
13,
13,
13,
17,
40,
18,
18,
13,
13,
13,
4,
13,
17,
4,
13,
14,
2,
4,
13,
13,
17,
4,
13,
17,
4,
13,
14,
2,
2,
13,
2,
13,
17,
2,
13,
2,
13,
17,
4,
13,
17,
4,
13,
4,
13,
17,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
39,
13,
10,
2,
13,
10,
39,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
39,
13,
10,
4,
13,
10,
17,
13,
10,
2,
13,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
13,
13
] |
[
[
396,
3
],
[
396,
12
],
[
366,
14
],
[
19,
18
],
[
352,
21
],
[
408,
25
],
[
29,
28
],
[
352,
31
],
[
375,
33
],
[
367,
43
],
[
376,
45
],
[
405,
47
],
[
384,
49
],
[
357,
52
],
[
378,
56
],
[
360,
63
],
[
358,
71
],
[
402,
79
],
[
358,
82
],
[
402,
84
],
[
91,
86
],
[
409,
88
],
[
403,
89
],
[
355,
90
],
[
379,
97
],
[
361,
98
],
[
387,
100
],
[
403,
102
],
[
363,
105
],
[
355,
107
],
[
388,
114
],
[
352,
117
],
[
364,
119
],
[
397,
122
],
[
409,
126
],
[
388,
127
],
[
364,
128
],
[
367,
132
],
[
388,
133
],
[
364,
134
],
[
358,
138
],
[
145,
144
],
[
352,
147
],
[
150,
149
],
[
397,
152
],
[
409,
158
],
[
144,
159
],
[
149,
160
],
[
367,
164
],
[
144,
165
],
[
149,
166
],
[
358,
175
],
[
183,
182
],
[
352,
185
],
[
348,
189
],
[
381,
194
],
[
358,
197
],
[
381,
199
],
[
206,
201
],
[
349,
203
],
[
409,
203
],
[
370,
204
],
[
403,
204
],
[
382,
205
],
[
355,
205
],
[
379,
213
],
[
361,
218
],
[
372,
223
],
[
370,
225
],
[
403,
225
],
[
399,
228
],
[
382,
230
],
[
355,
230
],
[
373,
236
],
[
388,
236
],
[
394,
236
],
[
352,
239
],
[
400,
241
],
[
364,
241
],
[
391,
241
],
[
397,
244
],
[
367,
248
],
[
373,
249
],
[
388,
249
],
[
394,
249
],
[
400,
250
],
[
364,
250
],
[
391,
250
],
[
358,
254
],
[
379,
265
],
[
361,
270
],
[
393,
275
],
[
370,
277
],
[
403,
277
],
[
390,
280
],
[
382,
282
],
[
355,
282
],
[
394,
289
],
[
373,
289
],
[
388,
289
],
[
352,
292
],
[
391,
294
],
[
400,
294
],
[
364,
294
],
[
397,
297
],
[
367,
301
],
[
394,
302
],
[
373,
302
],
[
388,
302
],
[
391,
303
],
[
400,
303
],
[
364,
303
],
[
349,
308
],
[
409,
308
],
[
394,
309
],
[
373,
309
],
[
388,
309
],
[
391,
310
],
[
400,
310
],
[
364,
310
],
[
358,
320
],
[
370,
330
],
[
403,
330
],
[
352,
332
],
[
382,
335
],
[
355,
335
],
[
397,
337
],
[
348,
349
],
[
396,
352
],
[
402,
355
],
[
357,
358
],
[
360,
361
],
[
363,
364
],
[
366,
367
],
[
381,
370
],
[
372,
373
],
[
375,
376
],
[
378,
379
],
[
381,
382
],
[
384,
385
],
[
387,
388
],
[
390,
391
],
[
393,
394
],
[
396,
397
],
[
399,
400
],
[
402,
403
],
[
405,
406
],
[
408,
409
]
] |
[
"from collections import deque\nh, w = map(int, input().split())\nfield = []\ncheck = [[False for _ in range(w)] for _ in range(h)]\nfor i in range(h):\n s = list(input().strip())\n field.append(s)\n\nsx, sy = 0, 0\nd = deque()\ndirx = [0, 1, 0, -1]\ndiry = [1, 0, -1, 0]\nd.append([sx, sy])\n# 離れ島がないかのチェック\nwhile (d):\n nowx, nowy = d.popleft()\n check[nowx][nowy] = True\n for x, y in zip(dirx, diry):\n nx = nowx + x\n ny = nowy + y\n if nx in range(h) and ny in range(w) and (\n not check[nx][ny]) and field[nx][ny] == '#':\n d.append([nx, ny])\nfor i in range(h):\n for j in range(w):\n if not check[i][j] and field[i][j] == '#':\n print('Impossible')\n exit()\n\n# 右or下のみの最短でいけるかチェック\nd.append([sx, sy])\ncheck = [[False for _ in range(w)] for _ in range(h)]\nwhile (d):\n nowx, nowy = d.pop()\n check[nowx][nowy] = True\n\n for x, y in zip(dirx[0:2], diry[0:2]):\n nx = nowx + x\n ny = nowy + y\n if nx in range(h) and ny in range(w) and field[nx][ny] == '#':\n d.append([nx, ny])\n for x, y in zip(dirx[2:4], diry[2:4]):\n nx = nowx + x\n ny = nowy + y\n if nx in range(h) and ny in range(\n w) and field[nx][ny] == '#' and not check[nx][ny]:\n print('Impossible')\n exit()\n\n if len(d) == 2:\n print('Impossible')\n exit()\n if nowx == h - 1 and nowy == w - 1:\n print('Possible')\n exit()\n\nprint('Impossible')",
"from collections import deque",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"field = []",
"field",
"[]",
"[False for _ in range(w)] for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"[False for _ in range(w)]",
"check = [[False for _ in range(w)] for _ in range(h)]",
"check",
"[[False for _ in range(w)] for _ in range(h)]",
"for i in range(h):\n s = list(input().strip())\n field.append(s)",
"i",
"range(h)",
"range",
"h",
"s = list(input().strip())",
"s",
"list(input().strip())",
"list",
"input().strip()",
"().strip",
"()",
"input",
"strip",
"field.append(s)",
"field.append",
"field",
"append",
"s",
"sx, sy = 0, 0",
"sx",
"0",
"sy",
"0",
"d = deque()",
"d",
"deque()",
"deque",
"dirx = [0, 1, 0, -1]",
"dirx",
"[0, 1, 0, -1]",
"0",
"1",
"0",
"-1",
"diry = [1, 0, -1, 0]",
"diry",
"[1, 0, -1, 0]",
"1",
"0",
"-1",
"0",
"d.append([sx, sy])",
"d.append",
"d",
"append",
"[sx, sy]",
"sx",
"sy",
"while (d):\n nowx, nowy = d.popleft()\n check[nowx][nowy] = True\n for x, y in zip(dirx, diry):\n nx = nowx + x\n ny = nowy + y\n if nx in range(h) and ny in range(w) and (\n not check[nx][ny]) and field[nx][ny] == '#':\n d.append([nx, ny])",
"d",
"nowx, nowy = d.popleft()",
"nowx",
"d.popleft()",
"d.popleft",
"d",
"popleft",
"nowy",
"check[nowx][nowy] = True",
"check[nowx][nowy]",
"[nowx]",
"check",
"nowx",
"nowy",
"True",
"for x, y in zip(dirx, diry):\n nx = nowx + x\n ny = nowy + y\n if nx in range(h) and ny in range(w) and (\n not check[nx][ny]) and field[nx][ny] == '#':\n d.append([nx, ny])",
"x",
"y",
"zip(dirx, diry)",
"zip",
"dirx",
"diry",
"nx = nowx + x",
"nx",
"nowx + x",
"nowx",
"x",
"ny = nowy + y",
"ny",
"nowy + y",
"nowy",
"y",
"if nx in range(h) and ny in range(w) and (\n not check[nx][ny]) and field[nx][ny] == '#':\n d.append([nx, ny])",
"nx in range(h) and ny in range(w) and (\n not check[nx][ny]) and field[nx][ny] == '#'",
"nx in range(h) and ny in range(w) and (\n not check[nx][ny])",
"nx in range(h) and ny in range(w)",
"nx in range(h)",
"nx",
"range(h)",
"range",
"h",
"ny in range(w)",
"ny",
"range(w)",
"range",
"w",
"not check[nx][ny]",
"check[nx][ny]",
"[nx]",
"check",
"nx",
"ny",
"field[nx][ny] == '#'",
"field[nx][ny]",
"[nx]",
"field",
"nx",
"ny",
"'#'",
"d.append([nx, ny])",
"d.append",
"d",
"append",
"[nx, ny]",
"nx",
"ny",
"for i in range(h):\n for j in range(w):\n if not check[i][j] and field[i][j] == '#':\n print('Impossible')\n exit()\n\n# 右or下のみの最短でいけるかチェック",
"i",
"range(h)",
"range",
"h",
"for j in range(w):\n if not check[i][j] and field[i][j] == '#':\n print('Impossible')\n exit()\n\n# 右or下のみの最短でいけるかチェック",
"j",
"range(w)",
"range",
"w",
"if not check[i][j] and field[i][j] == '#':\n print('Impossible')\n exit()\n\n# 右or下のみの最短でいけるかチェック",
"not check[i][j] and field[i][j] == '#'",
"not check[i][j]",
"check[i][j]",
"[i]",
"check",
"i",
"j",
"field[i][j] == '#'",
"field[i][j]",
"[i]",
"field",
"i",
"j",
"'#'",
"print('Impossible')",
"print",
"'Impossible'",
"exit()",
"exit",
"d.append([sx, sy])",
"d.append",
"d",
"append",
"[sx, sy]",
"sx",
"sy",
"[False for _ in range(w)] for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"[False for _ in range(w)]",
"check = [[False for _ in range(w)] for _ in range(h)]",
"check",
"[[False for _ in range(w)] for _ in range(h)]",
"while (d):\n nowx, nowy = d.pop()\n check[nowx][nowy] = True\n\n for x, y in zip(dirx[0:2], diry[0:2]):\n nx = nowx + x\n ny = nowy + y\n if nx in range(h) and ny in range(w) and field[nx][ny] == '#':\n d.append([nx, ny])\n for x, y in zip(dirx[2:4], diry[2:4]):\n nx = nowx + x\n ny = nowy + y\n if nx in range(h) and ny in range(\n w) and field[nx][ny] == '#' and not check[nx][ny]:\n print('Impossible')\n exit()\n\n if len(d) == 2:\n print('Impossible')\n exit()\n if nowx == h - 1 and nowy == w - 1:\n print('Possible')\n exit()",
"d",
"nowx, nowy = d.pop()",
"nowx",
"d.pop()",
"d.pop",
"d",
"pop",
"nowy",
"check[nowx][nowy] = True",
"check[nowx][nowy]",
"[nowx]",
"check",
"nowx",
"nowy",
"True",
"for x, y in zip(dirx[0:2], diry[0:2]):\n nx = nowx + x\n ny = nowy + y\n if nx in range(h) and ny in range(w) and field[nx][ny] == '#':\n d.append([nx, ny])\n ",
"x",
"y",
"zip(dirx[0:2], diry[0:2])",
"zip",
"dirx[0:2]",
"dirx",
"0:2",
"0",
"2",
"diry[0:2]",
"diry",
"0:2",
"0",
"2",
"nx = nowx + x",
"nx",
"nowx + x",
"nowx",
"x",
"ny = nowy + y",
"ny",
"nowy + y",
"nowy",
"y",
"if nx in range(h) and ny in range(w) and field[nx][ny] == '#':\n d.append([nx, ny])\n ",
"nx in range(h) and ny in range(w) and field[nx][ny] == '#'",
"nx in range(h) and ny in range(w)",
"nx in range(h)",
"nx",
"range(h)",
"range",
"h",
"ny in range(w)",
"ny",
"range(w)",
"range",
"w",
"field[nx][ny] == '#'",
"field[nx][ny]",
"[nx]",
"field",
"nx",
"ny",
"'#'",
"d.append([nx, ny])",
"d.append",
"d",
"append",
"[nx, ny]",
"nx",
"ny",
"for x, y in zip(dirx[2:4], diry[2:4]):\n nx = nowx + x\n ny = nowy + y\n if nx in range(h) and ny in range(\n w) and field[nx][ny] == '#' and not check[nx][ny]:\n print('Impossible')\n exit()\n\n ",
"x",
"y",
"zip(dirx[2:4], diry[2:4])",
"zip",
"dirx[2:4]",
"dirx",
"2:4",
"2",
"4",
"diry[2:4]",
"diry",
"2:4",
"2",
"4",
"nx = nowx + x",
"nx",
"nowx + x",
"nowx",
"x",
"ny = nowy + y",
"ny",
"nowy + y",
"nowy",
"y",
"if nx in range(h) and ny in range(\n w) and field[nx][ny] == '#' and not check[nx][ny]:\n print('Impossible')\n exit()\n\n ",
"nx in range(h) and ny in range(\n w) and field[nx][ny] == '#' and not check[nx][ny]",
"nx in range(h) and ny in range(\n w) and field[nx][ny] == '#'",
"nx in range(h) and ny in range(\n w)",
"nx in range(h)",
"nx",
"range(h)",
"range",
"h",
"ny in range(\n w)",
"ny",
"range(\n w)",
"range",
"w",
"field[nx][ny] == '#'",
"field[nx][ny]",
"[nx]",
"field",
"nx",
"ny",
"'#'",
"not check[nx][ny]",
"check[nx][ny]",
"[nx]",
"check",
"nx",
"ny",
"print('Impossible')",
"print",
"'Impossible'",
"exit()",
"exit",
"if len(d) == 2:\n print('Impossible')\n exit()\n ",
"len(d) == 2",
"len(d)",
"len",
"d",
"2",
"print('Impossible')",
"print",
"'Impossible'",
"exit()",
"exit",
"if nowx == h - 1 and nowy == w - 1:\n print('Possible')\n exit()",
"nowx == h - 1 and nowy == w - 1",
"nowx == h - 1",
"nowx",
"h - 1",
"h",
"1",
"nowy == w - 1",
"nowy",
"w - 1",
"w",
"1",
"print('Possible')",
"print",
"'Possible'",
"exit()",
"exit",
"print('Impossible')",
"print",
"'Impossible'",
"check = [[False for _ in range(w)] for _ in range(h)]",
"[[False for _ in range(w)] for _ in range(h)]",
"check",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h",
"nowy = d.popleft()",
"d.popleft()",
"nowy",
"d = deque()",
"deque()",
"d",
"diry = [1, 0, -1, 0]",
"[1, 0, -1, 0]",
"diry",
"ny = nowy + y",
"nowy + y",
"ny",
"field = []",
"[]",
"field",
"nowx, nowy = d.pop()",
"d.pop()",
"nowx",
"nx = nowx + x",
"nowx + x",
"nx",
"s = list(input().strip())",
"list(input().strip())",
"s",
"dirx = [0, 1, 0, -1]",
"[0, 1, 0, -1]",
"dirx",
"nowy = d.pop()",
"d.pop()",
"nowy",
"sy = 0, 0",
"0",
"sy",
"nx = nowx + x",
"nowx + x",
"nx",
"ny = nowy + y",
"nowy + y",
"ny",
"nx = nowx + x",
"nowx + x",
"nx",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"ny = nowy + y",
"nowy + y",
"ny",
"nowx, nowy = d.popleft()",
"d.popleft()",
"nowx",
"sx, sy = 0, 0",
"0",
"sx",
"check = [[False for _ in range(w)] for _ in range(h)]",
"[[False for _ in range(w)] for _ in range(h)]",
"check"
] |
from collections import deque
h, w = map(int, input().split())
field = []
check = [[False for _ in range(w)] for _ in range(h)]
for i in range(h):
s = list(input().strip())
field.append(s)
sx, sy = 0, 0
d = deque()
dirx = [0, 1, 0, -1]
diry = [1, 0, -1, 0]
d.append([sx, sy])
# 離れ島がないかのチェック
while (d):
nowx, nowy = d.popleft()
check[nowx][nowy] = True
for x, y in zip(dirx, diry):
nx = nowx + x
ny = nowy + y
if nx in range(h) and ny in range(w) and (
not check[nx][ny]) and field[nx][ny] == '#':
d.append([nx, ny])
for i in range(h):
for j in range(w):
if not check[i][j] and field[i][j] == '#':
print('Impossible')
exit()
# 右or下のみの最短でいけるかチェック
d.append([sx, sy])
check = [[False for _ in range(w)] for _ in range(h)]
while (d):
nowx, nowy = d.pop()
check[nowx][nowy] = True
for x, y in zip(dirx[0:2], diry[0:2]):
nx = nowx + x
ny = nowy + y
if nx in range(h) and ny in range(w) and field[nx][ny] == '#':
d.append([nx, ny])
for x, y in zip(dirx[2:4], diry[2:4]):
nx = nowx + x
ny = nowy + y
if nx in range(h) and ny in range(
w) and field[nx][ny] == '#' and not check[nx][ny]:
print('Impossible')
exit()
if len(d) == 2:
print('Impossible')
exit()
if nowx == h - 1 and nowy == w - 1:
print('Possible')
exit()
print('Impossible')
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
0,
13,
4,
18,
13,
13,
17,
14,
2,
2,
13,
17,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13
] |
[
[
54,
2
],
[
54,
11
],
[
57,
13
],
[
17,
16
],
[
52,
19
],
[
48,
21
],
[
60,
25
],
[
49,
28
],
[
61,
34
],
[
58,
34
],
[
52,
38
],
[
55,
39
],
[
48,
49
],
[
54,
52
],
[
54,
55
],
[
57,
58
],
[
60,
61
]
] |
[
"h,w=map(int,input().split())\ns=0\nfor i in range(h):\n a=input()\n s+=a.count('#')\nif s-1==h+w-2:\n print('Possible')\nelse:\n print('Impossible')",
"h,w=map(int,input().split())",
"h",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"s=0",
"s",
"0",
"for i in range(h):\n a=input()\n s+=a.count('#')",
"i",
"range(h)",
"range",
"h",
"a=input()",
"a",
"input()",
"input",
"s+=a.count('#')",
"s",
"a.count('#')",
"a.count",
"a",
"count",
"'#'",
"if s-1==h+w-2:\n print('Possible')\nelse:\n print('Impossible')",
"s-1==h+w-2",
"s-1",
"s",
"1",
"h+w-2",
"h+w",
"h",
"w",
"2",
"print('Possible')",
"print",
"'Possible'",
"print('Impossible')",
"print",
"'Impossible'",
"a=input()",
"input()",
"a",
"h,w=map(int,input().split())",
"map(int,input().split())",
"h",
"w=map(int,input().split())",
"map(int,input().split())",
"w",
"s=0",
"0",
"s",
"s+=a.count('#')",
"a.count('#')",
"s"
] |
h,w=map(int,input().split())
s=0
for i in range(h):
a=input()
s+=a.count('#')
if s-1==h+w-2:
print('Possible')
else:
print('Impossible')
|
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
0,
13,
4,
13,
4,
18,
13,
13,
39,
17,
17,
41,
28,
13,
4,
13,
13,
4,
2,
39,
17,
13,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
12,
13,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
2,
18,
18,
13,
13,
13,
17,
40,
18,
18,
13,
13,
13,
29,
17,
29,
17,
12,
13,
42,
2,
4,
13,
13,
17,
0,
13,
4,
18,
13,
13,
13,
14,
2,
2,
40,
17,
13,
2,
13,
17,
2,
40,
17,
13,
2,
13,
17,
14,
2,
2,
18,
18,
13,
13,
2,
13,
17,
17,
2,
18,
18,
13,
2,
13,
17,
13,
17,
4,
13,
17,
4,
13,
28,
13,
13,
39,
39,
17,
17,
39,
17,
17,
0,
13,
2,
13,
13,
13,
2,
13,
13,
14,
2,
2,
40,
17,
13,
13,
2,
40,
17,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
4,
18,
13,
13,
39,
13,
13,
0,
18,
18,
13,
13,
13,
17,
4,
13,
8,
4,
13,
17,
17,
23,
13,
4,
13,
13,
10,
4,
13,
10,
12,
13,
10,
4,
13,
10,
12,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13
] |
[
[
224,
3
],
[
224,
12
],
[
16,
15
],
[
225,
18
],
[
227,
25
],
[
212,
28
],
[
213,
33
],
[
41,
40
],
[
225,
43
],
[
219,
48
],
[
230,
50
],
[
58,
53
],
[
231,
55
],
[
63,
62
],
[
225,
65
],
[
68,
67
],
[
219,
70
],
[
228,
76
],
[
62,
77
],
[
67,
78
],
[
231,
83
],
[
62,
84
],
[
67,
85
],
[
207,
96
],
[
100,
99
],
[
207,
102
],
[
100,
104
],
[
104,
110
],
[
219,
112
],
[
99,
117
],
[
225,
119
],
[
228,
126
],
[
99,
127
],
[
104,
129
],
[
228,
135
],
[
99,
137
],
[
104,
139
],
[
158,
157
],
[
99,
159
],
[
162,
161
],
[
104,
163
],
[
161,
170
],
[
219,
171
],
[
157,
175
],
[
225,
176
],
[
228,
181
],
[
157,
182
],
[
161,
183
],
[
207,
187
],
[
198,
193
],
[
231,
195
],
[
157,
196
],
[
161,
197
],
[
216,
203
],
[
207,
207
],
[
222,
209
],
[
213,
210
],
[
212,
213
],
[
224,
219
],
[
224,
225
],
[
227,
228
],
[
230,
231
]
] |
[
"from collections import deque\nh, w = map(int, input().split())\na = [list(input()) for _ in range(h)]\n\nqueue = deque()\nqueue.append([0, 0])\nvisited = [[False] * w for _ in range(h)]\nvisited[0][0] = True\n\ndef judge():\n for i in range(h):\n for j in range(w):\n if a[i][j] == \"#\" and not visited[i][j]:\n return False\n return True\ndef bfs(queue):\n while len(queue) > 0:\n n_y, n_x = queue.popleft()\n if 0 <= n_x < w - 1 and 0 <= n_y < h - 1:\n if a[n_y][n_x + 1] == \"#\" and a[n_y + 1][n_x] == \"#\":\n print(\"Impossible\")\n exit()\n for i, j in [[0, 1], [1, 0]]:\n y, x = n_y + i, n_x + j\n if 0 <= x < w and 0 <= y < h:\n if a[y][x] == \"#\":\n queue.append([y, x])\n visited[y][x] = True\n print(\"Possible\" if judge() else \"Impossible\")\nbfs(queue)",
"from collections import deque",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"list(input()) for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"list(input())",
"list",
"input()",
"input",
"a = [list(input()) for _ in range(h)]",
"a",
"[list(input()) for _ in range(h)]",
"queue = deque()",
"queue",
"deque()",
"deque",
"queue.append([0, 0])",
"queue.append",
"queue",
"append",
"[0, 0]",
"0",
"0",
"[False] * w for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"[False] * w",
"[False]",
"False",
"w",
"visited = [[False] * w for _ in range(h)]",
"visited",
"[[False] * w for _ in range(h)]",
"visited[0][0] = True",
"visited[0][0]",
"[0]",
"visited",
"0",
"0",
"True",
"def judge():\n for i in range(h):\n for j in range(w):\n if a[i][j] == \"#\" and not visited[i][j]:\n return False\n return True",
"judge",
"for i in range(h):\n for j in range(w):\n if a[i][j] == \"#\" and not visited[i][j]:\n return False\n ",
"i",
"range(h)",
"range",
"h",
"for j in range(w):\n if a[i][j] == \"#\" and not visited[i][j]:\n return False\n ",
"j",
"range(w)",
"range",
"w",
"if a[i][j] == \"#\" and not visited[i][j]:\n return False\n ",
"a[i][j] == \"#\" and not visited[i][j]",
"a[i][j] == \"#\"",
"a[i][j]",
"[i]",
"a",
"i",
"j",
"\"#\"",
"not visited[i][j]",
"visited[i][j]",
"[i]",
"visited",
"i",
"j",
"return False",
"False",
"return True",
"True",
"def bfs(queue):\n while len(queue) > 0:\n n_y, n_x = queue.popleft()\n if 0 <= n_x < w - 1 and 0 <= n_y < h - 1:\n if a[n_y][n_x + 1] == \"#\" and a[n_y + 1][n_x] == \"#\":\n print(\"Impossible\")\n exit()\n for i, j in [[0, 1], [1, 0]]:\n y, x = n_y + i, n_x + j\n if 0 <= x < w and 0 <= y < h:\n if a[y][x] == \"#\":\n queue.append([y, x])\n visited[y][x] = True\n print(\"Possible\" if judge() else \"Impossible\")",
"bfs",
"while len(queue) > 0:\n n_y, n_x = queue.popleft()\n if 0 <= n_x < w - 1 and 0 <= n_y < h - 1:\n if a[n_y][n_x + 1] == \"#\" and a[n_y + 1][n_x] == \"#\":\n print(\"Impossible\")\n exit()\n for i, j in [[0, 1], [1, 0]]:\n y, x = n_y + i, n_x + j\n if 0 <= x < w and 0 <= y < h:\n if a[y][x] == \"#\":\n queue.append([y, x])\n visited[y][x] = True\n ",
"len(queue) > 0",
"len(queue)",
"len",
"queue",
"0",
"n_y, n_x = queue.popleft()",
"n_y",
"queue.popleft()",
"queue.popleft",
"queue",
"popleft",
"n_x",
"if 0 <= n_x < w - 1 and 0 <= n_y < h - 1:\n if a[n_y][n_x + 1] == \"#\" and a[n_y + 1][n_x] == \"#\":\n print(\"Impossible\")\n exit()\n ",
"0 <= n_x < w - 1 and 0 <= n_y < h - 1",
"0 <= n_x < w - 1",
"0 <= n_x",
"0",
"n_x",
"w - 1",
"w",
"1",
"0 <= n_y < h - 1",
"0 <= n_y",
"0",
"n_y",
"h - 1",
"h",
"1",
"if a[n_y][n_x + 1] == \"#\" and a[n_y + 1][n_x] == \"#\":\n print(\"Impossible\")\n exit()\n ",
"a[n_y][n_x + 1] == \"#\" and a[n_y + 1][n_x] == \"#\"",
"a[n_y][n_x + 1] == \"#\"",
"a[n_y][n_x + 1]",
"[n_y]",
"a",
"n_y",
"n_x + 1",
"n_x",
"1",
"\"#\"",
"a[n_y + 1][n_x] == \"#\"",
"a[n_y + 1][n_x]",
"[n_y + 1]",
"a",
"n_y + 1",
"n_y",
"1",
"n_x",
"\"#\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"exit()",
"exit",
"for i, j in [[0, 1], [1, 0]]:\n y, x = n_y + i, n_x + j\n if 0 <= x < w and 0 <= y < h:\n if a[y][x] == \"#\":\n queue.append([y, x])\n visited[y][x] = True\n ",
"i",
"j",
"[[0, 1], [1, 0]]",
"[0, 1]",
"0",
"1",
"[1, 0]",
"1",
"0",
"y, x = n_y + i, n_x + j",
"y",
"n_y + i",
"n_y",
"i",
"x",
"n_x + j",
"n_x",
"j",
"if 0 <= x < w and 0 <= y < h:\n if a[y][x] == \"#\":\n queue.append([y, x])\n visited[y][x] = True\n ",
"0 <= x < w and 0 <= y < h",
"0 <= x < w",
"0 <= x",
"0",
"x",
"w",
"0 <= y < h",
"0 <= y",
"0",
"y",
"h",
"if a[y][x] == \"#\":\n queue.append([y, x])\n visited[y][x] = True\n ",
"a[y][x] == \"#\"",
"a[y][x]",
"[y]",
"a",
"y",
"x",
"\"#\"",
"queue.append([y, x])",
"queue.append",
"queue",
"append",
"[y, x]",
"y",
"x",
"visited[y][x] = True",
"visited[y][x]",
"[y]",
"visited",
"y",
"x",
"True",
"print(\"Possible\" if judge() else \"Impossible\")",
"print",
"\"Possible\" if judge() else \"Impossible\"",
"judge()",
"judge",
"\"Possible\"",
"\"Impossible\"",
"queue",
"queue",
"bfs(queue)",
"bfs",
"queue",
"queue = deque()",
"deque()",
"queue",
"def judge():\n for i in range(h):\n for j in range(w):\n if a[i][j] == \"#\" and not visited[i][j]:\n return False\n return True",
"def judge():\n for i in range(h):\n for j in range(w):\n if a[i][j] == \"#\" and not visited[i][j]:\n return False\n return True",
"judge",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"def bfs(queue):\n while len(queue) > 0:\n n_y, n_x = queue.popleft()\n if 0 <= n_x < w - 1 and 0 <= n_y < h - 1:\n if a[n_y][n_x + 1] == \"#\" and a[n_y + 1][n_x] == \"#\":\n print(\"Impossible\")\n exit()\n for i, j in [[0, 1], [1, 0]]:\n y, x = n_y + i, n_x + j\n if 0 <= x < w and 0 <= y < h:\n if a[y][x] == \"#\":\n queue.append([y, x])\n visited[y][x] = True\n print(\"Possible\" if judge() else \"Impossible\")",
"def bfs(queue):\n while len(queue) > 0:\n n_y, n_x = queue.popleft()\n if 0 <= n_x < w - 1 and 0 <= n_y < h - 1:\n if a[n_y][n_x + 1] == \"#\" and a[n_y + 1][n_x] == \"#\":\n print(\"Impossible\")\n exit()\n for i, j in [[0, 1], [1, 0]]:\n y, x = n_y + i, n_x + j\n if 0 <= x < w and 0 <= y < h:\n if a[y][x] == \"#\":\n queue.append([y, x])\n visited[y][x] = True\n print(\"Possible\" if judge() else \"Impossible\")",
"bfs",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h",
"a = [list(input()) for _ in range(h)]",
"[list(input()) for _ in range(h)]",
"a",
"visited = [[False] * w for _ in range(h)]",
"[[False] * w for _ in range(h)]",
"visited"
] |
from collections import deque
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
queue = deque()
queue.append([0, 0])
visited = [[False] * w for _ in range(h)]
visited[0][0] = True
def judge():
for i in range(h):
for j in range(w):
if a[i][j] == "#" and not visited[i][j]:
return False
return True
def bfs(queue):
while len(queue) > 0:
n_y, n_x = queue.popleft()
if 0 <= n_x < w - 1 and 0 <= n_y < h - 1:
if a[n_y][n_x + 1] == "#" and a[n_y + 1][n_x] == "#":
print("Impossible")
exit()
for i, j in [[0, 1], [1, 0]]:
y, x = n_y + i, n_x + j
if 0 <= x < w and 0 <= y < h:
if a[y][x] == "#":
queue.append([y, x])
visited[y][x] = True
print("Possible" if judge() else "Impossible")
bfs(queue)
|
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
39,
0,
13,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
4,
13,
4,
13,
0,
13,
4,
18,
13,
13,
13,
0,
13,
13,
0,
13,
17,
28,
13,
18,
13,
39,
17,
0,
13,
4,
18,
17,
13,
13,
0,
13,
4,
18,
13,
13,
17,
0,
13,
2,
2,
4,
13,
13,
17,
4,
18,
18,
13,
39,
17,
13,
17,
14,
2,
13,
13,
4,
13,
17,
4,
13,
0,
13,
13,
0,
13,
13,
0,
13,
18,
13,
13,
0,
13,
13,
0,
13,
17,
28,
13,
18,
13,
39,
17,
0,
13,
4,
18,
17,
13,
13,
0,
13,
4,
18,
13,
13,
17,
0,
13,
2,
2,
4,
13,
13,
17,
4,
18,
18,
13,
39,
17,
13,
17,
14,
2,
13,
13,
4,
13,
17,
4,
13,
0,
13,
13,
0,
13,
13,
4,
13,
17,
10,
4,
13,
10,
13,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13,
10,
13,
13,
10,
13,
13,
10,
13,
13,
10,
2,
13,
10,
18,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
2,
13,
10,
4,
13
] |
[
[
222,
4
],
[
222,
13
],
[
17,
16
],
[
223,
19
],
[
186,
23
],
[
27,
26
],
[
223,
29
],
[
34,
31
],
[
187,
32
],
[
26,
33
],
[
207,
39
],
[
187,
44
],
[
201,
46
],
[
205,
47
],
[
213,
49
],
[
53,
52
],
[
208,
54
],
[
187,
54
],
[
198,
58
],
[
52,
63
],
[
168,
65
],
[
199,
68
],
[
192,
72
],
[
199,
77
],
[
199,
82
],
[
193,
89
],
[
202,
90
],
[
190,
90
],
[
189,
97
],
[
169,
98
],
[
177,
100
],
[
193,
101
],
[
195,
103
],
[
208,
105
],
[
187,
105
],
[
174,
108
],
[
223,
109
],
[
216,
111
],
[
115,
114
],
[
196,
116
],
[
208,
116
],
[
187,
116
],
[
210,
120
],
[
114,
125
],
[
180,
127
],
[
211,
130
],
[
199,
130
],
[
219,
134
],
[
211,
139
],
[
199,
139
],
[
211,
144
],
[
199,
144
],
[
220,
151
],
[
193,
151
],
[
175,
152
],
[
190,
152
],
[
202,
152
],
[
184,
152
],
[
183,
159
],
[
181,
160
],
[
169,
160
],
[
171,
162
],
[
220,
163
],
[
193,
163
],
[
168,
169
],
[
220,
171
],
[
193,
171
],
[
171,
172
],
[
223,
174
],
[
174,
175
],
[
193,
177
],
[
177,
178
],
[
180,
181
],
[
181,
183
],
[
169,
183
],
[
183,
184
],
[
186,
187
],
[
169,
189
],
[
189,
190
],
[
192,
193
],
[
195,
196
],
[
198,
199
],
[
205,
201
],
[
201,
202
],
[
222,
205
],
[
207,
208
],
[
210,
211
],
[
213,
214
],
[
216,
217
],
[
219,
220
],
[
222,
223
]
] |
[
"import numpy as np\n\n# 盤面の受け取り\nH,W = map(int,input().split())\nboard = [[] for _ in range(H)]\nfor i in range(H):\n board[i] = list(input())\n\nboard = np.array(board)\n\nminnum = W\nmaxnum = 0\nfor row in board[::-1]:\n S = \"\".join(row)\n left = S.find(\"#\")\n right = len(S) - 1 - S[::-1].find(\"#\")\n if right > minnum:\n print(\"Impossible\")\n exit()\n minnum = left\n maxnum = right\n\nboard = board.T\n\nminnum = H\nmaxnum = 0\nfor row in board[::-1]:\n S = \"\".join(row)\n left = S.find(\"#\")\n right = len(S) - 1 - S[::-1].find(\"#\")\n if right > minnum:\n print(\"Impossible\")\n exit()\n minnum = left\n maxnum = right\n\nprint(\"Possible\")",
"import numpy as np",
"numpy",
"H,W = map(int,input().split())",
"H",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"[] for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"[]",
"board = [[] for _ in range(H)]",
"board",
"[[] for _ in range(H)]",
"for i in range(H):\n board[i] = list(input())",
"i",
"range(H)",
"range",
"H",
"board[i] = list(input())",
"board[i]",
"board",
"i",
"list(input())",
"list",
"input()",
"input",
"board = np.array(board)",
"board",
"np.array(board)",
"np.array",
"np",
"array",
"board",
"minnum = W",
"minnum",
"W",
"maxnum = 0",
"maxnum",
"0",
"for row in board[::-1]:\n S = \"\".join(row)\n left = S.find(\"#\")\n right = len(S) - 1 - S[::-1].find(\"#\")\n if right > minnum:\n print(\"Impossible\")\n exit()\n minnum = left\n maxnum = right",
"row",
"board[::-1]",
"board",
"::-1",
"-1",
"S = \"\".join(row)",
"S",
"\"\".join(row)",
"\"\".join",
"\"\"",
"join",
"row",
"left = S.find(\"#\")",
"left",
"S.find(\"#\")",
"S.find",
"S",
"find",
"\"#\"",
"right = len(S) - 1 - S[::-1].find(\"#\")",
"right",
"len(S) - 1 - S[::-1].find(\"#\")",
"len(S) - 1",
"len(S)",
"len",
"S",
"1",
"S[::-1].find(\"#\")",
"[::-1].find",
"[::-1]",
"S",
"::-1",
"-1",
"find",
"\"#\"",
"if right > minnum:\n print(\"Impossible\")\n exit()\n ",
"right > minnum",
"right",
"minnum",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"exit()",
"exit",
"minnum = left",
"minnum",
"left",
"maxnum = right",
"maxnum",
"right",
"board = board.T",
"board",
"board.T",
"board",
"T",
"minnum = H",
"minnum",
"H",
"maxnum = 0",
"maxnum",
"0",
"for row in board[::-1]:\n S = \"\".join(row)\n left = S.find(\"#\")\n right = len(S) - 1 - S[::-1].find(\"#\")\n if right > minnum:\n print(\"Impossible\")\n exit()\n minnum = left\n maxnum = right",
"row",
"board[::-1]",
"board",
"::-1",
"-1",
"S = \"\".join(row)",
"S",
"\"\".join(row)",
"\"\".join",
"\"\"",
"join",
"row",
"left = S.find(\"#\")",
"left",
"S.find(\"#\")",
"S.find",
"S",
"find",
"\"#\"",
"right = len(S) - 1 - S[::-1].find(\"#\")",
"right",
"len(S) - 1 - S[::-1].find(\"#\")",
"len(S) - 1",
"len(S)",
"len",
"S",
"1",
"S[::-1].find(\"#\")",
"[::-1].find",
"[::-1]",
"S",
"::-1",
"-1",
"find",
"\"#\"",
"if right > minnum:\n print(\"Impossible\")\n exit()\n ",
"right > minnum",
"right",
"minnum",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"exit()",
"exit",
"minnum = left",
"minnum",
"left",
"maxnum = right",
"maxnum",
"right",
"print(\"Possible\")",
"print",
"\"Possible\"",
"left = S.find(\"#\")",
"S.find(\"#\")",
"left",
"maxnum = right",
"right",
"maxnum",
"minnum = H",
"H",
"minnum",
"maxnum = right",
"right",
"maxnum",
"left = S.find(\"#\")",
"S.find(\"#\")",
"left",
"minnum = left",
"left",
"minnum",
"board = [[] for _ in range(H)]",
"[[] for _ in range(H)]",
"board",
"minnum = left",
"left",
"minnum",
"right = len(S) - 1 - S[::-1].find(\"#\")",
"len(S) - 1 - S[::-1].find(\"#\")",
"right",
"board = board.T",
"board.T",
"board",
"S = \"\".join(row)",
"\"\".join(row)",
"S",
"minnum = W",
"W",
"minnum",
"W = map(int,input().split())",
"map(int,input().split())",
"W",
"board = np.array(board)",
"np.array(board)",
"board",
"S = \"\".join(row)",
"\"\".join(row)",
"S",
"maxnum = 0",
"0",
"maxnum",
"maxnum = 0",
"0",
"maxnum",
"right = len(S) - 1 - S[::-1].find(\"#\")",
"len(S) - 1 - S[::-1].find(\"#\")",
"right",
"H,W = map(int,input().split())",
"map(int,input().split())",
"H"
] |
import numpy as np
# 盤面の受け取り
H,W = map(int,input().split())
board = [[] for _ in range(H)]
for i in range(H):
board[i] = list(input())
board = np.array(board)
minnum = W
maxnum = 0
for row in board[::-1]:
S = "".join(row)
left = S.find("#")
right = len(S) - 1 - S[::-1].find("#")
if right > minnum:
print("Impossible")
exit()
minnum = left
maxnum = right
board = board.T
minnum = H
maxnum = 0
for row in board[::-1]:
S = "".join(row)
left = S.find("#")
right = len(S) - 1 - S[::-1].find("#")
if right > minnum:
print("Impossible")
exit()
minnum = left
maxnum = right
print("Possible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
2,
4,
13,
4,
13,
39,
17,
0,
18,
18,
13,
17,
2,
13,
17,
17,
4,
18,
13,
13,
2,
39,
17,
2,
13,
17,
12,
13,
14,
2,
2,
2,
13,
13,
2,
13,
13,
2,
18,
18,
13,
13,
13,
17,
29,
14,
2,
18,
18,
13,
13,
13,
17,
4,
13,
17,
4,
13,
4,
13,
2,
13,
17,
13,
4,
13,
13,
2,
13,
17,
23,
13,
23,
13,
0,
13,
17,
28,
13,
13,
28,
13,
13,
14,
2,
13,
17,
0,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
17,
4,
13,
17,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
12,
13,
10,
17,
13,
10,
39,
13
] |
[
[
136,
2
],
[
136,
11
],
[
145,
13
],
[
17,
16
],
[
137,
19
],
[
146,
22
],
[
39,
32
],
[
146,
34
],
[
131,
37
],
[
146,
42
],
[
131,
48
],
[
95,
56
],
[
131,
57
],
[
97,
59
],
[
137,
60
],
[
146,
64
],
[
97,
65
],
[
95,
66
],
[
146,
73
],
[
97,
74
],
[
95,
75
],
[
95,
85
],
[
97,
87
],
[
95,
90
],
[
97,
92
],
[
95,
95
],
[
97,
97
],
[
142,
99
],
[
103,
102
],
[
146,
102
],
[
106,
105
],
[
102,
105
],
[
105,
109
],
[
133,
112
],
[
134,
116
],
[
143,
116
],
[
137,
119
],
[
131,
120
],
[
140,
123
],
[
136,
131
],
[
133,
134
],
[
136,
137
],
[
142,
143
],
[
145,
146
]
] |
[
"h, w = map(int, input().split())\nl = []\nfor i in range(h):\n l.append(list(input()) + [\".\"])\nl[-1][w-1] = \"g\"\nl.append([\".\"]*(w+1))\n\ndef dfs(x, y):\n if x == w or y == h or l[y][x] == \".\":\n return\n elif l[y][x] == \"g\":\n print(\"Possible\")\n exit()\n else:\n dfs(x+1, y)\n dfs(x, y+1)\n\ncnt = 0\nfor i in l:\n for j in i:\n if j == \"#\":\n cnt += 1\n\nif cnt == h + w - 2:\n dfs(0, 0)\nprint(\"Impossible\")",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"l = []",
"l",
"[]",
"for i in range(h):\n l.append(list(input()) + [\".\"])",
"i",
"range(h)",
"range",
"h",
"l.append(list(input()) + [\".\"])",
"l.append",
"l",
"append",
"list(input()) + [\".\"]",
"list(input())",
"list",
"input()",
"input",
"[\".\"]",
"\".\"",
"l[-1][w-1] = \"g\"",
"l[-1][w-1]",
"[-1]",
"l",
"-1",
"w-1",
"w",
"1",
"\"g\"",
"l.append([\".\"]*(w+1))",
"l.append",
"l",
"append",
"[\".\"]*(w+1)",
"[\".\"]",
"\".\"",
"w+1",
"w",
"1",
"def dfs(x, y):\n if x == w or y == h or l[y][x] == \".\":\n return\n elif l[y][x] == \"g\":\n print(\"Possible\")\n exit()\n else:\n dfs(x+1, y)\n dfs(x, y+1)",
"dfs",
"if x == w or y == h or l[y][x] == \".\":\n return\n elif l[y][x] == \"g\":\n print(\"Possible\")\n exit()\n else:\n dfs(x+1, y)\n dfs(x, y+1)",
"x == w or y == h or l[y][x] == \".\"",
"x == w or y == h",
"x == w",
"x",
"w",
"y == h",
"y",
"h",
"l[y][x] == \".\"",
"l[y][x]",
"[y]",
"l",
"y",
"x",
"\".\"",
"return",
"elif l[y][x] == \"g\":\n print(\"Possible\")\n exit()\n ",
"l[y][x] == \"g\"",
"l[y][x]",
"[y]",
"l",
"y",
"x",
"\"g\"",
"print(\"Possible\")",
"print",
"\"Possible\"",
"exit()",
"exit",
"dfs(x+1, y)",
"dfs",
"x+1",
"x",
"1",
"y",
"dfs(x, y+1)",
"dfs",
"x",
"y+1",
"y",
"1",
"x",
"x",
"y",
"y",
"cnt = 0",
"cnt",
"0",
"for i in l:\n for j in i:\n if j == \"#\":\n cnt += 1",
"i",
"l",
"for j in i:\n if j == \"#\":\n cnt += 1",
"j",
"i",
"if j == \"#\":\n cnt += 1",
"j == \"#\"",
"j",
"\"#\"",
"cnt += 1",
"cnt",
"1",
"if cnt == h + w - 2:\n dfs(0, 0)",
"cnt == h + w - 2",
"cnt",
"h + w - 2",
"h + w",
"h",
"w",
"2",
"dfs(0, 0)",
"dfs",
"0",
"0",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"cnt += 1",
"1",
"cnt",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h",
"def dfs(x, y):\n if x == w or y == h or l[y][x] == \".\":\n return\n elif l[y][x] == \"g\":\n print(\"Possible\")\n exit()\n else:\n dfs(x+1, y)\n dfs(x, y+1)",
"def dfs(x, y):\n if x == w or y == h or l[y][x] == \".\":\n return\n elif l[y][x] == \"g\":\n print(\"Possible\")\n exit()\n else:\n dfs(x+1, y)\n dfs(x, y+1)",
"dfs",
"cnt = 0",
"0",
"cnt",
"l = []",
"[]",
"l"
] |
h, w = map(int, input().split())
l = []
for i in range(h):
l.append(list(input()) + ["."])
l[-1][w-1] = "g"
l.append(["."]*(w+1))
def dfs(x, y):
if x == w or y == h or l[y][x] == ".":
return
elif l[y][x] == "g":
print("Possible")
exit()
else:
dfs(x+1, y)
dfs(x, y+1)
cnt = 0
for i in l:
for j in i:
if j == "#":
cnt += 1
if cnt == h + w - 2:
dfs(0, 0)
print("Impossible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
2,
39,
17,
13,
0,
13,
13,
12,
13,
0,
18,
18,
13,
13,
13,
17,
14,
2,
2,
13,
2,
13,
17,
2,
13,
2,
13,
17,
29,
14,
2,
2,
2,
13,
17,
13,
2,
18,
18,
13,
13,
2,
13,
17,
17,
4,
13,
13,
2,
13,
17,
14,
2,
2,
2,
13,
17,
13,
2,
18,
18,
13,
2,
13,
17,
13,
17,
4,
13,
2,
13,
17,
13,
23,
13,
23,
13,
4,
13,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
14,
40,
18,
18,
13,
13,
13,
0,
13,
17,
14,
13,
4,
13,
17,
4,
13,
17,
10,
12,
13,
10,
13,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
13,
13
] |
[
[
164,
2
],
[
164,
11
],
[
15,
14
],
[
162,
17
],
[
170,
22
],
[
27,
26
],
[
162,
29
],
[
165,
34
],
[
155,
36
],
[
46,
41
],
[
156,
43
],
[
105,
44
],
[
107,
45
],
[
105,
50
],
[
162,
52
],
[
107,
55
],
[
165,
57
],
[
107,
64
],
[
165,
66
],
[
171,
70
],
[
105,
71
],
[
107,
73
],
[
105,
78
],
[
107,
80
],
[
105,
86
],
[
162,
88
],
[
171,
92
],
[
105,
94
],
[
107,
96
],
[
105,
101
],
[
107,
103
],
[
105,
105
],
[
107,
107
],
[
153,
109
],
[
167,
113
],
[
117,
116
],
[
162,
119
],
[
122,
121
],
[
165,
124
],
[
171,
129
],
[
116,
130
],
[
121,
131
],
[
156,
137
],
[
116,
138
],
[
121,
139
],
[
158,
141
],
[
155,
156
],
[
158,
159
],
[
164,
162
],
[
164,
165
],
[
167,
168
],
[
170,
171
]
] |
[
"H, W = map(int, input().split())\nG = [input() for i in range(H)]\ndone = [[False]*W for i in range(H)]\ndef dfs(h, w):\n done[h][w] = True\n if h == H-1 and w == W-1:\n return\n if w+1 < W and G[h][w+1] == \"#\":\n dfs(h, w+1)\n elif h+1 < H and G[h+1][w] == \"#\":\n dfs(h+1, w)\ndfs(0, 0)\nans = True\nfor i in range(H):\n for j in range(W):\n if G[i][j] == \"#\":\n if not done[i][j]:\n ans = False\nif ans:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"input() for i in range(H)",
"for i in range(H)",
"i",
"range(H)",
"range",
"H",
"for i in range(H)",
"input()",
"input",
"G = [input() for i in range(H)]",
"G",
"[input() for i in range(H)]",
"[False]*W for i in range(H)",
"for i in range(H)",
"i",
"range(H)",
"range",
"H",
"for i in range(H)",
"[False]*W",
"[False]",
"False",
"W",
"done = [[False]*W for i in range(H)]",
"done",
"[[False]*W for i in range(H)]",
"def dfs(h, w):\n done[h][w] = True\n if h == H-1 and w == W-1:\n return\n if w+1 < W and G[h][w+1] == \"#\":\n dfs(h, w+1)\n elif h+1 < H and G[h+1][w] == \"#\":\n dfs(h+1, w)",
"dfs",
"done[h][w] = True",
"done[h][w]",
"[h]",
"done",
"h",
"w",
"True",
"if h == H-1 and w == W-1:\n return\n ",
"h == H-1 and w == W-1",
"h == H-1",
"h",
"H-1",
"H",
"1",
"w == W-1",
"w",
"W-1",
"W",
"1",
"return",
"if w+1 < W and G[h][w+1] == \"#\":\n dfs(h, w+1)\n elif h+1 < H and G[h+1][w] == \"#\":\n dfs(h+1, w)",
"w+1 < W and G[h][w+1] == \"#\"",
"w+1 < W",
"w+1",
"w",
"1",
"W",
"G[h][w+1] == \"#\"",
"G[h][w+1]",
"[h]",
"G",
"h",
"w+1",
"w",
"1",
"\"#\"",
"dfs(h, w+1)",
"dfs",
"h",
"w+1",
"w",
"1",
"elif h+1 < H and G[h+1][w] == \"#\":\n dfs(h+1, w)",
"h+1 < H and G[h+1][w] == \"#\"",
"h+1 < H",
"h+1",
"h",
"1",
"H",
"G[h+1][w] == \"#\"",
"G[h+1][w]",
"[h+1]",
"G",
"h+1",
"h",
"1",
"w",
"\"#\"",
"dfs(h+1, w)",
"dfs",
"h+1",
"h",
"1",
"w",
"h",
"h",
"w",
"w",
"dfs(0, 0)",
"dfs",
"0",
"0",
"ans = True",
"ans",
"True",
"for i in range(H):\n for j in range(W):\n if G[i][j] == \"#\":\n if not done[i][j]:\n ans = False",
"i",
"range(H)",
"range",
"H",
"for j in range(W):\n if G[i][j] == \"#\":\n if not done[i][j]:\n ans = False",
"j",
"range(W)",
"range",
"W",
"if G[i][j] == \"#\":\n if not done[i][j]:\n ans = False",
"G[i][j] == \"#\"",
"G[i][j]",
"[i]",
"G",
"i",
"j",
"\"#\"",
"if not done[i][j]:\n ans = False",
"not done[i][j]",
"done[i][j]",
"[i]",
"done",
"i",
"j",
"ans = False",
"ans",
"False",
"if ans:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"ans",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"def dfs(h, w):\n done[h][w] = True\n if h == H-1 and w == W-1:\n return\n if w+1 < W and G[h][w+1] == \"#\":\n dfs(h, w+1)\n elif h+1 < H and G[h+1][w] == \"#\":\n dfs(h+1, w)",
"def dfs(h, w):\n done[h][w] = True\n if h == H-1 and w == W-1:\n return\n if w+1 < W and G[h][w+1] == \"#\":\n dfs(h, w+1)\n elif h+1 < H and G[h+1][w] == \"#\":\n dfs(h+1, w)",
"dfs",
"done = [[False]*W for i in range(H)]",
"[[False]*W for i in range(H)]",
"done",
"ans = False",
"False",
"ans",
"H, W = map(int, input().split())",
"map(int, input().split())",
"H",
"W = map(int, input().split())",
"map(int, input().split())",
"W",
"ans = True",
"True",
"ans",
"G = [input() for i in range(H)]",
"[input() for i in range(H)]",
"G"
] |
H, W = map(int, input().split())
G = [input() for i in range(H)]
done = [[False]*W for i in range(H)]
def dfs(h, w):
done[h][w] = True
if h == H-1 and w == W-1:
return
if w+1 < W and G[h][w+1] == "#":
dfs(h, w+1)
elif h+1 < H and G[h+1][w] == "#":
dfs(h+1, w)
dfs(0, 0)
ans = True
for i in range(H):
for j in range(W):
if G[i][j] == "#":
if not done[i][j]:
ans = False
if ans:
print("Possible")
else:
print("Impossible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
39,
0,
13,
13,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
4,
18,
18,
13,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
2,
4,
13,
13,
17,
14,
2,
2,
4,
13,
18,
13,
13,
18,
13,
2,
13,
17,
2,
18,
18,
13,
13,
17,
18,
18,
13,
2,
13,
17,
17,
9,
0,
13,
17,
14,
13,
4,
13,
17,
4,
13,
17,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
13,
13,
10,
13,
13
] |
[
[
119,
2
],
[
119,
11
],
[
15,
14
],
[
120,
17
],
[
128,
24
],
[
29,
28
],
[
120,
31
],
[
125,
35
],
[
39,
38
],
[
120,
41
],
[
44,
43
],
[
117,
46
],
[
129,
51
],
[
38,
52
],
[
43,
53
],
[
126,
58
],
[
38,
59
],
[
43,
61
],
[
113,
63
],
[
67,
66
],
[
126,
72
],
[
126,
80
],
[
66,
81
],
[
126,
83
],
[
66,
85
],
[
126,
90
],
[
66,
91
],
[
126,
95
],
[
66,
97
],
[
122,
102
],
[
113,
114
],
[
119,
117
],
[
119,
120
],
[
122,
123
],
[
125,
126
],
[
128,
129
]
] |
[
"# 631\n\nh, w = map(int, input().split())\na = [str(input()) for _ in range(h)]\njud = [[] for _ in range(h)]\n\nfor i in range(h):\n for j in range(w):\n if a[i][j] == '#':\n jud[i].append(j)\n\n# print(jud)\n\nflag = True\n\nfor k in range(len(jud) - 1):\n if max(jud[k]) in jud[k + 1] and jud[k][-1] == jud[k + 1][0]:\n continue\n else:\n flag = False\n\nif flag:\n print(\"Possible\")\nelse:\n print('Impossible')",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"str(input()) for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"str(input())",
"str",
"input()",
"input",
"a = [str(input()) for _ in range(h)]",
"a",
"[str(input()) for _ in range(h)]",
"[] for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"[]",
"jud = [[] for _ in range(h)]",
"jud",
"[[] for _ in range(h)]",
"for i in range(h):\n for j in range(w):\n if a[i][j] == '#':\n jud[i].append(j)\n\n# print(jud)",
"i",
"range(h)",
"range",
"h",
"for j in range(w):\n if a[i][j] == '#':\n jud[i].append(j)\n\n# print(jud)",
"j",
"range(w)",
"range",
"w",
"if a[i][j] == '#':\n jud[i].append(j)\n\n# print(jud)",
"a[i][j] == '#'",
"a[i][j]",
"[i]",
"a",
"i",
"j",
"'#'",
"jud[i].append(j)",
"[i].append",
"[i]",
"jud",
"i",
"append",
"j",
"flag = True",
"flag",
"True",
"for k in range(len(jud) - 1):\n if max(jud[k]) in jud[k + 1] and jud[k][-1] == jud[k + 1][0]:\n continue\n else:\n flag = False",
"k",
"range(len(jud) - 1)",
"range",
"len(jud) - 1",
"len(jud)",
"len",
"jud",
"1",
"if max(jud[k]) in jud[k + 1] and jud[k][-1] == jud[k + 1][0]:\n continue\n else:\n flag = False",
"max(jud[k]) in jud[k + 1] and jud[k][-1] == jud[k + 1][0]",
"max(jud[k]) in jud[k + 1]",
"max(jud[k])",
"max",
"jud[k]",
"jud",
"k",
"jud[k + 1]",
"jud",
"k + 1",
"k",
"1",
"jud[k][-1] == jud[k + 1][0]",
"jud[k][-1]",
"[k]",
"jud",
"k",
"-1",
"jud[k + 1][0]",
"[k + 1]",
"jud",
"k + 1",
"k",
"1",
"0",
"continue",
"flag = False",
"flag",
"False",
"if flag:\n print(\"Possible\")\nelse:\n print('Impossible')",
"flag",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print('Impossible')",
"print",
"'Impossible'",
"flag = True",
"True",
"flag",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h",
"flag = False",
"False",
"flag",
"jud = [[] for _ in range(h)]",
"[[] for _ in range(h)]",
"jud",
"a = [str(input()) for _ in range(h)]",
"[str(input()) for _ in range(h)]",
"a"
] |
# 631
h, w = map(int, input().split())
a = [str(input()) for _ in range(h)]
jud = [[] for _ in range(h)]
for i in range(h):
for j in range(w):
if a[i][j] == '#':
jud[i].append(j)
# print(jud)
flag = True
for k in range(len(jud) - 1):
if max(jud[k]) in jud[k + 1] and jud[k][-1] == jud[k + 1][0]:
continue
else:
flag = False
if flag:
print("Possible")
else:
print('Impossible')
|
[
7,
12,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
2,
2,
39,
17,
4,
13,
4,
13,
39,
17,
0,
13,
2,
2,
39,
2,
39,
17,
2,
13,
17,
13,
39,
2,
39,
17,
2,
13,
17,
0,
13,
17,
13,
17,
42,
17,
0,
18,
18,
13,
13,
13,
17,
14,
2,
2,
13,
13,
2,
13,
13,
3,
14,
2,
18,
18,
13,
2,
13,
17,
13,
18,
18,
13,
13,
2,
13,
17,
4,
13,
17,
4,
13,
14,
2,
18,
18,
13,
2,
13,
17,
13,
17,
0,
13,
17,
0,
13,
17,
28,
13,
13,
14,
4,
13,
13,
4,
13,
17,
3,
4,
13,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13
] |
[
[
5,
4
],
[
5,
15
],
[
19,
18
],
[
4,
21
],
[
35,
34
],
[
15,
42
],
[
15,
50
],
[
54,
53
],
[
56,
55
],
[
65,
60
],
[
34,
62
],
[
53,
63
],
[
107,
63
],
[
55,
64
],
[
110,
64
],
[
53,
69
],
[
107,
69
],
[
4,
70
],
[
55,
72
],
[
110,
72
],
[
15,
73
],
[
34,
79
],
[
53,
81
],
[
107,
81
],
[
55,
83
],
[
110,
83
],
[
34,
86
],
[
53,
87
],
[
107,
87
],
[
55,
89
],
[
110,
89
],
[
34,
100
],
[
53,
102
],
[
107,
102
],
[
55,
104
],
[
110,
104
],
[
108,
107
],
[
111,
110
],
[
114,
113
],
[
34,
113
],
[
134,
131
]
] |
[
"def main():\n h, w = list(map(int, input().split()))\n A = [['.'] * (w + 2)] + [['.', ] + list(input()) + ['.', ] for _ in range(h)] + [['.'] * (w + 2)]\n i, j = 1, 1\n while True:\n A[i][j] = '.'\n if i == h and j == w:\n break\n if A[i + 1][j] == A[i][j + 1]:\n print('Impossible')\n exit()\n if A[i + 1][j] == '#':\n i += 1\n else:\n j += 1\n for a in A:\n if any([i == '#' for i in a]):\n print('Impossible')\n break\n else:\n print('Possible')\n\nif __name__ == '__main__':\n main()",
"def main():\n h, w = list(map(int, input().split()))\n A = [['.'] * (w + 2)] + [['.', ] + list(input()) + ['.', ] for _ in range(h)] + [['.'] * (w + 2)]\n i, j = 1, 1\n while True:\n A[i][j] = '.'\n if i == h and j == w:\n break\n if A[i + 1][j] == A[i][j + 1]:\n print('Impossible')\n exit()\n if A[i + 1][j] == '#':\n i += 1\n else:\n j += 1\n for a in A:\n if any([i == '#' for i in a]):\n print('Impossible')\n break\n else:\n print('Possible')",
"main",
"h, w = list(map(int, input().split()))",
"h",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"['.', ] + list(input()) + ['.', ] for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"['.', ] + list(input()) + ['.', ]",
"['.', ] + list(input())",
"['.', ]",
"'.'",
"list(input())",
"list",
"input()",
"input",
"['.', ]",
"'.'",
"A = [['.'] * (w + 2)] + [['.', ] + list(input()) + ['.', ] for _ in range(h)] + [['.'] * (w + 2)]",
"A",
"[['.'] * (w + 2)] + [['.', ] + list(input()) + ['.', ] for _ in range(h)] + [['.'] * (w + 2)]",
"[['.'] * (w + 2)] + [['.', ] + list(input()) + ['.', ] for _ in range(h)]",
"[['.'] * (w + 2)]",
"['.'] * (w + 2)",
"['.']",
"'.'",
"w + 2",
"w",
"2",
"[['.', ] + list(input()) + ['.', ] for _ in range(h)]",
"[['.'] * (w + 2)]",
"['.'] * (w + 2)",
"['.']",
"'.'",
"w + 2",
"w",
"2",
"i, j = 1, 1",
"i",
"1",
"j",
"1",
"while True:\n A[i][j] = '.'\n if i == h and j == w:\n break\n if A[i + 1][j] == A[i][j + 1]:\n print('Impossible')\n exit()\n if A[i + 1][j] == '#':\n i += 1\n else:\n j += 1\n ",
"True",
"A[i][j] = '.'",
"A[i][j]",
"[i]",
"A",
"i",
"j",
"'.'",
"if i == h and j == w:\n break\n ",
"i == h and j == w",
"i == h",
"i",
"h",
"j == w",
"j",
"w",
"break",
"if A[i + 1][j] == A[i][j + 1]:\n print('Impossible')\n exit()\n ",
"A[i + 1][j] == A[i][j + 1]",
"A[i + 1][j]",
"[i + 1]",
"A",
"i + 1",
"i",
"1",
"j",
"A[i][j + 1]",
"[i]",
"A",
"i",
"j + 1",
"j",
"1",
"print('Impossible')",
"print",
"'Impossible'",
"exit()",
"exit",
"if A[i + 1][j] == '#':\n i += 1\n else:\n j += 1\n ",
"A[i + 1][j] == '#'",
"A[i + 1][j]",
"[i + 1]",
"A",
"i + 1",
"i",
"1",
"j",
"'#'",
"i += 1",
"i",
"1",
"j += 1",
"j",
"1",
"for a in A:\n if any([i == '#' for i in a]):\n print('Impossible')\n break\n else:\n print('Possible')",
"a",
"A",
"if any([i == '#' for i in a]):\n print('Impossible')\n break\n ",
"any([i == '#' for i in a])",
"any",
"[i == '#' for i in a]",
"print('Impossible')",
"print",
"'Impossible'",
"break",
"print('Possible')",
"print",
"'Possible'",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"def main():\n h, w = list(map(int, input().split()))\n A = [['.'] * (w + 2)] + [['.', ] + list(input()) + ['.', ] for _ in range(h)] + [['.'] * (w + 2)]\n i, j = 1, 1\n while True:\n A[i][j] = '.'\n if i == h and j == w:\n break\n if A[i + 1][j] == A[i][j + 1]:\n print('Impossible')\n exit()\n if A[i + 1][j] == '#':\n i += 1\n else:\n j += 1\n for a in A:\n if any([i == '#' for i in a]):\n print('Impossible')\n break\n else:\n print('Possible')",
"def main():\n h, w = list(map(int, input().split()))\n A = [['.'] * (w + 2)] + [['.', ] + list(input()) + ['.', ] for _ in range(h)] + [['.'] * (w + 2)]\n i, j = 1, 1\n while True:\n A[i][j] = '.'\n if i == h and j == w:\n break\n if A[i + 1][j] == A[i][j + 1]:\n print('Impossible')\n exit()\n if A[i + 1][j] == '#':\n i += 1\n else:\n j += 1\n for a in A:\n if any([i == '#' for i in a]):\n print('Impossible')\n break\n else:\n print('Possible')",
"main"
] |
def main():
h, w = list(map(int, input().split()))
A = [['.'] * (w + 2)] + [['.', ] + list(input()) + ['.', ] for _ in range(h)] + [['.'] * (w + 2)]
i, j = 1, 1
while True:
A[i][j] = '.'
if i == h and j == w:
break
if A[i + 1][j] == A[i][j + 1]:
print('Impossible')
exit()
if A[i + 1][j] == '#':
i += 1
else:
j += 1
for a in A:
if any([i == '#' for i in a]):
print('Impossible')
break
else:
print('Possible')
if __name__ == '__main__':
main()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
15,
0,
13,
39,
39,
17,
17,
39,
17,
17,
41,
28,
13,
4,
13,
13,
4,
2,
39,
17,
13,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
2,
39,
17,
13,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
0,
13,
4,
13,
39,
39,
17,
17,
42,
13,
0,
13,
4,
18,
13,
13,
13,
28,
13,
13,
13,
0,
13,
2,
13,
13,
13,
2,
13,
13,
14,
40,
2,
40,
17,
13,
13,
14,
40,
2,
40,
17,
13,
13,
14,
18,
18,
13,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
18,
18,
13,
13,
13,
17,
0,
18,
18,
13,
13,
13,
2,
18,
18,
13,
13,
13,
17,
4,
18,
13,
13,
39,
13,
13,
0,
13,
4,
13,
4,
18,
13,
13,
17,
4,
13,
8,
2,
2,
18,
18,
13,
17,
17,
17,
13,
17,
17,
10,
13,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
2,
13,
10,
13,
13,
10,
39,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
205,
2
],
[
205,
11
],
[
15,
14
],
[
203,
17
],
[
193,
22
],
[
196,
26
],
[
37,
36
],
[
203,
39
],
[
206,
44
],
[
187,
46
],
[
51,
50
],
[
203,
53
],
[
206,
58
],
[
178,
60
],
[
68,
63
],
[
179,
65
],
[
181,
70
],
[
211,
80
],
[
182,
83
],
[
211,
85
],
[
199,
91
],
[
212,
93
],
[
190,
95
],
[
209,
97
],
[
200,
104
],
[
206,
105
],
[
191,
111
],
[
203,
112
],
[
179,
116
],
[
191,
117
],
[
200,
118
],
[
194,
123
],
[
191,
124
],
[
200,
125
],
[
133,
128
],
[
179,
130
],
[
191,
131
],
[
200,
132
],
[
140,
135
],
[
188,
137
],
[
191,
138
],
[
200,
139
],
[
188,
143
],
[
209,
144
],
[
212,
145
],
[
182,
149
],
[
184,
155
],
[
188,
170
],
[
185,
174
],
[
178,
179
],
[
181,
182
],
[
184,
185
],
[
187,
188
],
[
190,
191
],
[
193,
194
],
[
196,
197
],
[
199,
200
],
[
205,
203
],
[
205,
206
],
[
211,
209
],
[
211,
212
]
] |
[
"H,W = map(int,input().split())\nA = [input() for i in range(H)]\n\nfrom collections import deque\ndxy = [(0,1),(1,0)]\ndist = [[0]*W for i in range(H)]\nvisited = [[0]*W for i in range(H)]\nvisited[0][0] = 1\nq = deque([(0,0)])\nwhile q:\n x,y = q.popleft()\n for dx,dy in dxy:\n nx,ny = x+dx,y+dy\n if not 0 <= nx < W: continue\n if not 0 <= ny < H: continue\n if visited[ny][nx]: continue\n if A[ny][nx] == '.': continue\n visited[ny][nx] = 1\n dist[ny][nx] = dist[y][x] + 1\n q.append((nx,ny))\n\ncnt = sum(row.count('#') for row in A)\nprint('Possible' if dist[-1][-1]+1 == cnt else 'Impossible')",
"H,W = map(int,input().split())",
"H",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"input() for i in range(H)",
"for i in range(H)",
"i",
"range(H)",
"range",
"H",
"for i in range(H)",
"input()",
"input",
"A = [input() for i in range(H)]",
"A",
"[input() for i in range(H)]",
"from collections import deque",
"dxy = [(0,1),(1,0)]",
"dxy",
"[(0,1),(1,0)]",
"(0,1)",
"0",
"1",
"(1,0)",
"1",
"0",
"[0]*W for i in range(H)",
"for i in range(H)",
"i",
"range(H)",
"range",
"H",
"for i in range(H)",
"[0]*W",
"[0]",
"0",
"W",
"dist = [[0]*W for i in range(H)]",
"dist",
"[[0]*W for i in range(H)]",
"[0]*W for i in range(H)",
"for i in range(H)",
"i",
"range(H)",
"range",
"H",
"for i in range(H)",
"[0]*W",
"[0]",
"0",
"W",
"visited = [[0]*W for i in range(H)]",
"visited",
"[[0]*W for i in range(H)]",
"visited[0][0] = 1",
"visited[0][0]",
"[0]",
"visited",
"0",
"0",
"1",
"q = deque([(0,0)])",
"q",
"deque([(0,0)])",
"deque",
"[(0,0)]",
"(0,0)",
"0",
"0",
"while q:\n x,y = q.popleft()\n for dx,dy in dxy:\n nx,ny = x+dx,y+dy\n if not 0 <= nx < W: continue\n if not 0 <= ny < H: continue\n if visited[ny][nx]: continue\n if A[ny][nx] == '.': continue\n visited[ny][nx] = 1\n dist[ny][nx] = dist[y][x] + 1\n q.append((nx,ny))",
"q",
"x,y = q.popleft()",
"x",
"q.popleft()",
"q.popleft",
"q",
"popleft",
"y",
"for dx,dy in dxy:\n nx,ny = x+dx,y+dy\n if not 0 <= nx < W: continue\n if not 0 <= ny < H: continue\n if visited[ny][nx]: continue\n if A[ny][nx] == '.': continue\n visited[ny][nx] = 1\n dist[ny][nx] = dist[y][x] + 1\n q.append((nx,ny))",
"dx",
"dy",
"dxy",
"nx,ny = x+dx,y+dy",
"nx",
"x+dx",
"x",
"dx",
"ny",
"y+dy",
"y",
"dy",
"if not 0 <= nx < W: continue\n ",
"not 0 <= nx < W",
"0 <= nx < W",
"0 <= nx",
"0",
"nx",
"W",
"if not 0 <= ny < H: continue\n ",
"not 0 <= ny < H",
"0 <= ny < H",
"0 <= ny",
"0",
"ny",
"H",
"if visited[ny][nx]: continue\n ",
"visited[ny][nx]",
"[ny]",
"visited",
"ny",
"nx",
"if A[ny][nx] == '.': continue\n ",
"A[ny][nx] == '.'",
"A[ny][nx]",
"[ny]",
"A",
"ny",
"nx",
"'.'",
"visited[ny][nx] = 1",
"visited[ny][nx]",
"[ny]",
"visited",
"ny",
"nx",
"1",
"dist[ny][nx] = dist[y][x] + 1",
"dist[ny][nx]",
"[ny]",
"dist",
"ny",
"nx",
"dist[y][x] + 1",
"dist[y][x]",
"[y]",
"dist",
"y",
"x",
"1",
"q.append((nx,ny))",
"q.append",
"q",
"append",
"(nx,ny)",
"nx",
"ny",
"cnt = sum(row.count('#') for row in A)",
"cnt",
"sum(row.count('#') for row in A)",
"sum",
"row.count('#')",
"row.count",
"row",
"count",
"'#'",
"print('Possible' if dist[-1][-1]+1 == cnt else 'Impossible')",
"print",
"'Possible' if dist[-1][-1]+1 == cnt else 'Impossible'",
"dist[-1][-1]+1 == cnt",
"dist[-1][-1]+1",
"dist[-1][-1]",
"[-1]",
"dist",
"-1",
"-1",
"1",
"cnt",
"'Possible'",
"'Impossible'",
"visited = [[0]*W for i in range(H)]",
"[[0]*W for i in range(H)]",
"visited",
"q = deque([(0,0)])",
"deque([(0,0)])",
"q",
"cnt = sum(row.count('#') for row in A)",
"sum(row.count('#') for row in A)",
"cnt",
"dist = [[0]*W for i in range(H)]",
"[[0]*W for i in range(H)]",
"dist",
"ny = x+dx,y+dy",
"y+dy",
"ny",
"A = [input() for i in range(H)]",
"[input() for i in range(H)]",
"A",
"dxy = [(0,1),(1,0)]",
"[(0,1),(1,0)]",
"dxy",
"nx,ny = x+dx,y+dy",
"x+dx",
"nx",
"H,W = map(int,input().split())",
"map(int,input().split())",
"H",
"W = map(int,input().split())",
"map(int,input().split())",
"W",
"y = q.popleft()",
"q.popleft()",
"y",
"x,y = q.popleft()",
"q.popleft()",
"x"
] |
H,W = map(int,input().split())
A = [input() for i in range(H)]
from collections import deque
dxy = [(0,1),(1,0)]
dist = [[0]*W for i in range(H)]
visited = [[0]*W for i in range(H)]
visited[0][0] = 1
q = deque([(0,0)])
while q:
x,y = q.popleft()
for dx,dy in dxy:
nx,ny = x+dx,y+dy
if not 0 <= nx < W: continue
if not 0 <= ny < H: continue
if visited[ny][nx]: continue
if A[ny][nx] == '.': continue
visited[ny][nx] = 1
dist[ny][nx] = dist[y][x] + 1
q.append((nx,ny))
cnt = sum(row.count('#') for row in A)
print('Possible' if dist[-1][-1]+1 == cnt else 'Impossible')
|
[
7,
15,
13,
15,
15,
15,
15,
15,
15,
15,
15,
0,
13,
4,
13,
2,
4,
13,
17,
17,
17,
0,
13,
17,
12,
13,
12,
13,
23,
13,
17,
23,
12,
13,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
13,
12,
13,
23,
13,
23,
13,
17,
41,
28,
13,
4,
13,
13,
4,
4,
13,
13,
13,
12,
13,
23,
13,
23,
13,
23,
13,
17,
0,
13,
4,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
12,
13,
10,
17,
13,
10,
4,
13,
10,
12,
13,
10,
12,
13,
10,
13,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
12,
13,
10,
17,
13
] |
[
[
164,
12
],
[
134,
22
],
[
30,
29
],
[
43,
42
],
[
51,
51
],
[
54,
53
],
[
58,
57
],
[
144,
63
],
[
69,
69
],
[
71,
71
],
[
74,
73
],
[
167,
76
],
[
153,
78
],
[
167,
79
],
[
83,
82
],
[
138,
85
],
[
146,
90
],
[
173,
93
],
[
97,
96
],
[
138,
99
],
[
102,
101
],
[
168,
104
],
[
147,
109
],
[
96,
110
],
[
101,
111
],
[
161,
114
],
[
162,
118
],
[
174,
118
],
[
138,
121
],
[
168,
122
],
[
134,
135
],
[
167,
138
],
[
146,
147
],
[
161,
162
],
[
164,
165
],
[
167,
168
],
[
173,
174
]
] |
[
"import sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush\nfrom math import *\nfrom collections import defaultdict as dd, deque, Counter as C\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom time import perf_counter\nfrom fractions import Fraction\n# sys.setrecursionlimit(int(pow(10, 2)))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"output.txt\", \"w\")\nmod = int(pow(10, 9) + 7)\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(*var, end=\"\\n\"): sys.stdout.write(' '.join(map(str, var))+end)\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n# @lru_cache(None)\n\n\n\n\n\n\nh,w=l()\nA=[input() for i in range(h)]\nans=0\nfor i in range(h):\n for j in range(w):\n if(A[i][j]==\"#\"):\n ans+=1\n\n\n\nif ans==h+w-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"import sys",
"sys",
"from functools import lru_cache, cmp_to_key",
"from heapq import merge, heapify, heappop, heappush",
"from math import *",
"from collections import defaultdict as dd, deque, Counter as C",
"from itertools import combinations as comb, permutations as perm",
"from bisect import bisect_left as bl, bisect_right as br, bisect",
"from time import perf_counter",
"from fractions import Fraction",
"mod = int(pow(10, 9) + 7)",
"mod",
"int(pow(10, 9) + 7)",
"int",
"pow(10, 9) + 7",
"pow(10, 9)",
"pow",
"10",
"9",
"7",
"mod2 = 998244353",
"mod2",
"998244353",
"def data(): return sys.stdin.readline().strip()",
"data",
"def out(*var, end=\"\\n\"): sys.stdout.write(' '.join(map(str, var))+end)",
"out",
"end=\"\\n\"",
"end",
"\"\\n\"",
"*var",
"def l(): return list(sp())",
"l",
"def sl(): return list(ssp())",
"sl",
"def sp(): return map(int, data().split())",
"sp",
"def ssp(): return map(str, data().split())",
"ssp",
"val for i in range(n)",
"for i in range(n)",
"i",
"range(n)",
"range",
"n",
"for i in range(n)",
"val",
"def l1d(n, val=0): return [val for i in range(n)]",
"l1d",
"n",
"n",
"val=0",
"val",
"0",
"l1d(n, val) for j in range(m)",
"for j in range(m)",
"j",
"range(m)",
"range",
"m",
"for j in range(m)",
"l1d(n, val)",
"l1d",
"n",
"val",
"def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n# @lru_cache(None)",
"l2d",
"n",
"n",
"m",
"m",
"val=0",
"val",
"0",
"h,w=l()",
"h",
"l()",
"l",
"w",
"input() for i in range(h)",
"for i in range(h)",
"i",
"range(h)",
"range",
"h",
"for i in range(h)",
"input()",
"input",
"A=[input() for i in range(h)]",
"A",
"[input() for i in range(h)]",
"ans=0",
"ans",
"0",
"for i in range(h):\n for j in range(w):\n if(A[i][j]==\"#\"):\n ans+=1",
"i",
"range(h)",
"range",
"h",
"for j in range(w):\n if(A[i][j]==\"#\"):\n ans+=1",
"j",
"range(w)",
"range",
"w",
"if(A[i][j]==\"#\"):\n ans+=1",
"A[i][j]==\"#\"",
"A[i][j]",
"[i]",
"A",
"i",
"j",
"\"#\"",
"ans+=1",
"ans",
"1",
"if ans==h+w-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"ans==h+w-1",
"ans",
"h+w-1",
"h+w",
"h",
"w",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"def sp(): return map(int, data().split())",
"def sp(): return map(int, data().split())",
"sp",
"mod2 = 998244353",
"998244353",
"mod2",
"h,w=l()",
"l()",
"h",
"def data(): return sys.stdin.readline().strip()",
"def data(): return sys.stdin.readline().strip()",
"data",
"def l1d(n, val=0): return [val for i in range(n)]",
"def l1d(n, val=0): return [val for i in range(n)]",
"l1d",
"A=[input() for i in range(h)]",
"[input() for i in range(h)]",
"A",
"def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n# @lru_cache(None)",
"def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n# @lru_cache(None)",
"l2d",
"def l(): return list(sp())",
"def l(): return list(sp())",
"l",
"def sl(): return list(ssp())",
"def sl(): return list(ssp())",
"sl",
"def ssp(): return map(str, data().split())",
"def ssp(): return map(str, data().split())",
"ssp",
"ans+=1",
"1",
"ans",
"mod = int(pow(10, 9) + 7)",
"int(pow(10, 9) + 7)",
"mod",
"w=l()",
"l()",
"w",
"def out(*var, end=\"\\n\"): sys.stdout.write(' '.join(map(str, var))+end)",
"def out(*var, end=\"\\n\"): sys.stdout.write(' '.join(map(str, var))+end)",
"out",
"ans=0",
"0",
"ans"
] |
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
# @lru_cache(None)
h,w=l()
A=[input() for i in range(h)]
ans=0
for i in range(h):
for j in range(w):
if(A[i][j]=="#"):
ans+=1
if ans==h+w-1:
print("Possible")
else:
print("Impossible")
|
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
4,
13,
0,
13,
39,
17,
17,
0,
13,
39,
17,
17,
0,
13,
39,
39,
17,
17,
42,
13,
0,
13,
4,
18,
13,
13,
0,
13,
17,
14,
2,
13,
39,
2,
13,
17,
2,
13,
17,
0,
18,
18,
13,
2,
13,
17,
2,
13,
17,
17,
28,
13,
13,
14,
40,
4,
18,
13,
13,
17,
17,
4,
13,
17,
4,
18,
13,
13,
4,
13,
17,
3,
28,
13,
4,
13,
17,
0,
13,
2,
18,
13,
17,
18,
13,
13,
0,
13,
2,
18,
13,
17,
18,
13,
13,
14,
2,
2,
40,
40,
17,
13,
2,
13,
17,
40,
40,
17,
13,
2,
13,
17,
2,
18,
18,
13,
13,
13,
17,
4,
18,
13,
13,
39,
13,
13,
0,
13,
17,
14,
40,
13,
17,
4,
13,
17,
3,
0,
18,
18,
13,
18,
13,
17,
18,
13,
17,
17,
10,
2,
13,
10,
2,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
39,
13,
10,
39,
13,
10,
4,
13,
10,
39,
13,
10,
39,
13
] |
[
[
201,
4
],
[
201,
13
],
[
198,
15
],
[
19,
18
],
[
193,
21
],
[
199,
24
],
[
204,
31
],
[
207,
36
],
[
195,
41
],
[
183,
49
],
[
196,
52
],
[
186,
55
],
[
184,
59
],
[
202,
62
],
[
193,
65
],
[
77,
68
],
[
199,
70
],
[
193,
72
],
[
202,
75
],
[
80,
79
],
[
199,
79
],
[
79,
85
],
[
102,
101
],
[
180,
106
],
[
184,
109
],
[
205,
112
],
[
101,
113
],
[
177,
115
],
[
184,
118
],
[
208,
121
],
[
101,
122
],
[
181,
129
],
[
202,
131
],
[
178,
136
],
[
193,
138
],
[
199,
143
],
[
178,
144
],
[
181,
145
],
[
196,
149
],
[
189,
155
],
[
190,
159
],
[
187,
159
],
[
175,
166
],
[
199,
168
],
[
184,
170
],
[
184,
173
],
[
177,
178
],
[
180,
181
],
[
183,
184
],
[
186,
187
],
[
189,
190
],
[
201,
193
],
[
195,
196
],
[
198,
199
],
[
201,
202
],
[
204,
205
],
[
207,
208
]
] |
[
"import sys\nh,w = map(int,input().split())\nA = []\nfor i in range(h):\n A.append(list(input()))\ndx = [1,0,]\ndy = [0,1,]\nB = [[0,0]]\nwhile B:\n S = B.pop()\n cnt = 0\n if S == [w-1,h-1]:\n A[h-1][w-1] = \".\"\n for L in A:\n if L.count(\"#\") != 0:\n print(\"Impossible\")\n sys.exit()\n else:\n print(\"Possible\")\n break\n for i in range(2):\n x = S[0] + dx[i]\n y = S[1] + dy[i]\n if 0 <= x <= w-1 and 0 <= y <= h-1 and A[y][x] == \"#\":\n B.append([x,y])\n cnt += 1\n else:\n if cnt != 1:\n print(\"Impossible\")\n break\n else:\n A[S[1]][S[0]] = \".\"\n \n \n ",
"import sys",
"sys",
"h,w = map(int,input().split())",
"h",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"A = []",
"A",
"[]",
"for i in range(h):\n A.append(list(input()))",
"i",
"range(h)",
"range",
"h",
"A.append(list(input()))",
"A.append",
"A",
"append",
"list(input())",
"list",
"input()",
"input",
"dx = [1,0,]",
"dx",
"[1,0,]",
"1",
"0",
"dy = [0,1,]",
"dy",
"[0,1,]",
"0",
"1",
"B = [[0,0]]",
"B",
"[[0,0]]",
"[0,0]",
"0",
"0",
"while B:\n S = B.pop()\n cnt = 0\n if S == [w-1,h-1]:\n A[h-1][w-1] = \".\"\n for L in A:\n if L.count(\"#\") != 0:\n print(\"Impossible\")\n sys.exit()\n else:\n print(\"Possible\")\n break\n for i in range(2):\n x = S[0] + dx[i]\n y = S[1] + dy[i]\n if 0 <= x <= w-1 and 0 <= y <= h-1 and A[y][x] == \"#\":\n B.append([x,y])\n cnt += 1\n else:\n if cnt != 1:\n print(\"Impossible\")\n break\n else:\n A[S[1]][S[0]] = \".\"\n \n \n ",
"B",
"S = B.pop()",
"S",
"B.pop()",
"B.pop",
"B",
"pop",
"cnt = 0",
"cnt",
"0",
"if S == [w-1,h-1]:\n A[h-1][w-1] = \".\"\n for L in A:\n if L.count(\"#\") != 0:\n print(\"Impossible\")\n sys.exit()\n else:\n print(\"Possible\")\n break\n ",
"S == [w-1,h-1]",
"S",
"[w-1,h-1]",
"w-1",
"w",
"1",
"h-1",
"h",
"1",
"A[h-1][w-1] = \".\"",
"A[h-1][w-1]",
"[h-1]",
"A",
"h-1",
"h",
"1",
"w-1",
"w",
"1",
"\".\"",
"for L in A:\n if L.count(\"#\") != 0:\n print(\"Impossible\")\n sys.exit()\n else:\n print(\"Possible\")\n break\n ",
"L",
"A",
"if L.count(\"#\") != 0:\n print(\"Impossible\")\n sys.exit()\n ",
"L.count(\"#\") != 0",
"L.count(\"#\")",
"L.count",
"L",
"count",
"\"#\"",
"0",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"sys.exit()",
"sys.exit",
"sys",
"exit",
"print(\"Possible\")",
"print",
"\"Possible\"",
"break",
"for i in range(2):\n x = S[0] + dx[i]\n y = S[1] + dy[i]\n if 0 <= x <= w-1 and 0 <= y <= h-1 and A[y][x] == \"#\":\n B.append([x,y])\n cnt += 1\n else:\n if cnt != 1:\n print(\"Impossible\")\n break\n else:\n A[S[1]][S[0]] = \".\"\n \n \n ",
"i",
"range(2)",
"range",
"2",
"x = S[0] + dx[i]",
"x",
"S[0] + dx[i]",
"S[0]",
"S",
"0",
"dx[i]",
"dx",
"i",
"y = S[1] + dy[i]",
"y",
"S[1] + dy[i]",
"S[1]",
"S",
"1",
"dy[i]",
"dy",
"i",
"if 0 <= x <= w-1 and 0 <= y <= h-1 and A[y][x] == \"#\":\n B.append([x,y])\n cnt += 1\n ",
"0 <= x <= w-1 and 0 <= y <= h-1 and A[y][x] == \"#\"",
"0 <= x <= w-1 and 0 <= y <= h-1",
"0 <= x <= w-1",
"0 <= x",
"0",
"x",
"w-1",
"w",
"1",
"0 <= y <= h-1",
"0 <= y",
"0",
"y",
"h-1",
"h",
"1",
"A[y][x] == \"#\"",
"A[y][x]",
"[y]",
"A",
"y",
"x",
"\"#\"",
"B.append([x,y])",
"B.append",
"B",
"append",
"[x,y]",
"x",
"y",
"cnt += 1",
"cnt",
"1",
"if cnt != 1:\n print(\"Impossible\")\n break\n else:\n A[S[1]][S[0]] = \".\"\n \n \n ",
"cnt != 1",
"cnt",
"1",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"break",
"A[S[1]][S[0]] = \".\"",
"A[S[1]][S[0]]",
"[S[1]]",
"A",
"S[1]",
"S",
"1",
"S[0]",
"S",
"0",
"\".\"",
"y = S[1] + dy[i]",
"S[1] + dy[i]",
"y",
"x = S[0] + dx[i]",
"S[0] + dx[i]",
"x",
"S = B.pop()",
"B.pop()",
"S",
"cnt = 0",
"0",
"cnt",
"cnt += 1",
"1",
"cnt",
"h,w = map(int,input().split())",
"map(int,input().split())",
"h",
"B = [[0,0]]",
"[[0,0]]",
"B",
"A = []",
"[]",
"A",
"w = map(int,input().split())",
"map(int,input().split())",
"w",
"dx = [1,0,]",
"[1,0,]",
"dx",
"dy = [0,1,]",
"[0,1,]",
"dy"
] |
import sys
h,w = map(int,input().split())
A = []
for i in range(h):
A.append(list(input()))
dx = [1,0,]
dy = [0,1,]
B = [[0,0]]
while B:
S = B.pop()
cnt = 0
if S == [w-1,h-1]:
A[h-1][w-1] = "."
for L in A:
if L.count("#") != 0:
print("Impossible")
sys.exit()
else:
print("Possible")
break
for i in range(2):
x = S[0] + dx[i]
y = S[1] + dy[i]
if 0 <= x <= w-1 and 0 <= y <= h-1 and A[y][x] == "#":
B.append([x,y])
cnt += 1
else:
if cnt != 1:
print("Impossible")
break
else:
A[S[1]][S[0]] = "."
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
14,
2,
13,
13,
4,
13,
17,
4,
13,
0,
13,
13,
4,
13,
17,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13
] |
[
[
67,
2
],
[
67,
11
],
[
15,
14
],
[
68,
17
],
[
70,
22
],
[
73,
25
],
[
29,
28
],
[
68,
31
],
[
34,
33
],
[
62,
36
],
[
71,
41
],
[
28,
42
],
[
33,
43
],
[
33,
47
],
[
74,
48
],
[
65,
48
],
[
64,
55
],
[
33,
56
],
[
67,
62
],
[
33,
64
],
[
64,
65
],
[
67,
68
],
[
70,
71
],
[
73,
74
]
] |
[
"h, w = map(int, input().split())\nL = [input() for _ in range(h)]\nr = 0\nfor i in range(h):\n for j in range(w):\n if L[i][j] == '#':\n if j < r:\n print('Impossible')\n exit()\n else:\n r = j\nelse:\n print('Possible')",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"input() for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"input()",
"input",
"L = [input() for _ in range(h)]",
"L",
"[input() for _ in range(h)]",
"r = 0",
"r",
"0",
"for i in range(h):\n for j in range(w):\n if L[i][j] == '#':\n if j < r:\n print('Impossible')\n exit()\n else:\n r = j\nelse:\n print('Possible')",
"i",
"range(h)",
"range",
"h",
"for j in range(w):\n if L[i][j] == '#':\n if j < r:\n print('Impossible')\n exit()\n else:\n r = j",
"j",
"range(w)",
"range",
"w",
"if L[i][j] == '#':\n if j < r:\n print('Impossible')\n exit()\n else:\n r = j",
"L[i][j] == '#'",
"L[i][j]",
"[i]",
"L",
"i",
"j",
"'#'",
"if j < r:\n print('Impossible')\n exit()\n else:\n r = j",
"j < r",
"j",
"r",
"print('Impossible')",
"print",
"'Impossible'",
"exit()",
"exit",
"r = j",
"r",
"j",
"print('Possible')",
"print",
"'Possible'",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"r = j",
"j",
"r",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h",
"L = [input() for _ in range(h)]",
"[input() for _ in range(h)]",
"L",
"r = 0",
"0",
"r"
] |
h, w = map(int, input().split())
L = [input() for _ in range(h)]
r = 0
for i in range(h):
for j in range(w):
if L[i][j] == '#':
if j < r:
print('Impossible')
exit()
else:
r = j
else:
print('Possible')
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
4,
18,
13,
13,
13,
4,
18,
13,
13,
13,
28,
13,
4,
13,
2,
13,
17,
14,
40,
4,
13,
18,
13,
13,
4,
13,
18,
13,
2,
13,
17,
4,
13,
17,
4,
13,
4,
13,
17,
10,
4,
13,
10,
39,
13,
10,
39,
13,
10,
13,
13,
10,
4,
13
] |
[
[
102,
2
],
[
102,
11
],
[
15,
14
],
[
103,
17
],
[
99,
24
],
[
96,
27
],
[
31,
30
],
[
103,
33
],
[
93,
35
],
[
39,
38
],
[
91,
41
],
[
100,
46
],
[
30,
47
],
[
38,
48
],
[
94,
52
],
[
38,
54
],
[
97,
57
],
[
94,
59
],
[
62,
61
],
[
103,
65
],
[
97,
72
],
[
61,
73
],
[
97,
77
],
[
61,
79
],
[
102,
91
],
[
93,
94
],
[
96,
97
],
[
99,
100
],
[
102,
103
]
] |
[
"h , w = map(int,input().split())\nma = [list(input()) for i in range(h)]\nans = []\nfor i in range(h):\n kar = []\n for j in range(w):\n if ma[i][j] ==\"#\":\n kar.append(j)\n ans.append(kar)\n\n\nfor i in range(h-1):\n if max(ans[i]) != min(ans[i+1]):\n print(\"Impossible\")\n exit()\n \nprint(\"Possible\")",
"h , w = map(int,input().split())",
"h",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"list(input()) for i in range(h)",
"for i in range(h)",
"i",
"range(h)",
"range",
"h",
"for i in range(h)",
"list(input())",
"list",
"input()",
"input",
"ma = [list(input()) for i in range(h)]",
"ma",
"[list(input()) for i in range(h)]",
"ans = []",
"ans",
"[]",
"for i in range(h):\n kar = []\n for j in range(w):\n if ma[i][j] ==\"#\":\n kar.append(j)\n ans.append(kar)",
"i",
"range(h)",
"range",
"h",
"kar = []",
"kar",
"[]",
"for j in range(w):\n if ma[i][j] ==\"#\":\n kar.append(j)\n ",
"j",
"range(w)",
"range",
"w",
"if ma[i][j] ==\"#\":\n kar.append(j)\n ",
"ma[i][j] ==\"#\"",
"ma[i][j]",
"[i]",
"ma",
"i",
"j",
"\"#\"",
"kar.append(j)",
"kar.append",
"kar",
"append",
"j",
"ans.append(kar)",
"ans.append",
"ans",
"append",
"kar",
"for i in range(h-1):\n if max(ans[i]) != min(ans[i+1]):\n print(\"Impossible\")\n exit()\n ",
"i",
"range(h-1)",
"range",
"h-1",
"h",
"1",
"if max(ans[i]) != min(ans[i+1]):\n print(\"Impossible\")\n exit()\n ",
"max(ans[i]) != min(ans[i+1])",
"max(ans[i])",
"max",
"ans[i]",
"ans",
"i",
"min(ans[i+1])",
"min",
"ans[i+1]",
"ans",
"i+1",
"i",
"1",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"exit()",
"exit",
"print(\"Possible\")",
"print",
"\"Possible\"",
"w = map(int,input().split())",
"map(int,input().split())",
"w",
"kar = []",
"[]",
"kar",
"ans = []",
"[]",
"ans",
"ma = [list(input()) for i in range(h)]",
"[list(input()) for i in range(h)]",
"ma",
"h , w = map(int,input().split())",
"map(int,input().split())",
"h"
] |
h , w = map(int,input().split())
ma = [list(input()) for i in range(h)]
ans = []
for i in range(h):
kar = []
for j in range(w):
if ma[i][j] =="#":
kar.append(j)
ans.append(kar)
for i in range(h-1):
if max(ans[i]) != min(ans[i+1]):
print("Impossible")
exit()
print("Possible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
18,
18,
13,
13,
13,
17,
14,
2,
2,
13,
13,
2,
13,
17,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
17,
13
] |
[
[
59,
2
],
[
59,
11
],
[
15,
14
],
[
57,
17
],
[
62,
22
],
[
68,
25
],
[
29,
28
],
[
57,
31
],
[
65,
33
],
[
63,
37
],
[
28,
38
],
[
57,
44
],
[
60,
45
],
[
66,
47
],
[
69,
47
],
[
59,
57
],
[
59,
60
],
[
62,
63
],
[
65,
66
],
[
68,
69
]
] |
[
"\nh,w = map(int,input().split())\ng = [input() for _ in range(h)]\nnum = 0\n\nfor i in range(h):\n num += g[i].count(\"#\")\n\nif h + w == num + 1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")\n",
"h,w = map(int,input().split())",
"h",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"input() for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"input()",
"input",
"g = [input() for _ in range(h)]",
"g",
"[input() for _ in range(h)]",
"num = 0",
"num",
"0",
"for i in range(h):\n num += g[i].count(\"#\")",
"i",
"range(h)",
"range",
"h",
"num += g[i].count(\"#\")",
"num",
"g[i].count(\"#\")",
"[i].count",
"[i]",
"g",
"i",
"count",
"\"#\"",
"if h + w == num + 1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"h + w == num + 1",
"h + w",
"h",
"w",
"num + 1",
"num",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"h,w = map(int,input().split())",
"map(int,input().split())",
"h",
"w = map(int,input().split())",
"map(int,input().split())",
"w",
"g = [input() for _ in range(h)]",
"[input() for _ in range(h)]",
"g",
"num += g[i].count(\"#\")",
"g[i].count(\"#\")",
"num",
"num = 0",
"0",
"num"
] |
h,w = map(int,input().split())
g = [input() for _ in range(h)]
num = 0
for i in range(h):
num += g[i].count("#")
if h + w == num + 1:
print("Possible")
else:
print("Impossible")
|
[
7,
15,
13,
15,
0,
13,
12,
2,
4,
13,
13,
17,
23,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
4,
18,
13,
13,
17,
12,
13,
0,
13,
39,
28,
39,
13,
13,
39,
39,
17,
17,
39,
17,
17,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
14,
2,
2,
2,
40,
17,
13,
2,
13,
13,
40,
17,
13,
2,
13,
13,
4,
18,
13,
13,
39,
13,
13,
29,
13,
23,
13,
23,
13,
23,
13,
23,
13,
12,
13,
0,
13,
39,
28,
39,
13,
13,
39,
39,
17,
17,
39,
17,
17,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
14,
2,
2,
2,
40,
17,
13,
2,
13,
13,
40,
17,
13,
2,
13,
13,
4,
18,
13,
13,
39,
13,
13,
29,
13,
23,
13,
23,
13,
23,
13,
23,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
18,
4,
18,
4,
13,
13,
13,
0,
13,
13,
0,
13,
4,
13,
39,
39,
17,
17,
42,
40,
4,
13,
13,
17,
0,
13,
4,
18,
13,
13,
0,
13,
4,
13,
31,
13,
13,
13,
0,
13,
4,
13,
31,
13,
13,
13,
41,
28,
13,
13,
2,
18,
18,
13,
18,
13,
17,
18,
13,
17,
17,
4,
13,
0,
13,
13,
41,
28,
13,
13,
2,
18,
18,
13,
18,
13,
17,
18,
13,
17,
17,
4,
13,
0,
13,
13,
14,
2,
4,
13,
13,
17,
4,
13,
17,
4,
18,
13,
13,
14,
2,
13,
39,
2,
13,
17,
2,
13,
17,
3,
14,
2,
40,
4,
13,
13,
17,
2,
4,
13,
13,
17,
4,
13,
17,
4,
18,
13,
13,
4,
18,
13,
13,
31,
13,
4,
13,
17,
10,
12,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
18,
13,
10,
18,
13,
10,
13,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
18,
13,
10,
13,
13
] |
[
[
323,
5
],
[
362,
14
],
[
344,
23
],
[
341,
32
],
[
49,
48
],
[
54,
51
],
[
63,
62
],
[
97,
64
],
[
68,
67
],
[
99,
69
],
[
62,
77
],
[
62,
79
],
[
101,
80
],
[
67,
83
],
[
67,
85
],
[
103,
86
],
[
48,
89
],
[
48,
95
],
[
97,
97
],
[
99,
99
],
[
101,
101
],
[
103,
103
],
[
108,
107
],
[
113,
110
],
[
122,
121
],
[
156,
123
],
[
127,
126
],
[
158,
128
],
[
121,
136
],
[
121,
138
],
[
160,
139
],
[
126,
142
],
[
126,
144
],
[
162,
145
],
[
107,
148
],
[
107,
154
],
[
156,
156
],
[
158,
158
],
[
160,
160
],
[
162,
162
],
[
356,
164
],
[
345,
171
],
[
356,
173
],
[
177,
176
],
[
357,
179
],
[
345,
188
],
[
338,
192
],
[
332,
195
],
[
333,
206
],
[
359,
209
],
[
333,
212
],
[
329,
215
],
[
351,
217
],
[
360,
219
],
[
357,
220
],
[
336,
221
],
[
353,
223
],
[
327,
225
],
[
360,
227
],
[
357,
228
],
[
336,
229
],
[
233,
232
],
[
330,
232
],
[
366,
232
],
[
339,
237
],
[
232,
239
],
[
232,
242
],
[
232,
246
],
[
365,
248
],
[
253,
252
],
[
354,
252
],
[
348,
252
],
[
339,
257
],
[
252,
259
],
[
252,
262
],
[
252,
266
],
[
347,
268
],
[
348,
274
],
[
354,
274
],
[
360,
285
],
[
357,
288
],
[
336,
291
],
[
366,
299
],
[
330,
299
],
[
348,
304
],
[
354,
304
],
[
333,
315
],
[
366,
318
],
[
330,
318
],
[
323,
324
],
[
329,
330
],
[
332,
333
],
[
356,
336
],
[
338,
339
],
[
341,
342
],
[
344,
345
],
[
347,
348
],
[
353,
354
],
[
356,
357
],
[
359,
360
],
[
362,
363
],
[
365,
366
]
] |
[
"#! /usr/bin/env python3\n\nimport sys\nfrom collections import deque\nint1 = lambda x: int(x) - 1\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(500000)\n\n\n# adjacent_2\ndef adjacent_2(h, w, H, W):\n ret = []\n for (dh, dw) in [(0, 1), (1, 0)]:\n h_ = h + dh\n w_ = w + dw\n if (0 <= h_) & (h_ < H) & (0 <= w_) & (w_ < W):\n ret.append((h_, w_))\n return ret\n\n\ndef adjacent_2_(h, w, H, W):\n ret = []\n for (dh, dw) in [(0, -1), (-1, 0)]:\n h_ = h + dh\n w_ = w + dw\n if (0 <= h_) & (h_ < H) & (0 <= w_) & (w_ < W):\n ret.append((h_, w_))\n return ret\n\n\nH, W = map(int, readline().split())\nM = [list(readline().decode().rstrip()) for _ in range(H)]\n\nque = deque([(0, 0)])\nwhile len(que) != 0:\n acc = que.popleft()\n\n ret = adjacent_2(*acc, H, W)\n cnt = adjacent_2_(*acc, H, W)\n ret = [pos for pos in ret if M[pos[0]][pos[1]] == '#']\n cnt = [pos for pos in cnt if M[pos[0]][pos[1]] == '#']\n\n if (len(cnt) > 1):\n print(\"Impossible\")\n sys.exit()\n if acc == (H - 1, W - 1):\n break\n\n if (len(ret) != 1) or (len(cnt) > 1):\n print(\"Impossible\")\n sys.exit()\n que.append(*ret)\n\nprint(\"Possible\")",
"import sys",
"sys",
"from collections import deque",
"int1 = lambda x: int(x) - 1",
"int1",
"lambda x: int(x) - 1",
"int(x) - 1",
"int(x)",
"int",
"x",
"1",
"x",
"read = sys.stdin.buffer.read",
"read",
"sys.stdin.buffer.read",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"read",
"readline = sys.stdin.buffer.readline",
"readline",
"sys.stdin.buffer.readline",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readline",
"readlines = sys.stdin.buffer.readlines",
"readlines",
"sys.stdin.buffer.readlines",
"sys.stdin.buffer",
"sys.stdin",
"sys",
"stdin",
"buffer",
"readlines",
"sys.setrecursionlimit(500000)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"500000",
"def adjacent_2(h, w, H, W):\n ret = []\n for (dh, dw) in [(0, 1), (1, 0)]:\n h_ = h + dh\n w_ = w + dw\n if (0 <= h_) & (h_ < H) & (0 <= w_) & (w_ < W):\n ret.append((h_, w_))\n return ret",
"adjacent_2",
"ret = []",
"ret",
"[]",
"for (dh, dw) in [(0, 1), (1, 0)]:\n h_ = h + dh\n w_ = w + dw\n if (0 <= h_) & (h_ < H) & (0 <= w_) & (w_ < W):\n ret.append((h_, w_))\n ",
"(dh, dw)",
"dh",
"dw",
"[(0, 1), (1, 0)]",
"(0, 1)",
"0",
"1",
"(1, 0)",
"1",
"0",
"h_ = h + dh",
"h_",
"h + dh",
"h",
"dh",
"w_ = w + dw",
"w_",
"w + dw",
"w",
"dw",
"if (0 <= h_) & (h_ < H) & (0 <= w_) & (w_ < W):\n ret.append((h_, w_))\n ",
"(0 <= h_) & (h_ < H) & (0 <= w_) & (w_ < W)",
"(0 <= h_) & (h_ < H) & (0 <= w_)",
"(0 <= h_) & (h_ < H)",
"0 <= h_",
"0",
"h_",
"h_ < H",
"h_",
"H",
"0 <= w_",
"0",
"w_",
"w_ < W",
"w_",
"W",
"ret.append((h_, w_))",
"ret.append",
"ret",
"append",
"(h_, w_)",
"h_",
"w_",
"return ret",
"ret",
"h",
"h",
"w",
"w",
"H",
"H",
"W",
"W",
"def adjacent_2_(h, w, H, W):\n ret = []\n for (dh, dw) in [(0, -1), (-1, 0)]:\n h_ = h + dh\n w_ = w + dw\n if (0 <= h_) & (h_ < H) & (0 <= w_) & (w_ < W):\n ret.append((h_, w_))\n return ret",
"adjacent_2_",
"ret = []",
"ret",
"[]",
"for (dh, dw) in [(0, -1), (-1, 0)]:\n h_ = h + dh\n w_ = w + dw\n if (0 <= h_) & (h_ < H) & (0 <= w_) & (w_ < W):\n ret.append((h_, w_))\n ",
"(dh, dw)",
"dh",
"dw",
"[(0, -1), (-1, 0)]",
"(0, -1)",
"0",
"-1",
"(-1, 0)",
"-1",
"0",
"h_ = h + dh",
"h_",
"h + dh",
"h",
"dh",
"w_ = w + dw",
"w_",
"w + dw",
"w",
"dw",
"if (0 <= h_) & (h_ < H) & (0 <= w_) & (w_ < W):\n ret.append((h_, w_))\n ",
"(0 <= h_) & (h_ < H) & (0 <= w_) & (w_ < W)",
"(0 <= h_) & (h_ < H) & (0 <= w_)",
"(0 <= h_) & (h_ < H)",
"0 <= h_",
"0",
"h_",
"h_ < H",
"h_",
"H",
"0 <= w_",
"0",
"w_",
"w_ < W",
"w_",
"W",
"ret.append((h_, w_))",
"ret.append",
"ret",
"append",
"(h_, w_)",
"h_",
"w_",
"return ret",
"ret",
"h",
"h",
"w",
"w",
"H",
"H",
"W",
"W",
"H, W = map(int, readline().split())",
"H",
"map(int, readline().split())",
"map",
"int",
"readline().split()",
"().split",
"()",
"readline",
"split",
"W",
"list(readline().decode().rstrip()) for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"list(readline().decode().rstrip())",
"list",
"readline().decode().rstrip()",
"().decode().rstrip",
"().decode()",
"().decode",
"()",
"readline",
"decode",
"rstrip",
"M = [list(readline().decode().rstrip()) for _ in range(H)]",
"M",
"[list(readline().decode().rstrip()) for _ in range(H)]",
"que = deque([(0, 0)])",
"que",
"deque([(0, 0)])",
"deque",
"[(0, 0)]",
"(0, 0)",
"0",
"0",
"while len(que) != 0:\n acc = que.popleft()\n\n ret = adjacent_2(*acc, H, W)\n cnt = adjacent_2_(*acc, H, W)\n ret = [pos for pos in ret if M[pos[0]][pos[1]] == '#']\n cnt = [pos for pos in cnt if M[pos[0]][pos[1]] == '#']\n\n if (len(cnt) > 1):\n print(\"Impossible\")\n sys.exit()\n if acc == (H - 1, W - 1):\n break\n\n if (len(ret) != 1) or (len(cnt) > 1):\n print(\"Impossible\")\n sys.exit()\n que.append(*ret)",
"len(que) != 0",
"len(que)",
"len",
"que",
"0",
"acc = que.popleft()",
"acc",
"que.popleft()",
"que.popleft",
"que",
"popleft",
"ret = adjacent_2(*acc, H, W)",
"ret",
"adjacent_2(*acc, H, W)",
"adjacent_2",
"*acc",
"acc",
"H",
"W",
"cnt = adjacent_2_(*acc, H, W)",
"cnt",
"adjacent_2_(*acc, H, W)",
"adjacent_2_",
"*acc",
"acc",
"H",
"W",
"pos for pos in ret if M[pos[0]][pos[1]] == '#'",
"for pos in ret if M[pos[0]][pos[1]] == '#'",
"pos",
"ret",
"M[pos[0]][pos[1]] == '#'",
"M[pos[0]][pos[1]]",
"[pos[0]]",
"M",
"pos[0]",
"pos",
"0",
"pos[1]",
"pos",
"1",
"'#'",
"if M[pos[0]][pos[1]] == '#'",
"pos",
"ret = [pos for pos in ret if M[pos[0]][pos[1]] == '#']",
"ret",
"[pos for pos in ret if M[pos[0]][pos[1]] == '#']",
"pos for pos in cnt if M[pos[0]][pos[1]] == '#'",
"for pos in cnt if M[pos[0]][pos[1]] == '#'",
"pos",
"cnt",
"M[pos[0]][pos[1]] == '#'",
"M[pos[0]][pos[1]]",
"[pos[0]]",
"M",
"pos[0]",
"pos",
"0",
"pos[1]",
"pos",
"1",
"'#'",
"if M[pos[0]][pos[1]] == '#'",
"pos",
"cnt = [pos for pos in cnt if M[pos[0]][pos[1]] == '#']",
"cnt",
"[pos for pos in cnt if M[pos[0]][pos[1]] == '#']",
"if (len(cnt) > 1):\n print(\"Impossible\")\n sys.exit()\n ",
"len(cnt) > 1",
"len(cnt)",
"len",
"cnt",
"1",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"sys.exit()",
"sys.exit",
"sys",
"exit",
"if acc == (H - 1, W - 1):\n break\n\n ",
"acc == (H - 1, W - 1)",
"acc",
"(H - 1, W - 1)",
"H - 1",
"H",
"1",
"W - 1",
"W",
"1",
"break",
"if (len(ret) != 1) or (len(cnt) > 1):\n print(\"Impossible\")\n sys.exit()\n ",
"(len(ret) != 1) or (len(cnt) > 1)",
"len(ret) != 1",
"len(ret)",
"len",
"ret",
"1",
"len(cnt) > 1",
"len(cnt)",
"len",
"cnt",
"1",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"sys.exit()",
"sys.exit",
"sys",
"exit",
"que.append(*ret)",
"que.append",
"que",
"append",
"*ret",
"ret",
"print(\"Possible\")",
"print",
"\"Possible\"",
"int1 = lambda x: int(x) - 1",
"lambda x: int(x) - 1",
"int1",
"def adjacent_2_(h, w, H, W):\n ret = []\n for (dh, dw) in [(0, -1), (-1, 0)]:\n h_ = h + dh\n w_ = w + dw\n if (0 <= h_) & (h_ < H) & (0 <= w_) & (w_ < W):\n ret.append((h_, w_))\n return ret",
"def adjacent_2_(h, w, H, W):\n ret = []\n for (dh, dw) in [(0, -1), (-1, 0)]:\n h_ = h + dh\n w_ = w + dw\n if (0 <= h_) & (h_ < H) & (0 <= w_) & (w_ < W):\n ret.append((h_, w_))\n return ret",
"adjacent_2_",
"ret = adjacent_2(*acc, H, W)",
"adjacent_2(*acc, H, W)",
"ret",
"que = deque([(0, 0)])",
"deque([(0, 0)])",
"que",
"W = map(int, readline().split())",
"map(int, readline().split())",
"W",
"M = [list(readline().decode().rstrip()) for _ in range(H)]",
"[list(readline().decode().rstrip()) for _ in range(H)]",
"M",
"readlines = sys.stdin.buffer.readlines",
"sys.stdin.buffer.readlines",
"readlines",
"readline = sys.stdin.buffer.readline",
"sys.stdin.buffer.readline",
"readline",
"cnt = [pos for pos in cnt if M[pos[0]][pos[1]] == '#']",
"[pos for pos in cnt if M[pos[0]][pos[1]] == '#']",
"cnt",
"def adjacent_2(h, w, H, W):\n ret = []\n for (dh, dw) in [(0, 1), (1, 0)]:\n h_ = h + dh\n w_ = w + dw\n if (0 <= h_) & (h_ < H) & (0 <= w_) & (w_ < W):\n ret.append((h_, w_))\n return ret",
"def adjacent_2(h, w, H, W):\n ret = []\n for (dh, dw) in [(0, 1), (1, 0)]:\n h_ = h + dh\n w_ = w + dw\n if (0 <= h_) & (h_ < H) & (0 <= w_) & (w_ < W):\n ret.append((h_, w_))\n return ret",
"adjacent_2",
"cnt = adjacent_2_(*acc, H, W)",
"adjacent_2_(*acc, H, W)",
"cnt",
"H, W = map(int, readline().split())",
"map(int, readline().split())",
"H",
"acc = que.popleft()",
"que.popleft()",
"acc",
"read = sys.stdin.buffer.read",
"sys.stdin.buffer.read",
"read",
"ret = [pos for pos in ret if M[pos[0]][pos[1]] == '#']",
"[pos for pos in ret if M[pos[0]][pos[1]] == '#']",
"ret"
] |
#! /usr/bin/env python3
import sys
from collections import deque
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
# adjacent_2
def adjacent_2(h, w, H, W):
ret = []
for (dh, dw) in [(0, 1), (1, 0)]:
h_ = h + dh
w_ = w + dw
if (0 <= h_) & (h_ < H) & (0 <= w_) & (w_ < W):
ret.append((h_, w_))
return ret
def adjacent_2_(h, w, H, W):
ret = []
for (dh, dw) in [(0, -1), (-1, 0)]:
h_ = h + dh
w_ = w + dw
if (0 <= h_) & (h_ < H) & (0 <= w_) & (w_ < W):
ret.append((h_, w_))
return ret
H, W = map(int, readline().split())
M = [list(readline().decode().rstrip()) for _ in range(H)]
que = deque([(0, 0)])
while len(que) != 0:
acc = que.popleft()
ret = adjacent_2(*acc, H, W)
cnt = adjacent_2_(*acc, H, W)
ret = [pos for pos in ret if M[pos[0]][pos[1]] == '#']
cnt = [pos for pos in cnt if M[pos[0]][pos[1]] == '#']
if (len(cnt) > 1):
print("Impossible")
sys.exit()
if acc == (H - 1, W - 1):
break
if (len(ret) != 1) or (len(cnt) > 1):
print("Impossible")
sys.exit()
que.append(*ret)
print("Possible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
18,
4,
13,
13,
17,
0,
13,
13,
4,
13,
8,
2,
4,
13,
13,
2,
2,
13,
13,
17,
17,
17,
10,
4,
13,
10,
4,
13,
10,
13,
13
] |
[
[
46,
2
],
[
46,
11
],
[
15,
14
],
[
47,
17
],
[
49,
26
],
[
50,
34
],
[
47,
37
],
[
44,
38
],
[
46,
44
],
[
46,
47
],
[
49,
50
]
] |
[
"h,w = map(int,input().split())\na = [input().count('#') for i in range(h)]\nprint('Possible' if sum(a)==h+w-1 else 'Impossible')",
"h,w = map(int,input().split())",
"h",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"input().count('#') for i in range(h)",
"for i in range(h)",
"i",
"range(h)",
"range",
"h",
"for i in range(h)",
"input().count('#')",
"().count",
"()",
"input",
"count",
"'#'",
"a = [input().count('#') for i in range(h)]",
"a",
"[input().count('#') for i in range(h)]",
"print('Possible' if sum(a)==h+w-1 else 'Impossible')",
"print",
"'Possible' if sum(a)==h+w-1 else 'Impossible'",
"sum(a)==h+w-1",
"sum(a)",
"sum",
"a",
"h+w-1",
"h+w",
"h",
"w",
"1",
"'Possible'",
"'Impossible'",
"w = map(int,input().split())",
"map(int,input().split())",
"w",
"h,w = map(int,input().split())",
"map(int,input().split())",
"h",
"a = [input().count('#') for i in range(h)]",
"[input().count('#') for i in range(h)]",
"a"
] |
h,w = map(int,input().split())
a = [input().count('#') for i in range(h)]
print('Possible' if sum(a)==h+w-1 else 'Impossible')
|
[
7,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
15,
15,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
23,
13,
23,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
2,
17,
17,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
2,
39,
17,
13,
0,
13,
13,
12,
13,
14,
2,
2,
2,
2,
13,
17,
2,
13,
17,
40,
13,
13,
40,
13,
13,
29,
14,
2,
18,
18,
13,
13,
13,
17,
29,
0,
18,
18,
13,
13,
13,
17,
4,
13,
2,
13,
17,
13,
4,
13,
13,
2,
13,
17,
23,
13,
23,
13,
4,
13,
17,
17,
14,
2,
18,
18,
13,
2,
13,
17,
2,
13,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
18,
18,
13,
13,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
4,
13,
17,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
12,
13,
10,
2,
13,
10,
4,
13,
10,
4,
13,
10,
12,
13,
10,
12,
13,
10,
13,
13,
10,
12,
13,
10,
12,
13,
10,
17,
13,
10,
13,
13,
10,
2,
13,
10,
4,
13
] |
[
[
29,
29
],
[
31,
31
],
[
228,
40
],
[
198,
45
],
[
231,
52
],
[
187,
54
],
[
231,
55
],
[
59,
58
],
[
205,
61
],
[
193,
66
],
[
213,
68
],
[
73,
72
],
[
205,
75
],
[
232,
80
],
[
225,
82
],
[
132,
91
],
[
134,
94
],
[
132,
97
],
[
205,
98
],
[
134,
100
],
[
232,
101
],
[
214,
107
],
[
132,
108
],
[
134,
109
],
[
118,
113
],
[
226,
115
],
[
132,
116
],
[
134,
117
],
[
132,
122
],
[
134,
124
],
[
132,
127
],
[
134,
129
],
[
132,
132
],
[
134,
134
],
[
208,
136
],
[
226,
143
],
[
205,
145
],
[
232,
148
],
[
222,
152
],
[
156,
155
],
[
205,
158
],
[
201,
160
],
[
214,
164
],
[
155,
165
],
[
202,
170
],
[
223,
170
],
[
205,
173
],
[
232,
174
],
[
198,
199
],
[
201,
202
],
[
231,
205
],
[
213,
214
],
[
222,
223
],
[
225,
226
],
[
228,
229
],
[
231,
232
]
] |
[
"import sys\nimport math\nimport numpy as np\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\ndef s(): return input()\ndef i(): return int(input())\ndef S(): return input().split()\ndef I(): return map(int,input().split())\ndef L(): return list(map(int,input().split()))\ndef l(): return list(map(int,input().split()))\ndef lcm(a,b): return a*b//math.gcd(a,b)\nsys.setrecursionlimit(10 ** 9)\nINF = 10**9\nmod = 10**9+7\n\nH,W = I()\nmaze = [list(s()) for _ in range(H)]\nvisited = [[0]*W for _ in range(H)]\ndef dfs(x,y):\n if x < 0 or y < 0 or x >= H or y >= W:\n return\n if maze[x][y] == '.':\n return\n visited[x][y] = 1\n dfs(x+1,y)\n dfs(x,y+1)\ndfs(0,0)\nif visited[H-1][W-1] == 1:\n cnt = 0\n for i in range(H):\n cnt += maze[i].count('#')\n if cnt == H+W-1:\n print('Possible')\n else:\n print('Impossible')\nelse:\n print('Impossible')",
"import sys",
"sys",
"import math",
"math",
"import numpy as np",
"numpy",
"import itertools",
"itertools",
"import bisect",
"bisect",
"from copy import copy",
"from collections import deque,Counter",
"from decimal import Decimal",
"def s(): return input()",
"s",
"def i(): return int(input())",
"i",
"def S(): return input().split()",
"S",
"def I(): return map(int,input().split())",
"I",
"def L(): return list(map(int,input().split()))",
"L",
"def l(): return list(map(int,input().split()))",
"l",
"def lcm(a,b): return a*b//math.gcd(a,b)",
"lcm",
"a",
"a",
"b",
"b",
"sys.setrecursionlimit(10 ** 9)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10 ** 9",
"10",
"9",
"INF = 10**9",
"INF",
"10**9",
"10",
"9",
"mod = 10**9+7",
"mod",
"10**9+7",
"10**9",
"10",
"9",
"7",
"H,W = I()",
"H",
"I()",
"I",
"W",
"list(s()) for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"list(s())",
"list",
"s()",
"s",
"maze = [list(s()) for _ in range(H)]",
"maze",
"[list(s()) for _ in range(H)]",
"[0]*W for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"[0]*W",
"[0]",
"0",
"W",
"visited = [[0]*W for _ in range(H)]",
"visited",
"[[0]*W for _ in range(H)]",
"def dfs(x,y):\n if x < 0 or y < 0 or x >= H or y >= W:\n return\n if maze[x][y] == '.':\n return\n visited[x][y] = 1\n dfs(x+1,y)\n dfs(x,y+1)",
"dfs",
"if x < 0 or y < 0 or x >= H or y >= W:\n return\n ",
"x < 0 or y < 0 or x >= H or y >= W",
"x < 0 or y < 0 or x >= H",
"x < 0 or y < 0",
"x < 0",
"x",
"0",
"y < 0",
"y",
"0",
"x >= H",
"x",
"H",
"y >= W",
"y",
"W",
"return",
"if maze[x][y] == '.':\n return\n ",
"maze[x][y] == '.'",
"maze[x][y]",
"[x]",
"maze",
"x",
"y",
"'.'",
"return",
"visited[x][y] = 1",
"visited[x][y]",
"[x]",
"visited",
"x",
"y",
"1",
"dfs(x+1,y)",
"dfs",
"x+1",
"x",
"1",
"y",
"dfs(x,y+1)",
"dfs",
"x",
"y+1",
"y",
"1",
"x",
"x",
"y",
"y",
"dfs(0,0)",
"dfs",
"0",
"0",
"if visited[H-1][W-1] == 1:\n cnt = 0\n for i in range(H):\n cnt += maze[i].count('#')\n if cnt == H+W-1:\n print('Possible')\n else:\n print('Impossible')\nelse:\n print('Impossible')",
"visited[H-1][W-1] == 1",
"visited[H-1][W-1]",
"[H-1]",
"visited",
"H-1",
"H",
"1",
"W-1",
"W",
"1",
"1",
"cnt = 0",
"cnt",
"0",
"for i in range(H):\n cnt += maze[i].count('#')\n ",
"i",
"range(H)",
"range",
"H",
"cnt += maze[i].count('#')",
"cnt",
"maze[i].count('#')",
"[i].count",
"[i]",
"maze",
"i",
"count",
"'#'",
"if cnt == H+W-1:\n print('Possible')\n else:\n print('Impossible')",
"cnt == H+W-1",
"cnt",
"H+W-1",
"H+W",
"H",
"W",
"1",
"print('Possible')",
"print",
"'Possible'",
"print('Impossible')",
"print",
"'Impossible'",
"print('Impossible')",
"print",
"'Impossible'",
"def I(): return map(int,input().split())",
"def I(): return map(int,input().split())",
"I",
"def i(): return int(input())",
"def i(): return int(input())",
"i",
"def s(): return input()",
"def s(): return input()",
"s",
"def L(): return list(map(int,input().split()))",
"def L(): return list(map(int,input().split()))",
"L",
"mod = 10**9+7",
"10**9+7",
"mod",
"cnt += maze[i].count('#')",
"maze[i].count('#')",
"cnt",
"H,W = I()",
"I()",
"H",
"def dfs(x,y):\n if x < 0 or y < 0 or x >= H or y >= W:\n return\n if maze[x][y] == '.':\n return\n visited[x][y] = 1\n dfs(x+1,y)\n dfs(x,y+1)",
"def dfs(x,y):\n if x < 0 or y < 0 or x >= H or y >= W:\n return\n if maze[x][y] == '.':\n return\n visited[x][y] = 1\n dfs(x+1,y)\n dfs(x,y+1)",
"dfs",
"def l(): return list(map(int,input().split()))",
"def l(): return list(map(int,input().split()))",
"l",
"maze = [list(s()) for _ in range(H)]",
"[list(s()) for _ in range(H)]",
"maze",
"def S(): return input().split()",
"def S(): return input().split()",
"S",
"def lcm(a,b): return a*b//math.gcd(a,b)",
"def lcm(a,b): return a*b//math.gcd(a,b)",
"lcm",
"cnt = 0",
"0",
"cnt",
"visited = [[0]*W for _ in range(H)]",
"[[0]*W for _ in range(H)]",
"visited",
"INF = 10**9",
"10**9",
"INF",
"W = I()",
"I()",
"W"
] |
import sys
import math
import numpy as np
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7
H,W = I()
maze = [list(s()) for _ in range(H)]
visited = [[0]*W for _ in range(H)]
def dfs(x,y):
if x < 0 or y < 0 or x >= H or y >= W:
return
if maze[x][y] == '.':
return
visited[x][y] = 1
dfs(x+1,y)
dfs(x,y+1)
dfs(0,0)
if visited[H-1][W-1] == 1:
cnt = 0
for i in range(H):
cnt += maze[i].count('#')
if cnt == H+W-1:
print('Possible')
else:
print('Impossible')
else:
print('Impossible')
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
0,
13,
2,
18,
18,
13,
13,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
0,
13,
17,
13,
17,
42,
2,
2,
13,
13,
2,
2,
13,
13,
17,
0,
13,
17,
13,
17,
14,
40,
13,
2,
13,
17,
14,
2,
18,
18,
13,
2,
13,
17,
13,
17,
0,
13,
17,
14,
40,
13,
2,
13,
17,
14,
2,
18,
18,
13,
13,
2,
13,
17,
17,
0,
13,
17,
14,
40,
2,
13,
13,
17,
4,
13,
17,
4,
13,
0,
13,
13,
0,
13,
13,
4,
13,
17,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
13,
13,
10,
13,
13,
10,
17,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13,
10,
2,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13
] |
[
[
174,
2
],
[
174,
11
],
[
15,
14
],
[
142,
17
],
[
156,
22
],
[
171,
25
],
[
29,
28
],
[
142,
31
],
[
34,
33
],
[
175,
36
],
[
165,
38
],
[
157,
42
],
[
28,
43
],
[
33,
44
],
[
166,
48
],
[
172,
48
],
[
142,
51
],
[
175,
52
],
[
162,
60
],
[
144,
62
],
[
163,
67
],
[
148,
67
],
[
145,
68
],
[
151,
68
],
[
142,
71
],
[
175,
72
],
[
153,
75
],
[
159,
77
],
[
163,
81
],
[
148,
81
],
[
142,
83
],
[
157,
89
],
[
163,
91
],
[
148,
91
],
[
145,
93
],
[
151,
93
],
[
138,
96
],
[
145,
100
],
[
151,
100
],
[
175,
102
],
[
157,
108
],
[
163,
109
],
[
148,
109
],
[
145,
111
],
[
151,
111
],
[
168,
115
],
[
139,
120
],
[
154,
120
],
[
169,
121
],
[
160,
121
],
[
147,
129
],
[
139,
130
],
[
154,
130
],
[
150,
132
],
[
169,
133
],
[
160,
133
],
[
138,
139
],
[
174,
142
],
[
144,
145
],
[
139,
147
],
[
154,
147
],
[
147,
148
],
[
169,
150
],
[
160,
150
],
[
150,
151
],
[
153,
154
],
[
156,
157
],
[
159,
160
],
[
162,
163
],
[
165,
166
],
[
168,
169
],
[
171,
172
],
[
174,
175
]
] |
[
"h,w = map(int,input().split())\na = [input() for _ in range(h)]\n\ncnt = 0\nfor x in range(h):\n for y in range(w):\n cnt += (a[x][y]=='#')\nif(cnt > h+w-1):\n print('Impossible')\n exit()\n\n\nx,y = 0,0\nwhile(x+y<h+w-2):\n dx,dy=0,0\n\n if(x!=h-1):\n if(a[x+1][y]=='#'):\n dx = 1\n if(y!=w-1):\n if(a[x][y+1]=='#'):\n dy = 1\n if(dx+dy!=1):\n print('Impossible')\n exit()\n\n x += dx\n y += dy\n\nprint('Possible')",
"h,w = map(int,input().split())",
"h",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"input() for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"input()",
"input",
"a = [input() for _ in range(h)]",
"a",
"[input() for _ in range(h)]",
"cnt = 0",
"cnt",
"0",
"for x in range(h):\n for y in range(w):\n cnt += (a[x][y]=='#')",
"x",
"range(h)",
"range",
"h",
"for y in range(w):\n cnt += (a[x][y]=='#')",
"y",
"range(w)",
"range",
"w",
"cnt += (a[x][y]=='#')",
"cnt",
"a[x][y]=='#'",
"a[x][y]",
"[x]",
"a",
"x",
"y",
"'#'",
"if(cnt > h+w-1):\n print('Impossible')\n exit()",
"cnt > h+w-1",
"cnt",
"h+w-1",
"h+w",
"h",
"w",
"1",
"print('Impossible')",
"print",
"'Impossible'",
"exit()",
"exit",
"x,y = 0,0",
"x",
"0",
"y",
"0",
"while(x+y<h+w-2):\n dx,dy=0,0\n\n if(x!=h-1):\n if(a[x+1][y]=='#'):\n dx = 1\n if(y!=w-1):\n if(a[x][y+1]=='#'):\n dy = 1\n if(dx+dy!=1):\n print('Impossible')\n exit()\n\n x += dx\n y += dy",
"x+y<h+w-2",
"x+y",
"x",
"y",
"h+w-2",
"h+w",
"h",
"w",
"2",
"dx,dy=0,0",
"dx",
"0",
"dy",
"0",
"if(x!=h-1):\n if(a[x+1][y]=='#'):\n dx = 1\n ",
"x!=h-1",
"x",
"h-1",
"h",
"1",
"if(a[x+1][y]=='#'):\n dx = 1\n ",
"a[x+1][y]=='#'",
"a[x+1][y]",
"[x+1]",
"a",
"x+1",
"x",
"1",
"y",
"'#'",
"dx = 1",
"dx",
"1",
"if(y!=w-1):\n if(a[x][y+1]=='#'):\n dy = 1\n ",
"y!=w-1",
"y",
"w-1",
"w",
"1",
"if(a[x][y+1]=='#'):\n dy = 1\n ",
"a[x][y+1]=='#'",
"a[x][y+1]",
"[x]",
"a",
"x",
"y+1",
"y",
"1",
"'#'",
"dy = 1",
"dy",
"1",
"if(dx+dy!=1):\n print('Impossible')\n exit()\n\n ",
"dx+dy!=1",
"dx+dy",
"dx",
"dy",
"1",
"print('Impossible')",
"print",
"'Impossible'",
"exit()",
"exit",
"x += dx",
"x",
"dx",
"y += dy",
"y",
"dy",
"print('Possible')",
"print",
"'Possible'",
"dx = 1",
"1",
"dx",
"h,w = map(int,input().split())",
"map(int,input().split())",
"h",
"y = 0,0",
"0",
"y",
"x += dx",
"dx",
"x",
"y += dy",
"dy",
"y",
"dx,dy=0,0",
"0",
"dx",
"a = [input() for _ in range(h)]",
"[input() for _ in range(h)]",
"a",
"dy=0,0",
"0",
"dy",
"x,y = 0,0",
"0",
"x",
"cnt += (a[x][y]=='#')",
"a[x][y]=='#'",
"cnt",
"dy = 1",
"1",
"dy",
"cnt = 0",
"0",
"cnt",
"w = map(int,input().split())",
"map(int,input().split())",
"w"
] |
h,w = map(int,input().split())
a = [input() for _ in range(h)]
cnt = 0
for x in range(h):
for y in range(w):
cnt += (a[x][y]=='#')
if(cnt > h+w-1):
print('Impossible')
exit()
x,y = 0,0
while(x+y<h+w-2):
dx,dy=0,0
if(x!=h-1):
if(a[x+1][y]=='#'):
dx = 1
if(y!=w-1):
if(a[x][y+1]=='#'):
dy = 1
if(dx+dy!=1):
print('Impossible')
exit()
x += dx
y += dy
print('Possible')
|
[
7,
15,
13,
4,
18,
13,
13,
2,
17,
17,
15,
15,
15,
15,
15,
15,
15,
15,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
17,
0,
13,
40,
4,
13,
17,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
0,
13,
4,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
12,
13,
10,
17,
13,
10,
12,
13,
10,
12,
13,
10,
4,
13,
10,
4,
13,
10,
12,
13,
10,
12,
13,
10,
13,
13,
10,
12,
13,
10,
12,
13,
10,
40,
13,
10,
4,
13,
10,
12,
13,
10,
2,
13,
10,
12,
13,
10,
12,
13,
10,
17,
13
] |
[
[
200,
19
],
[
173,
26
],
[
191,
31
],
[
45,
44
],
[
165,
50
],
[
54,
54
],
[
58,
57
],
[
177,
63
],
[
67,
67
],
[
77,
76
],
[
180,
82
],
[
86,
86
],
[
90,
89
],
[
204,
95
],
[
99,
99
],
[
194,
101
],
[
207,
103
],
[
194,
104
],
[
108,
107
],
[
195,
110
],
[
180,
115
],
[
182,
117
],
[
209,
120
],
[
124,
123
],
[
195,
126
],
[
129,
128
],
[
171,
131
],
[
183,
136
],
[
123,
137
],
[
128,
138
],
[
161,
141
],
[
162,
145
],
[
210,
145
],
[
195,
148
],
[
171,
149
],
[
161,
162
],
[
194,
171
],
[
173,
174
],
[
182,
183
],
[
191,
192
],
[
194,
195
],
[
200,
201
],
[
209,
210
]
] |
[
"import sys\nsys.setrecursionlimit(10**6)\nfrom math import floor,ceil,sqrt,factorial,log\nfrom heapq import heappop, heappush, heappushpop\nfrom collections import Counter,defaultdict,deque\nfrom itertools import accumulate,permutations,combinations,product,combinations_with_replacement\nfrom bisect import bisect_left,bisect_right\nfrom copy import deepcopy\nfrom operator import itemgetter\nfrom fractions import gcd\nmod = 10 ** 9 + 7\ninf = float('inf')\nninf = -float('inf')\n \n#整数input\ndef ii(): return int(sys.stdin.readline().rstrip()) #int(input())\ndef mii(): return map(int,sys.stdin.readline().rstrip().split())\ndef limii(): return list(mii()) #list(map(int,input().split()))\ndef lin(n:int): return [ii() for _ in range(n)]\ndef llint(n: int): return [limii() for _ in range(n)]\n#文字列input\ndef ss(): return sys.stdin.readline().rstrip() #input()\ndef mss(): return sys.stdin.readline().rstrip().split()\ndef limss(): return list(mss()) #list(input().split())\ndef lst(n:int): return [ss() for _ in range(n)]\ndef llstr(n: int): return [limss() for _ in range(n)]\n\n#本当に貪欲法か? DP法では??\n#本当に貪欲法か? DP法では??\n#本当に貪欲法か? DP法では??\n\nh,w=mii()\n\nmat=[list(ss()) for _ in range(h) ]\ncnt=0\nfor i in range(h):\n for j in range(w):\n if mat[i][j]==\"#\":\n cnt+=1\n\nif cnt==h+w-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"import sys",
"sys",
"sys.setrecursionlimit(10**6)",
"sys.setrecursionlimit",
"sys",
"setrecursionlimit",
"10**6",
"10",
"6",
"from math import floor,ceil,sqrt,factorial,log",
"from heapq import heappop, heappush, heappushpop",
"from collections import Counter,defaultdict,deque",
"from itertools import accumulate,permutations,combinations,product,combinations_with_replacement",
"from bisect import bisect_left,bisect_right",
"from copy import deepcopy",
"from operator import itemgetter",
"from fractions import gcd",
"mod = 10 ** 9 + 7",
"mod",
"10 ** 9 + 7",
"10 ** 9",
"10",
"9",
"7",
"inf = float('inf')",
"inf",
"float('inf')",
"float",
"'inf'",
"ninf = -float('inf')",
"ninf",
"-float('inf')",
"float('inf')",
"float",
"'inf'",
"def ii(): return int(sys.stdin.readline().rstrip()) #int(input())",
"ii",
"def mii(): return map(int,sys.stdin.readline().rstrip().split())",
"mii",
"def limii(): return list(mii()) #list(map(int,input().split()))",
"limii",
"ii() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"ii()",
"ii",
"def lin(n:int): return [ii() for _ in range(n)]",
"lin",
"n:int",
"n",
"limii() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"limii()",
"limii",
"def llint(n: int): return [limii() for _ in range(n)]\n#文字列input",
"llint",
"n: int",
"n",
"def ss(): return sys.stdin.readline().rstrip() #input()",
"ss",
"def mss(): return sys.stdin.readline().rstrip().split()",
"mss",
"def limss(): return list(mss()) #list(input().split())",
"limss",
"ss() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"ss()",
"ss",
"def lst(n:int): return [ss() for _ in range(n)]",
"lst",
"n:int",
"n",
"limss() for _ in range(n)",
"for _ in range(n)",
"_",
"range(n)",
"range",
"n",
"for _ in range(n)",
"limss()",
"limss",
"def llstr(n: int): return [limss() for _ in range(n)]\n\n#本当に貪欲法か? DP法では??\n#本当に貪欲法か? DP法では??\n#本当に貪欲法か? DP法では??",
"llstr",
"n: int",
"n",
"h,w=mii()",
"h",
"mii()",
"mii",
"w",
"list(ss()) for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"list(ss())",
"list",
"ss()",
"ss",
"mat=[list(ss()) for _ in range(h) ]",
"mat",
"[list(ss()) for _ in range(h) ]",
"cnt=0",
"cnt",
"0",
"for i in range(h):\n for j in range(w):\n if mat[i][j]==\"#\":\n cnt+=1",
"i",
"range(h)",
"range",
"h",
"for j in range(w):\n if mat[i][j]==\"#\":\n cnt+=1",
"j",
"range(w)",
"range",
"w",
"if mat[i][j]==\"#\":\n cnt+=1",
"mat[i][j]==\"#\"",
"mat[i][j]",
"[i]",
"mat",
"i",
"j",
"\"#\"",
"cnt+=1",
"cnt",
"1",
"if cnt==h+w-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"cnt==h+w-1",
"cnt",
"h+w-1",
"h+w",
"h",
"w",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"def lst(n:int): return [ss() for _ in range(n)]",
"def lst(n:int): return [ss() for _ in range(n)]",
"lst",
"cnt+=1",
"1",
"cnt",
"def ii(): return int(sys.stdin.readline().rstrip()) #int(input())",
"def ii(): return int(sys.stdin.readline().rstrip()) #int(input())",
"ii",
"def llint(n: int): return [limii() for _ in range(n)]\n#文字列input",
"def llint(n: int): return [limii() for _ in range(n)]\n#文字列input",
"llint",
"w=mii()",
"mii()",
"w",
"inf = float('inf')",
"float('inf')",
"inf",
"def limii(): return list(mii()) #list(map(int,input().split()))",
"def limii(): return list(mii()) #list(map(int,input().split()))",
"limii",
"def ss(): return sys.stdin.readline().rstrip() #input()",
"def ss(): return sys.stdin.readline().rstrip() #input()",
"ss",
"mat=[list(ss()) for _ in range(h) ]",
"[list(ss()) for _ in range(h) ]",
"mat",
"def lin(n:int): return [ii() for _ in range(n)]",
"def lin(n:int): return [ii() for _ in range(n)]",
"lin",
"def llstr(n: int): return [limss() for _ in range(n)]\n\n#本当に貪欲法か? DP法では??\n#本当に貪欲法か? DP法では??\n#本当に貪欲法か? DP法では??",
"def llstr(n: int): return [limss() for _ in range(n)]\n\n#本当に貪欲法か? DP法では??\n#本当に貪欲法か? DP法では??\n#本当に貪欲法か? DP法では??",
"llstr",
"ninf = -float('inf')",
"-float('inf')",
"ninf",
"h,w=mii()",
"mii()",
"h",
"def mss(): return sys.stdin.readline().rstrip().split()",
"def mss(): return sys.stdin.readline().rstrip().split()",
"mss",
"mod = 10 ** 9 + 7",
"10 ** 9 + 7",
"mod",
"def limss(): return list(mss()) #list(input().split())",
"def limss(): return list(mss()) #list(input().split())",
"limss",
"def mii(): return map(int,sys.stdin.readline().rstrip().split())",
"def mii(): return map(int,sys.stdin.readline().rstrip().split())",
"mii",
"cnt=0",
"0",
"cnt"
] |
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]
#本当に貪欲法か? DP法では??
#本当に貪欲法か? DP法では??
#本当に貪欲法か? DP法では??
h,w=mii()
mat=[list(ss()) for _ in range(h) ]
cnt=0
for i in range(h):
for j in range(w):
if mat[i][j]=="#":
cnt+=1
if cnt==h+w-1:
print("Possible")
else:
print("Impossible")
|
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
18,
4,
18,
4,
13,
13,
13,
17,
14,
40,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
18,
13,
10,
4,
13
] |
[
[
64,
4
],
[
67,
11
],
[
65,
18
],
[
67,
20
],
[
58,
22
],
[
26,
25
],
[
68,
28
],
[
61,
30
],
[
65,
36
],
[
62,
42
],
[
59,
42
],
[
68,
45
],
[
56,
46
],
[
67,
56
],
[
58,
59
],
[
61,
62
],
[
64,
65
],
[
67,
68
]
] |
[
"import sys\nreadline = sys.stdin.readline\n\nH,W = map(int,readline().split())\nr = 0\nfor i in range(H):\n r += readline().rstrip().count(\"#\")\n \nif r != H + W - 1:\n print(\"Impossible\")\nelse:\n print(\"Possible\")",
"import sys",
"sys",
"readline = sys.stdin.readline",
"readline",
"sys.stdin.readline",
"sys.stdin",
"sys",
"stdin",
"readline",
"H,W = map(int,readline().split())",
"H",
"map(int,readline().split())",
"map",
"int",
"readline().split()",
"().split",
"()",
"readline",
"split",
"W",
"r = 0",
"r",
"0",
"for i in range(H):\n r += readline().rstrip().count(\"#\")\n ",
"i",
"range(H)",
"range",
"H",
"r += readline().rstrip().count(\"#\")",
"r",
"readline().rstrip().count(\"#\")",
"().rstrip().count",
"().rstrip()",
"().rstrip",
"()",
"readline",
"rstrip",
"count",
"\"#\"",
"if r != H + W - 1:\n print(\"Impossible\")\nelse:\n print(\"Possible\")",
"r != H + W - 1",
"r",
"H + W - 1",
"H + W",
"H",
"W",
"1",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"print(\"Possible\")",
"print",
"\"Possible\"",
"W = map(int,readline().split())",
"map(int,readline().split())",
"W",
"r = 0",
"0",
"r",
"r += readline().rstrip().count(\"#\")",
"readline().rstrip().count(\"#\")",
"r",
"readline = sys.stdin.readline",
"sys.stdin.readline",
"readline",
"H,W = map(int,readline().split())",
"map(int,readline().split())",
"H"
] |
import sys
readline = sys.stdin.readline
H,W = map(int,readline().split())
r = 0
for i in range(H):
r += readline().rstrip().count("#")
if r != H + W - 1:
print("Impossible")
else:
print("Possible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
13,
28,
13,
13,
14,
2,
13,
17,
0,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13
] |
[
[
63,
2
],
[
63,
11
],
[
15,
14
],
[
64,
17
],
[
60,
24
],
[
66,
27
],
[
31,
30
],
[
61,
30
],
[
34,
33
],
[
30,
33
],
[
33,
37
],
[
69,
40
],
[
70,
44
],
[
67,
44
],
[
64,
47
],
[
58,
48
],
[
63,
58
],
[
60,
61
],
[
63,
64
],
[
66,
67
],
[
69,
70
]
] |
[
"H,W=map(int,input().split())\nA= [list(input()) for _ in range(H)]\ncnt=0\nfor p in A:\n for q in p:\n if q==\"#\":\n cnt +=1\n\nif cnt == H+W-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"H,W=map(int,input().split())",
"H",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"list(input()) for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"list(input())",
"list",
"input()",
"input",
"A= [list(input()) for _ in range(H)]",
"A",
"[list(input()) for _ in range(H)]",
"cnt=0",
"cnt",
"0",
"for p in A:\n for q in p:\n if q==\"#\":\n cnt +=1",
"p",
"A",
"for q in p:\n if q==\"#\":\n cnt +=1",
"q",
"p",
"if q==\"#\":\n cnt +=1",
"q==\"#\"",
"q",
"\"#\"",
"cnt +=1",
"cnt",
"1",
"if cnt == H+W-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"cnt == H+W-1",
"cnt",
"H+W-1",
"H+W",
"H",
"W",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"W=map(int,input().split())",
"map(int,input().split())",
"W",
"A= [list(input()) for _ in range(H)]",
"[list(input()) for _ in range(H)]",
"A",
"H,W=map(int,input().split())",
"map(int,input().split())",
"H",
"cnt=0",
"0",
"cnt",
"cnt +=1",
"1",
"cnt"
] |
H,W=map(int,input().split())
A= [list(input()) for _ in range(H)]
cnt=0
for p in A:
for q in p:
if q=="#":
cnt +=1
if cnt == H+W-1:
print("Possible")
else:
print("Impossible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
28,
13,
4,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
8,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
61,
2
],
[
61,
11
],
[
52,
13
],
[
17,
16
],
[
62,
19
],
[
58,
21
],
[
26,
25
],
[
59,
30
],
[
59,
34
],
[
25,
35
],
[
53,
39
],
[
62,
42
],
[
56,
43
],
[
52,
53
],
[
61,
56
],
[
58,
59
],
[
61,
62
]
] |
[
"h, w = map(int, input().split())\ncnt = 0\nfor i in range(h):\n s = input()\n for j in range(len(s)):\n \tif s[j] == \"#\": cnt += 1\nprint(\"Possible\") if cnt == h + w - 1 else print(\"Impossible\")",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"cnt = 0",
"cnt",
"0",
"for i in range(h):\n s = input()\n for j in range(len(s)):\n \tif s[j] == \"#\": cnt += 1",
"i",
"range(h)",
"range",
"h",
"s = input()",
"s",
"input()",
"input",
"for j in range(len(s)):\n \tif s[j] == \"#\": cnt += 1",
"j",
"range(len(s))",
"range",
"len(s)",
"len",
"s",
"if s[j] == \"#\": cnt",
"s[j] == \"#\"",
"s[j]",
"s",
"j",
"\"#\"",
"print(\"Possible\") if cnt == h + w - 1 else print(\"Impossible\")",
"cnt == h + w - 1",
"cnt",
"h + w - 1",
"h + w",
"h",
"w",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"cnt = 0",
"0",
"cnt",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"s = input()",
"input()",
"s",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h"
] |
h, w = map(int, input().split())
cnt = 0
for i in range(h):
s = input()
for j in range(len(s)):
if s[j] == "#": cnt += 1
print("Possible") if cnt == h + w - 1 else print("Impossible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
2,
13,
17,
0,
13,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
18,
13,
13,
2,
2,
39,
17,
4,
13,
4,
13,
39,
17,
0,
13,
4,
18,
18,
13,
13,
13,
17,
0,
18,
13,
17,
2,
39,
17,
2,
13,
17,
0,
18,
13,
17,
2,
39,
17,
2,
13,
17,
0,
13,
17,
13,
17,
0,
13,
17,
0,
13,
17,
42,
17,
14,
2,
2,
13,
13,
2,
13,
13,
3,
0,
13,
17,
0,
13,
17,
14,
2,
18,
18,
13,
2,
13,
17,
13,
17,
0,
13,
17,
14,
2,
18,
18,
13,
13,
2,
13,
17,
17,
0,
13,
17,
14,
2,
2,
13,
17,
2,
13,
17,
0,
13,
17,
3,
14,
2,
2,
13,
17,
2,
13,
17,
0,
13,
17,
3,
14,
2,
13,
17,
0,
13,
17,
0,
13,
17,
0,
13,
17,
0,
13,
17,
14,
40,
2,
13,
17,
13,
0,
13,
17,
4,
13,
18,
39,
17,
17,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13
] |
[
[
221,
2
],
[
221,
11
],
[
224,
13
],
[
222,
18
],
[
206,
21
],
[
25,
24
],
[
222,
29
],
[
35,
32
],
[
225,
33
],
[
24,
34
],
[
209,
46
],
[
32,
49
],
[
225,
50
],
[
24,
51
],
[
58,
55
],
[
225,
56
],
[
186,
62
],
[
68,
65
],
[
225,
66
],
[
186,
72
],
[
200,
75
],
[
227,
77
],
[
233,
80
],
[
203,
83
],
[
201,
90
],
[
237,
90
],
[
222,
91
],
[
228,
93
],
[
219,
93
],
[
186,
94
],
[
242,
97
],
[
188,
100
],
[
225,
106
],
[
201,
108
],
[
237,
108
],
[
228,
110
],
[
219,
110
],
[
230,
113
],
[
225,
119
],
[
201,
120
],
[
237,
120
],
[
228,
122
],
[
219,
122
],
[
215,
126
],
[
231,
131
],
[
243,
131
],
[
216,
134
],
[
189,
134
],
[
194,
137
],
[
231,
143
],
[
243,
143
],
[
216,
146
],
[
189,
146
],
[
191,
149
],
[
231,
154
],
[
243,
154
],
[
236,
157
],
[
212,
160
],
[
218,
163
],
[
197,
166
],
[
198,
171
],
[
213,
171
],
[
234,
171
],
[
210,
173
],
[
207,
173
],
[
239,
175
],
[
240,
183
],
[
192,
183
],
[
195,
183
],
[
204,
183
],
[
221,
186
],
[
188,
189
],
[
191,
192
],
[
194,
195
],
[
197,
198
],
[
200,
201
],
[
203,
204
],
[
206,
207
],
[
209,
210
],
[
212,
213
],
[
215,
216
],
[
218,
219
],
[
221,
222
],
[
224,
225
],
[
227,
228
],
[
230,
231
],
[
233,
234
],
[
236,
237
],
[
239,
240
],
[
242,
243
]
] |
[
"h,w = map(int,input().split())\nc = [0]*(h+2)\n\nr = 0\n\nfor i in range(1,h+1):\n c[i] = [0] + list(input()) + [0]\n r += c[i].count(\"#\")\nc[0] = [0]*(w+2)\nc[-1] = [0]*(w+2)\n\nx,y = 1,1\n\nq = 0\nans = 1\nwhile 1:\n if x == h and y == w:\n break\n \n s = 0\n t = 0\n if c[x+1][y] == \"#\":\n s = 1\n if c[x][y+1] == \"#\":\n t = 1\n \n if s == 1 and t == 1:\n ans = 0\n break\n elif s == 0 and t == 0:\n ans = 0\n break\n elif s == 1:\n x += 1\n q += 1\n else:\n y += 1\n q += 1\nif q + 1 != r:\n ans = 0\n\nprint([\"Impossible\",\"Possible\"][ans])",
"h,w = map(int,input().split())",
"h",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"c = [0]*(h+2)",
"c",
"[0]*(h+2)",
"[0]",
"0",
"h+2",
"h",
"2",
"r = 0",
"r",
"0",
"for i in range(1,h+1):\n c[i] = [0] + list(input()) + [0]\n r += c[i].count(\"#\")",
"i",
"range(1,h+1)",
"range",
"1",
"h+1",
"h",
"1",
"c[i] = [0] + list(input()) + [0]",
"c[i]",
"c",
"i",
"[0] + list(input()) + [0]",
"[0] + list(input())",
"[0]",
"0",
"list(input())",
"list",
"input()",
"input",
"[0]",
"0",
"r += c[i].count(\"#\")",
"r",
"c[i].count(\"#\")",
"[i].count",
"[i]",
"c",
"i",
"count",
"\"#\"",
"c[0] = [0]*(w+2)",
"c[0]",
"c",
"0",
"[0]*(w+2)",
"[0]",
"0",
"w+2",
"w",
"2",
"c[-1] = [0]*(w+2)",
"c[-1]",
"c",
"-1",
"[0]*(w+2)",
"[0]",
"0",
"w+2",
"w",
"2",
"x,y = 1,1",
"x",
"1",
"y",
"1",
"q = 0",
"q",
"0",
"ans = 1",
"ans",
"1",
"while 1:\n if x == h and y == w:\n break\n \n s = 0\n t = 0\n if c[x+1][y] == \"#\":\n s = 1\n if c[x][y+1] == \"#\":\n t = 1\n \n if s == 1 and t == 1:\n ans = 0\n break\n elif s == 0 and t == 0:\n ans = 0\n break\n elif s == 1:\n x += 1\n q += 1\n else:\n y += 1\n q += 1",
"1",
"if x == h and y == w:\n break\n \n ",
"x == h and y == w",
"x == h",
"x",
"h",
"y == w",
"y",
"w",
"break",
"s = 0",
"s",
"0",
"t = 0",
"t",
"0",
"if c[x+1][y] == \"#\":\n s = 1\n ",
"c[x+1][y] == \"#\"",
"c[x+1][y]",
"[x+1]",
"c",
"x+1",
"x",
"1",
"y",
"\"#\"",
"s = 1",
"s",
"1",
"if c[x][y+1] == \"#\":\n t = 1\n \n ",
"c[x][y+1] == \"#\"",
"c[x][y+1]",
"[x]",
"c",
"x",
"y+1",
"y",
"1",
"\"#\"",
"t = 1",
"t",
"1",
"if s == 1 and t == 1:\n ans = 0\n break\n elif s == 0 and t == 0:\n ans = 0\n break\n elif s == 1:\n x += 1\n q += 1\n else:\n y += 1\n q += 1",
"s == 1 and t == 1",
"s == 1",
"s",
"1",
"t == 1",
"t",
"1",
"ans = 0",
"ans",
"0",
"break",
"elif s == 0 and t == 0:\n ans = 0\n break\n ",
"s == 0 and t == 0",
"s == 0",
"s",
"0",
"t == 0",
"t",
"0",
"ans = 0",
"ans",
"0",
"break",
"elif s == 1:\n x += 1\n q += 1\n ",
"s == 1",
"s",
"1",
"x += 1",
"x",
"1",
"q += 1",
"q",
"1",
"y += 1",
"y",
"1",
"q += 1",
"q",
"1",
"if q + 1 != r:\n ans = 0",
"q + 1 != r",
"q + 1",
"q",
"1",
"r",
"ans = 0",
"ans",
"0",
"print([\"Impossible\",\"Possible\"][ans])",
"print",
"[\"Impossible\",\"Possible\"][ans]",
"[\"Impossible\",\"Possible\"]",
"\"Impossible\"",
"\"Possible\"",
"ans",
"w = map(int,input().split())",
"map(int,input().split())",
"w",
"t = 0",
"0",
"t",
"ans = 0",
"0",
"ans",
"ans = 0",
"0",
"ans",
"q += 1",
"1",
"q",
"x,y = 1,1",
"1",
"x",
"ans = 1",
"1",
"ans",
"r = 0",
"0",
"r",
"r += c[i].count(\"#\")",
"c[i].count(\"#\")",
"r",
"q += 1",
"1",
"q",
"t = 1",
"1",
"t",
"y += 1",
"1",
"y",
"h,w = map(int,input().split())",
"map(int,input().split())",
"h",
"c = [0]*(h+2)",
"[0]*(h+2)",
"c",
"y = 1,1",
"1",
"y",
"s = 1",
"1",
"s",
"q = 0",
"0",
"q",
"x += 1",
"1",
"x",
"ans = 0",
"0",
"ans",
"s = 0",
"0",
"s"
] |
h,w = map(int,input().split())
c = [0]*(h+2)
r = 0
for i in range(1,h+1):
c[i] = [0] + list(input()) + [0]
r += c[i].count("#")
c[0] = [0]*(w+2)
c[-1] = [0]*(w+2)
x,y = 1,1
q = 0
ans = 1
while 1:
if x == h and y == w:
break
s = 0
t = 0
if c[x+1][y] == "#":
s = 1
if c[x][y+1] == "#":
t = 1
if s == 1 and t == 1:
ans = 0
break
elif s == 0 and t == 0:
ans = 0
break
elif s == 1:
x += 1
q += 1
else:
y += 1
q += 1
if q + 1 != r:
ans = 0
print(["Impossible","Possible"][ans])
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
2,
13,
13,
17,
0,
13,
39,
28,
13,
4,
13,
13,
0,
13,
4,
13,
4,
13,
0,
13,
4,
13,
13,
4,
18,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
14,
2,
13,
2,
13,
17,
4,
13,
17,
4,
13,
17,
10,
39,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
2,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13
] |
[
[
89,
2
],
[
89,
11
],
[
92,
13
],
[
84,
16
],
[
90,
17
],
[
80,
20
],
[
24,
23
],
[
84,
26
],
[
98,
28
],
[
101,
34
],
[
99,
37
],
[
102,
37
],
[
81,
40
],
[
102,
42
],
[
99,
42
],
[
86,
44
],
[
48,
47
],
[
84,
50
],
[
53,
52
],
[
90,
55
],
[
81,
60
],
[
47,
61
],
[
52,
62
],
[
95,
65
],
[
96,
69
],
[
87,
69
],
[
93,
71
],
[
80,
81
],
[
89,
84
],
[
86,
87
],
[
89,
90
],
[
92,
93
],
[
95,
96
],
[
98,
99
],
[
101,
102
]
] |
[
"H,W = map(int,input().split())\nstep = H+W-2\nA = []\nfor i in range(H):\n temp = str(input())\n temp = list(temp)\n A.append(temp)\ncnt = 0\nfor i in range(H):\n for j in range(W):\n if A[i][j] == \"#\":\n cnt += 1\nif cnt == step+1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"H,W = map(int,input().split())",
"H",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"step = H+W-2",
"step",
"H+W-2",
"H+W",
"H",
"W",
"2",
"A = []",
"A",
"[]",
"for i in range(H):\n temp = str(input())\n temp = list(temp)\n A.append(temp)",
"i",
"range(H)",
"range",
"H",
"temp = str(input())",
"temp",
"str(input())",
"str",
"input()",
"input",
"temp = list(temp)",
"temp",
"list(temp)",
"list",
"temp",
"A.append(temp)",
"A.append",
"A",
"append",
"temp",
"cnt = 0",
"cnt",
"0",
"for i in range(H):\n for j in range(W):\n if A[i][j] == \"#\":\n cnt += 1",
"i",
"range(H)",
"range",
"H",
"for j in range(W):\n if A[i][j] == \"#\":\n cnt += 1",
"j",
"range(W)",
"range",
"W",
"if A[i][j] == \"#\":\n cnt += 1",
"A[i][j] == \"#\"",
"A[i][j]",
"[i]",
"A",
"i",
"j",
"\"#\"",
"cnt += 1",
"cnt",
"1",
"if cnt == step+1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"cnt == step+1",
"cnt",
"step+1",
"step",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"A = []",
"[]",
"A",
"H,W = map(int,input().split())",
"map(int,input().split())",
"H",
"cnt = 0",
"0",
"cnt",
"W = map(int,input().split())",
"map(int,input().split())",
"W",
"step = H+W-2",
"H+W-2",
"step",
"cnt += 1",
"1",
"cnt",
"temp = str(input())",
"str(input())",
"temp",
"temp = list(temp)",
"list(temp)",
"temp"
] |
H,W = map(int,input().split())
step = H+W-2
A = []
for i in range(H):
temp = str(input())
temp = list(temp)
A.append(temp)
cnt = 0
for i in range(H):
for j in range(W):
if A[i][j] == "#":
cnt += 1
if cnt == step+1:
print("Possible")
else:
print("Impossible")
|
[
7,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
13,
4,
18,
13,
13,
4,
13,
4,
13,
0,
13,
17,
0,
13,
17,
42,
2,
2,
13,
13,
2,
13,
13,
14,
2,
2,
13,
2,
13,
17,
2,
18,
18,
13,
2,
13,
17,
13,
17,
0,
18,
18,
13,
13,
13,
17,
0,
13,
17,
14,
2,
2,
13,
2,
13,
17,
2,
18,
18,
13,
13,
2,
13,
17,
17,
0,
18,
18,
13,
13,
13,
17,
0,
13,
17,
3,
14,
2,
40,
13,
2,
13,
17,
40,
13,
2,
13,
17,
4,
13,
17,
0,
18,
18,
13,
13,
13,
17,
28,
13,
13,
14,
2,
17,
13,
4,
13,
17,
4,
13,
4,
13,
17,
10,
39,
13,
10,
17,
13,
10,
13,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13
] |
[
[
4,
3
],
[
3,
12
],
[
147,
14
],
[
147,
16
],
[
138,
18
],
[
22,
21
],
[
145,
24
],
[
139,
27
],
[
141,
34
],
[
156,
37
],
[
142,
42
],
[
154,
42
],
[
145,
43
],
[
157,
45
],
[
151,
45
],
[
148,
46
],
[
142,
50
],
[
154,
50
],
[
145,
52
],
[
139,
57
],
[
142,
59
],
[
154,
59
],
[
157,
61
],
[
151,
61
],
[
69,
64
],
[
139,
66
],
[
142,
67
],
[
154,
67
],
[
157,
68
],
[
151,
68
],
[
153,
71
],
[
157,
76
],
[
151,
76
],
[
148,
78
],
[
139,
83
],
[
142,
84
],
[
154,
84
],
[
157,
86
],
[
151,
86
],
[
95,
90
],
[
139,
92
],
[
142,
93
],
[
154,
93
],
[
157,
94
],
[
151,
94
],
[
150,
97
],
[
154,
103
],
[
142,
103
],
[
145,
105
],
[
151,
108
],
[
157,
108
],
[
148,
110
],
[
121,
116
],
[
139,
118
],
[
154,
119
],
[
142,
119
],
[
151,
120
],
[
157,
120
],
[
124,
123
],
[
139,
123
],
[
123,
128
],
[
138,
139
],
[
141,
142
],
[
147,
145
],
[
147,
148
],
[
150,
151
],
[
153,
154
],
[
156,
157
]
] |
[
"h, w = [int(i) for i in input().split()]\ngrid = []\nfor _ in range(h):\n grid.append(list(input()))\n\nx = 0\ny = 0\nwhile x < h or y < w:\n if x < h - 1 and grid[x + 1][y] == \"#\":\n grid[x][y] = \".\"\n x += 1\n elif y < w - 1 and grid[x][y + 1] == \"#\":\n grid[x][y] = \".\"\n y += 1\n else:\n break\n\nif x != h - 1 or y != w - 1:\n print(\"Impossible\")\nelse:\n grid[x][y] = \".\"\n for line in grid:\n if \"#\" in line:\n print(\"Impossible\")\n quit()\n print(\"Possible\")",
"int(i) for i in input().split()",
"for i in input().split()",
"i",
"input().split()",
"().split",
"()",
"input",
"split",
"for i in input().split()",
"int(i)",
"int",
"i",
"h, w = [int(i) for i in input().split()]",
"h",
"[int(i) for i in input().split()]",
"w",
"grid = []",
"grid",
"[]",
"for _ in range(h):\n grid.append(list(input()))",
"_",
"range(h)",
"range",
"h",
"grid.append(list(input()))",
"grid.append",
"grid",
"append",
"list(input())",
"list",
"input()",
"input",
"x = 0",
"x",
"0",
"y = 0",
"y",
"0",
"while x < h or y < w:\n if x < h - 1 and grid[x + 1][y] == \"#\":\n grid[x][y] = \".\"\n x += 1\n elif y < w - 1 and grid[x][y + 1] == \"#\":\n grid[x][y] = \".\"\n y += 1\n else:\n break",
"x < h or y < w",
"x < h",
"x",
"h",
"y < w",
"y",
"w",
"if x < h - 1 and grid[x + 1][y] == \"#\":\n grid[x][y] = \".\"\n x += 1\n elif y < w - 1 and grid[x][y + 1] == \"#\":\n grid[x][y] = \".\"\n y += 1\n else:\n break",
"x < h - 1 and grid[x + 1][y] == \"#\"",
"x < h - 1",
"x",
"h - 1",
"h",
"1",
"grid[x + 1][y] == \"#\"",
"grid[x + 1][y]",
"[x + 1]",
"grid",
"x + 1",
"x",
"1",
"y",
"\"#\"",
"grid[x][y] = \".\"",
"grid[x][y]",
"[x]",
"grid",
"x",
"y",
"\".\"",
"x += 1",
"x",
"1",
"elif y < w - 1 and grid[x][y + 1] == \"#\":\n grid[x][y] = \".\"\n y += 1\n ",
"y < w - 1 and grid[x][y + 1] == \"#\"",
"y < w - 1",
"y",
"w - 1",
"w",
"1",
"grid[x][y + 1] == \"#\"",
"grid[x][y + 1]",
"[x]",
"grid",
"x",
"y + 1",
"y",
"1",
"\"#\"",
"grid[x][y] = \".\"",
"grid[x][y]",
"[x]",
"grid",
"x",
"y",
"\".\"",
"y += 1",
"y",
"1",
"break",
"if x != h - 1 or y != w - 1:\n print(\"Impossible\")\nelse:\n grid[x][y] = \".\"\n for line in grid:\n if \"#\" in line:\n print(\"Impossible\")\n quit()\n print(\"Possible\")",
"x != h - 1 or y != w - 1",
"x != h - 1",
"x",
"h - 1",
"h",
"1",
"y != w - 1",
"y",
"w - 1",
"w",
"1",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"grid[x][y] = \".\"",
"grid[x][y]",
"[x]",
"grid",
"x",
"y",
"\".\"",
"for line in grid:\n if \"#\" in line:\n print(\"Impossible\")\n quit()\n ",
"line",
"grid",
"if \"#\" in line:\n print(\"Impossible\")\n quit()\n ",
"\"#\" in line",
"\"#\"",
"line",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"quit()",
"quit",
"print(\"Possible\")",
"print",
"\"Possible\"",
"grid = []",
"[]",
"grid",
"x = 0",
"0",
"x",
"h, w = [int(i) for i in input().split()]",
"[int(i) for i in input().split()]",
"h",
"w = [int(i) for i in input().split()]",
"[int(i) for i in input().split()]",
"w",
"y += 1",
"1",
"y",
"x += 1",
"1",
"x",
"y = 0",
"0",
"y"
] |
h, w = [int(i) for i in input().split()]
grid = []
for _ in range(h):
grid.append(list(input()))
x = 0
y = 0
while x < h or y < w:
if x < h - 1 and grid[x + 1][y] == "#":
grid[x][y] = "."
x += 1
elif y < w - 1 and grid[x][y + 1] == "#":
grid[x][y] = "."
y += 1
else:
break
if x != h - 1 or y != w - 1:
print("Impossible")
else:
grid[x][y] = "."
for line in grid:
if "#" in line:
print("Impossible")
quit()
print("Possible")
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
41,
28,
13,
4,
13,
13,
4,
2,
39,
17,
13,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
0,
13,
39,
39,
17,
17,
17,
17,
42,
13,
0,
13,
4,
18,
13,
13,
13,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
13,
39,
39,
17,
17,
39,
17,
17,
39,
17,
17,
39,
17,
17,
14,
2,
2,
2,
2,
2,
40,
17,
2,
13,
13,
13,
2,
40,
17,
2,
13,
13,
13,
40,
39,
2,
13,
13,
2,
13,
13,
39,
13,
13,
2,
18,
18,
13,
2,
13,
13,
2,
13,
13,
17,
40,
18,
18,
13,
2,
13,
13,
2,
13,
13,
0,
18,
18,
13,
2,
13,
13,
2,
13,
13,
17,
0,
13,
17,
4,
18,
13,
13,
39,
2,
13,
13,
2,
13,
13,
13,
13,
14,
2,
2,
13,
17,
2,
13,
17,
0,
13,
17,
14,
2,
40,
13,
17,
13,
4,
13,
17,
4,
13,
4,
13,
17,
10,
39,
13,
10,
4,
13,
10,
4,
13,
10,
17,
13,
10,
17,
13,
10,
17,
13,
10,
13,
13,
10,
13,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
4,
13
] |
[
[
226,
2
],
[
226,
11
],
[
15,
14
],
[
227,
17
],
[
208,
22
],
[
27,
26
],
[
227,
29
],
[
197,
34
],
[
211,
36
],
[
44,
39
],
[
212,
41
],
[
190,
46
],
[
223,
56
],
[
191,
59
],
[
223,
61
],
[
223,
62
],
[
223,
63
],
[
202,
65
],
[
205,
68
],
[
221,
95
],
[
227,
97
],
[
194,
102
],
[
197,
104
],
[
221,
108
],
[
194,
111
],
[
209,
119
],
[
221,
121
],
[
194,
124
],
[
212,
130
],
[
221,
132
],
[
194,
135
],
[
147,
138
],
[
212,
140
],
[
221,
142
],
[
194,
145
],
[
217,
149
],
[
191,
153
],
[
221,
157
],
[
194,
160
],
[
199,
173
],
[
218,
178
],
[
203,
178
],
[
200,
180
],
[
206,
180
],
[
190,
191
],
[
223,
194
],
[
226,
197
],
[
199,
200
],
[
202,
203
],
[
205,
206
],
[
208,
209
],
[
211,
212
],
[
223,
215
],
[
217,
218
],
[
223,
221
],
[
223,
224
],
[
226,
227
]
] |
[
"H, W = map(int, input().split())\nA = [input() for i in range(H)]\n\nvisited = [[False]*W for i in range(H)]\nvisited[0][0] = True\nd = [[0, 0, -1, -1]]\nwhile d:\n x, y, px, py = d.pop()\n num = 0\n flag = False\n for dx, dy in [[1, 0], [0, 1], [-1, 0], [0, -1]]:\n if 0<=x+dx<H and 0<=y+dy<W and [x+dx, y+dy]!=[px, py] and A[x+dx][y+dy]=='#' and not visited[x+dx][y+dy]:\n visited[x+dx][y+dy] = True\n num += 1\n d.append([x+dx, y+dy, x, y])\n if dx < 0 or dy < 0:\n flag = True\n if (num >= 2) or flag:\n print('Impossible')\n quit()\n\nprint('Possible')",
"H, W = map(int, input().split())",
"H",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"input() for i in range(H)",
"for i in range(H)",
"i",
"range(H)",
"range",
"H",
"for i in range(H)",
"input()",
"input",
"A = [input() for i in range(H)]",
"A",
"[input() for i in range(H)]",
"[False]*W for i in range(H)",
"for i in range(H)",
"i",
"range(H)",
"range",
"H",
"for i in range(H)",
"[False]*W",
"[False]",
"False",
"W",
"visited = [[False]*W for i in range(H)]",
"visited",
"[[False]*W for i in range(H)]",
"visited[0][0] = True",
"visited[0][0]",
"[0]",
"visited",
"0",
"0",
"True",
"d = [[0, 0, -1, -1]]",
"d",
"[[0, 0, -1, -1]]",
"[0, 0, -1, -1]",
"0",
"0",
"-1",
"-1",
"while d:\n x, y, px, py = d.pop()\n num = 0\n flag = False\n for dx, dy in [[1, 0], [0, 1], [-1, 0], [0, -1]]:\n if 0<=x+dx<H and 0<=y+dy<W and [x+dx, y+dy]!=[px, py] and A[x+dx][y+dy]=='#' and not visited[x+dx][y+dy]:\n visited[x+dx][y+dy] = True\n num += 1\n d.append([x+dx, y+dy, x, y])\n if dx < 0 or dy < 0:\n flag = True\n if (num >= 2) or flag:\n print('Impossible')\n quit()",
"d",
"x, y, px, py = d.pop()",
"x",
"d.pop()",
"d.pop",
"d",
"pop",
"y",
"px",
"py",
"num = 0",
"num",
"0",
"flag = False",
"flag",
"False",
"for dx, dy in [[1, 0], [0, 1], [-1, 0], [0, -1]]:\n if 0<=x+dx<H and 0<=y+dy<W and [x+dx, y+dy]!=[px, py] and A[x+dx][y+dy]=='#' and not visited[x+dx][y+dy]:\n visited[x+dx][y+dy] = True\n num += 1\n d.append([x+dx, y+dy, x, y])\n if dx < 0 or dy < 0:\n flag = True\n ",
"dx",
"dy",
"[[1, 0], [0, 1], [-1, 0], [0, -1]]",
"[1, 0]",
"1",
"0",
"[0, 1]",
"0",
"1",
"[-1, 0]",
"-1",
"0",
"[0, -1]",
"0",
"-1",
"if 0<=x+dx<H and 0<=y+dy<W and [x+dx, y+dy]!=[px, py] and A[x+dx][y+dy]=='#' and not visited[x+dx][y+dy]:\n visited[x+dx][y+dy] = True\n num += 1\n d.append([x+dx, y+dy, x, y])\n if dx < 0 or dy < 0:\n flag = True\n ",
"0<=x+dx<H and 0<=y+dy<W and [x+dx, y+dy]!=[px, py] and A[x+dx][y+dy]=='#' and not visited[x+dx][y+dy]",
"0<=x+dx<H and 0<=y+dy<W and [x+dx, y+dy]!=[px, py] and A[x+dx][y+dy]=='#'",
"0<=x+dx<H and 0<=y+dy<W and [x+dx, y+dy]!=[px, py]",
"0<=x+dx<H and 0<=y+dy<W",
"0<=x+dx<H",
"0<=x+dx",
"0",
"x+dx",
"x",
"dx",
"H",
"0<=y+dy<W",
"0<=y+dy",
"0",
"y+dy",
"y",
"dy",
"W",
"[x+dx, y+dy]!=[px, py]",
"[x+dx, y+dy]",
"x+dx",
"x",
"dx",
"y+dy",
"y",
"dy",
"[px, py]",
"px",
"py",
"A[x+dx][y+dy]=='#'",
"A[x+dx][y+dy]",
"[x+dx]",
"A",
"x+dx",
"x",
"dx",
"y+dy",
"y",
"dy",
"'#'",
"not visited[x+dx][y+dy]",
"visited[x+dx][y+dy]",
"[x+dx]",
"visited",
"x+dx",
"x",
"dx",
"y+dy",
"y",
"dy",
"visited[x+dx][y+dy] = True",
"visited[x+dx][y+dy]",
"[x+dx]",
"visited",
"x+dx",
"x",
"dx",
"y+dy",
"y",
"dy",
"True",
"num += 1",
"num",
"1",
"d.append([x+dx, y+dy, x, y])",
"d.append",
"d",
"append",
"[x+dx, y+dy, x, y]",
"x+dx",
"x",
"dx",
"y+dy",
"y",
"dy",
"x",
"y",
"if dx < 0 or dy < 0:\n flag = True\n ",
"dx < 0 or dy < 0",
"dx < 0",
"dx",
"0",
"dy < 0",
"dy",
"0",
"flag = True",
"flag",
"True",
"if (num >= 2) or flag:\n print('Impossible')\n quit()",
"(num >= 2) or flag",
"num >= 2",
"num",
"2",
"flag",
"print('Impossible')",
"print",
"'Impossible'",
"quit()",
"quit",
"print('Possible')",
"print",
"'Possible'",
"d = [[0, 0, -1, -1]]",
"[[0, 0, -1, -1]]",
"d",
"y, px, py = d.pop()",
"d.pop()",
"y",
"W = map(int, input().split())",
"map(int, input().split())",
"W",
"flag = True",
"True",
"flag",
"num = 0",
"0",
"num",
"flag = False",
"False",
"flag",
"A = [input() for i in range(H)]",
"[input() for i in range(H)]",
"A",
"visited = [[False]*W for i in range(H)]",
"[[False]*W for i in range(H)]",
"visited",
"px, py = d.pop()",
"d.pop()",
"px",
"num += 1",
"1",
"num",
"x, y, px, py = d.pop()",
"d.pop()",
"x",
"py = d.pop()",
"d.pop()",
"py",
"H, W = map(int, input().split())",
"map(int, input().split())",
"H"
] |
H, W = map(int, input().split())
A = [input() for i in range(H)]
visited = [[False]*W for i in range(H)]
visited[0][0] = True
d = [[0, 0, -1, -1]]
while d:
x, y, px, py = d.pop()
num = 0
flag = False
for dx, dy in [[1, 0], [0, 1], [-1, 0], [0, -1]]:
if 0<=x+dx<H and 0<=y+dy<W and [x+dx, y+dy]!=[px, py] and A[x+dx][y+dy]=='#' and not visited[x+dx][y+dy]:
visited[x+dx][y+dy] = True
num += 1
d.append([x+dx, y+dy, x, y])
if dx < 0 or dy < 0:
flag = True
if (num >= 2) or flag:
print('Impossible')
quit()
print('Possible')
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
41,
28,
13,
13,
4,
4,
18,
13,
13,
17,
0,
13,
4,
13,
13,
4,
13,
8,
2,
13,
2,
2,
13,
13,
17,
17,
17,
10,
4,
13,
10,
13,
13,
10,
4,
13,
10,
4,
13
] |
[
[
60,
2
],
[
60,
11
],
[
15,
14
],
[
61,
17
],
[
57,
24
],
[
29,
28
],
[
58,
28
],
[
28,
33
],
[
63,
37
],
[
64,
45
],
[
61,
48
],
[
55,
49
],
[
60,
55
],
[
57,
58
],
[
60,
61
],
[
63,
64
]
] |
[
"h, w = map(int, input().split())\na = [list(input()) for _ in range(h)]\n\ncnt = sum([row.count(\"#\") for row in a])\nprint(\"Possible\" if cnt == h + w - 1 else \"Impossible\")",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"list(input()) for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"list(input())",
"list",
"input()",
"input",
"a = [list(input()) for _ in range(h)]",
"a",
"[list(input()) for _ in range(h)]",
"row.count(\"#\") for row in a",
"for row in a",
"row",
"a",
"for row in a",
"row.count(\"#\")",
"row.count",
"row",
"count",
"\"#\"",
"cnt = sum([row.count(\"#\") for row in a])",
"cnt",
"sum([row.count(\"#\") for row in a])",
"sum",
"[row.count(\"#\") for row in a]",
"print(\"Possible\" if cnt == h + w - 1 else \"Impossible\")",
"print",
"\"Possible\" if cnt == h + w - 1 else \"Impossible\"",
"cnt == h + w - 1",
"cnt",
"h + w - 1",
"h + w",
"h",
"w",
"1",
"\"Possible\"",
"\"Impossible\"",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"a = [list(input()) for _ in range(h)]",
"[list(input()) for _ in range(h)]",
"a",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h",
"cnt = sum([row.count(\"#\") for row in a])",
"sum([row.count(\"#\") for row in a])",
"cnt"
] |
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
cnt = sum([row.count("#") for row in a])
print("Possible" if cnt == h + w - 1 else "Impossible")
|
[
7,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
0,
13,
39,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
0,
13,
2,
13,
17,
0,
13,
4,
13,
13,
28,
13,
13,
14,
2,
13,
17,
0,
13,
17,
4,
18,
13,
13,
13,
4,
18,
13,
13,
4,
13,
2,
17,
13,
14,
40,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
0,
13,
39,
39,
17,
17,
42,
2,
4,
13,
13,
17,
0,
13,
4,
18,
13,
13,
17,
13,
14,
2,
2,
13,
2,
13,
17,
2,
13,
2,
13,
17,
4,
13,
17,
4,
13,
14,
2,
18,
18,
13,
2,
13,
17,
13,
17,
4,
18,
13,
13,
39,
2,
13,
17,
13,
14,
2,
18,
18,
13,
13,
2,
13,
17,
17,
4,
18,
13,
13,
39,
13,
2,
13,
17,
4,
13,
17,
10,
4,
13,
10,
4,
13,
10,
39,
13,
10,
13,
13,
10,
2,
13,
10,
13,
13,
10,
4,
13,
10,
39,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13
] |
[
[
4,
3
],
[
3,
12
],
[
173,
14
],
[
173,
16
],
[
179,
18
],
[
188,
21
],
[
25,
24
],
[
174,
27
],
[
161,
29
],
[
170,
33
],
[
162,
35
],
[
186,
35
],
[
171,
35
],
[
185,
38
],
[
171,
41
],
[
162,
41
],
[
186,
41
],
[
44,
43
],
[
186,
43
],
[
171,
43
],
[
162,
43
],
[
43,
47
],
[
182,
50
],
[
180,
54
],
[
186,
56
],
[
171,
56
],
[
162,
56
],
[
180,
59
],
[
168,
65
],
[
183,
68
],
[
189,
68
],
[
174,
71
],
[
168,
72
],
[
164,
80
],
[
165,
89
],
[
176,
92
],
[
165,
95
],
[
176,
98
],
[
159,
102
],
[
174,
104
],
[
177,
107
],
[
168,
109
],
[
180,
120
],
[
159,
122
],
[
177,
124
],
[
165,
128
],
[
159,
132
],
[
180,
139
],
[
159,
140
],
[
177,
142
],
[
165,
147
],
[
177,
152
],
[
176,
159
],
[
161,
162
],
[
164,
165
],
[
173,
168
],
[
170,
171
],
[
173,
174
],
[
176,
177
],
[
179,
180
],
[
182,
183
],
[
185,
186
],
[
188,
189
]
] |
[
"h,w = (int(x) for x in input().split())\nab = []\ncount = 0\nfor _ in range(h):\n a = input()\n a = a+'.'\n a=list(a)\n for i in a:\n if i == '#':\n count += 1\n ab.append(a)\nab.append(list('.'*w))\n\nif count != h+w-1:\n print('Impossible')\n exit()\n \nstep = [[0, 0]]\n \nwhile len(step) > 0:\n y, x = step.pop(0)\n if y == h-1 and x == w-1:\n print('Possible')\n exit()\n if ab[y+1][x] == '#' :\n step.append([y+1, x])\n elif ab[y][x+1] == '#' :\n step.append([y, x+1])\n\nprint('Impossible') ",
"int(x) for x in input().split()",
"for x in input().split()",
"x",
"input().split()",
"().split",
"()",
"input",
"split",
"for x in input().split()",
"int(x)",
"int",
"x",
"h,w = (int(x) for x in input().split())",
"h",
"(int(x) for x in input().split())",
"w",
"ab = []",
"ab",
"[]",
"count = 0",
"count",
"0",
"for _ in range(h):\n a = input()\n a = a+'.'\n a=list(a)\n for i in a:\n if i == '#':\n count += 1\n ab.append(a)",
"_",
"range(h)",
"range",
"h",
"a = input()",
"a",
"input()",
"input",
"a = a+'.'",
"a",
"a+'.'",
"a",
"'.'",
"a=list(a)",
"a",
"list(a)",
"list",
"a",
"for i in a:\n if i == '#':\n count += 1\n ",
"i",
"a",
"if i == '#':\n count += 1\n ",
"i == '#'",
"i",
"'#'",
"count += 1",
"count",
"1",
"ab.append(a)",
"ab.append",
"ab",
"append",
"a",
"ab.append(list('.'*w))",
"ab.append",
"ab",
"append",
"list('.'*w)",
"list",
"'.'*w",
"'.'",
"w",
"if count != h+w-1:\n print('Impossible')\n exit()\n ",
"count != h+w-1",
"count",
"h+w-1",
"h+w",
"h",
"w",
"1",
"print('Impossible')",
"print",
"'Impossible'",
"exit()",
"exit",
"step = [[0, 0]]",
"step",
"[[0, 0]]",
"[0, 0]",
"0",
"0",
"while len(step) > 0:\n y, x = step.pop(0)\n if y == h-1 and x == w-1:\n print('Possible')\n exit()\n if ab[y+1][x] == '#' :\n step.append([y+1, x])\n elif ab[y][x+1] == '#' :\n step.append([y, x+1])",
"len(step) > 0",
"len(step)",
"len",
"step",
"0",
"y, x = step.pop(0)",
"y",
"step.pop(0)",
"step.pop",
"step",
"pop",
"0",
"x",
"if y == h-1 and x == w-1:\n print('Possible')\n exit()\n ",
"y == h-1 and x == w-1",
"y == h-1",
"y",
"h-1",
"h",
"1",
"x == w-1",
"x",
"w-1",
"w",
"1",
"print('Possible')",
"print",
"'Possible'",
"exit()",
"exit",
"if ab[y+1][x] == '#' :\n step.append([y+1, x])\n elif ab[y][x+1] == '#' :\n step.append([y, x+1])",
"ab[y+1][x] == '#'",
"ab[y+1][x]",
"[y+1]",
"ab",
"y+1",
"y",
"1",
"x",
"'#'",
"step.append([y+1, x])",
"step.append",
"step",
"append",
"[y+1, x]",
"y+1",
"y",
"1",
"x",
"elif ab[y][x+1] == '#' :\n step.append([y, x+1])",
"ab[y][x+1] == '#'",
"ab[y][x+1]",
"[y]",
"ab",
"y",
"x+1",
"x",
"1",
"'#'",
"step.append([y, x+1])",
"step.append",
"step",
"append",
"[y, x+1]",
"y",
"x+1",
"x",
"1",
"print('Impossible')",
"print",
"'Impossible'",
"y, x = step.pop(0)",
"step.pop(0)",
"y",
"a = input()",
"input()",
"a",
"step = [[0, 0]]",
"[[0, 0]]",
"step",
"w = (int(x) for x in input().split())",
"(int(x) for x in input().split())",
"w",
"a = a+'.'",
"a+'.'",
"a",
"h,w = (int(x) for x in input().split())",
"(int(x) for x in input().split())",
"h",
"x = step.pop(0)",
"step.pop(0)",
"x",
"ab = []",
"[]",
"ab",
"count += 1",
"1",
"count",
"a=list(a)",
"list(a)",
"a",
"count = 0",
"0",
"count"
] |
h,w = (int(x) for x in input().split())
ab = []
count = 0
for _ in range(h):
a = input()
a = a+'.'
a=list(a)
for i in a:
if i == '#':
count += 1
ab.append(a)
ab.append(list('.'*w))
if count != h+w-1:
print('Impossible')
exit()
step = [[0, 0]]
while len(step) > 0:
y, x = step.pop(0)
if y == h-1 and x == w-1:
print('Possible')
exit()
if ab[y+1][x] == '#' :
step.append([y+1, x])
elif ab[y][x+1] == '#' :
step.append([y, x+1])
print('Impossible')
|
[
7,
12,
13,
17,
15,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
13,
28,
13,
13,
14,
2,
13,
17,
0,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13
] |
[
[
9,
8
],
[
8,
17
],
[
20,
19
],
[
20,
21
],
[
25,
24
],
[
19,
27
],
[
32,
31
],
[
35,
34
],
[
38,
37
],
[
31,
37
],
[
41,
40
],
[
37,
40
],
[
40,
44
],
[
48,
47
],
[
47,
51
],
[
34,
51
],
[
19,
54
],
[
21,
55
],
[
71,
68
]
] |
[
"def resolve():\n '''\n code here\n '''\n import collections\n H, W = [int(item) for item in input().split()]\n\n grid = [[item for item in input()] for _ in range(H)]\n\n cnt = 0\n for line in grid:\n for i in line:\n if i == '#':\n cnt += 1\n\n if cnt > H + W -1:\n print('Impossible')\n else:\n print('Possible')\n\nif __name__ == \"__main__\":\n resolve()",
"def resolve():\n '''\n code here\n '''\n import collections\n H, W = [int(item) for item in input().split()]\n\n grid = [[item for item in input()] for _ in range(H)]\n\n cnt = 0\n for line in grid:\n for i in line:\n if i == '#':\n cnt += 1\n\n if cnt > H + W -1:\n print('Impossible')\n else:\n print('Possible')",
"resolve",
"'''\n code here\n '''",
"import collections",
"collections",
"int(item) for item in input().split()",
"for item in input().split()",
"item",
"input().split()",
"().split",
"()",
"input",
"split",
"for item in input().split()",
"int(item)",
"int",
"item",
"H, W = [int(item) for item in input().split()]",
"H",
"[int(item) for item in input().split()]",
"W",
"[item for item in input()] for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"[item for item in input()]",
"grid = [[item for item in input()] for _ in range(H)]",
"grid",
"[[item for item in input()] for _ in range(H)]",
"cnt = 0",
"cnt",
"0",
"for line in grid:\n for i in line:\n if i == '#':\n cnt += 1\n\n ",
"line",
"grid",
"for i in line:\n if i == '#':\n cnt += 1\n\n ",
"i",
"line",
"if i == '#':\n cnt += 1\n\n ",
"i == '#'",
"i",
"'#'",
"cnt += 1",
"cnt",
"1",
"if cnt > H + W -1:\n print('Impossible')\n else:\n print('Possible')",
"cnt > H + W -1",
"cnt",
"H + W -1",
"H + W",
"H",
"W",
"1",
"print('Impossible')",
"print",
"'Impossible'",
"print('Possible')",
"print",
"'Possible'",
"if __name__ == \"__main__\":\n resolve()",
"__name__ == \"__main__\"",
"__name__",
"\"__main__\"",
"resolve()",
"resolve",
"def resolve():\n '''\n code here\n '''\n import collections\n H, W = [int(item) for item in input().split()]\n\n grid = [[item for item in input()] for _ in range(H)]\n\n cnt = 0\n for line in grid:\n for i in line:\n if i == '#':\n cnt += 1\n\n if cnt > H + W -1:\n print('Impossible')\n else:\n print('Possible')",
"def resolve():\n '''\n code here\n '''\n import collections\n H, W = [int(item) for item in input().split()]\n\n grid = [[item for item in input()] for _ in range(H)]\n\n cnt = 0\n for line in grid:\n for i in line:\n if i == '#':\n cnt += 1\n\n if cnt > H + W -1:\n print('Impossible')\n else:\n print('Possible')",
"resolve"
] |
def resolve():
'''
code here
'''
import collections
H, W = [int(item) for item in input().split()]
grid = [[item for item in input()] for _ in range(H)]
cnt = 0
for line in grid:
for i in line:
if i == '#':
cnt += 1
if cnt > H + W -1:
print('Impossible')
else:
print('Possible')
if __name__ == "__main__":
resolve()
|
[
7,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
15,
15,
12,
13,
12,
13,
12,
13,
0,
13,
4,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
18,
4,
13,
13,
17,
14,
2,
13,
2,
2,
13,
13,
17,
4,
13,
17,
4,
13,
17,
10,
12,
13,
10,
12,
13,
10,
4,
13,
10,
17,
13,
10,
4,
13,
10,
12,
13,
10,
4,
13
] |
[
[
76,
23
],
[
74,
25
],
[
76,
26
],
[
67,
28
],
[
32,
31
],
[
71,
34
],
[
64,
36
],
[
62,
40
],
[
65,
45
],
[
68,
45
],
[
71,
48
],
[
77,
49
],
[
64,
65
],
[
67,
68
],
[
76,
71
],
[
76,
77
]
] |
[
"import sys\nimport heapq\nimport math\nimport fractions\nimport bisect\nimport itertools\nfrom collections import Counter\nfrom collections import deque\nfrom operator import itemgetter\ndef input(): return sys.stdin.readline().strip()\ndef mp(): return map(int,input().split())\ndef lmp(): return list(map(int,input().split()))\n\nh,w=mp()\nans=0\nfor i in range(h):\n ans+=input().count(\"#\")\nif ans==h+w-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"import sys",
"sys",
"import heapq",
"heapq",
"import math",
"math",
"import fractions",
"fractions",
"import bisect",
"bisect",
"import itertools",
"itertools",
"from collections import Counter",
"from collections import deque",
"from operator import itemgetter",
"def input(): return sys.stdin.readline().strip()",
"input",
"def mp(): return map(int,input().split())",
"mp",
"def lmp(): return list(map(int,input().split()))",
"lmp",
"h,w=mp()",
"h",
"mp()",
"mp",
"w",
"ans=0",
"ans",
"0",
"for i in range(h):\n ans+=input().count(\"#\")",
"i",
"range(h)",
"range",
"h",
"ans+=input().count(\"#\")",
"ans",
"input().count(\"#\")",
"().count",
"()",
"input",
"count",
"\"#\"",
"if ans==h+w-1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")",
"ans==h+w-1",
"ans",
"h+w-1",
"h+w",
"h",
"w",
"1",
"print(\"Possible\")",
"print",
"\"Possible\"",
"print(\"Impossible\")",
"print",
"\"Impossible\"",
"def lmp(): return list(map(int,input().split()))",
"def lmp(): return list(map(int,input().split()))",
"lmp",
"def input(): return sys.stdin.readline().strip()",
"def input(): return sys.stdin.readline().strip()",
"input",
"ans+=input().count(\"#\")",
"input().count(\"#\")",
"ans",
"ans=0",
"0",
"ans",
"h,w=mp()",
"mp()",
"h",
"def mp(): return map(int,input().split())",
"def mp(): return map(int,input().split())",
"mp",
"w=mp()",
"mp()",
"w"
] |
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))
h,w=mp()
ans=0
for i in range(h):
ans+=input().count("#")
if ans==h+w-1:
print("Possible")
else:
print("Impossible")
|
[
7,
15,
12,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
0,
13,
13,
0,
13,
4,
13,
4,
18,
13,
13,
39,
17,
17,
0,
13,
17,
42,
2,
4,
13,
13,
17,
0,
13,
4,
18,
13,
13,
13,
0,
18,
18,
13,
13,
13,
17,
14,
2,
39,
13,
13,
39,
2,
13,
17,
2,
13,
17,
0,
13,
17,
3,
0,
13,
13,
13,
2,
13,
17,
14,
2,
2,
13,
13,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
3,
14,
13,
3,
4,
18,
13,
13,
39,
13,
13,
9,
0,
13,
2,
13,
17,
13,
13,
14,
2,
2,
13,
13,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
28,
13,
4,
13,
13,
13,
14,
2,
18,
18,
13,
13,
13,
17,
0,
13,
17,
3,
14,
13,
3,
4,
18,
13,
13,
39,
13,
13,
9,
14,
13,
4,
13,
17,
4,
13,
17,
14,
2,
13,
17,
4,
13,
10,
12,
13
] |
[
[
6,
5
],
[
6,
16
],
[
20,
19
],
[
5,
22
],
[
30,
29
],
[
33,
32
],
[
32,
37
],
[
44,
43
],
[
32,
49
],
[
53,
52
],
[
32,
55
],
[
53,
57
],
[
64,
59
],
[
29,
61
],
[
52,
62
],
[
57,
63
],
[
5,
72
],
[
16,
75
],
[
79,
78
],
[
83,
82
],
[
52,
83
],
[
85,
84
],
[
57,
86
],
[
84,
91
],
[
137,
91
],
[
16,
92
],
[
29,
96
],
[
82,
97
],
[
133,
97
],
[
84,
98
],
[
137,
98
],
[
102,
101
],
[
105,
104
],
[
82,
107
],
[
133,
107
],
[
5,
108
],
[
29,
113
],
[
104,
114
],
[
57,
115
],
[
119,
118
],
[
32,
126
],
[
134,
133
],
[
52,
135
],
[
138,
137
],
[
57,
138
],
[
133,
142
],
[
82,
142
],
[
5,
143
],
[
29,
147
],
[
133,
148
],
[
82,
148
],
[
137,
149
],
[
84,
149
],
[
153,
152
],
[
156,
155
],
[
137,
158
],
[
84,
158
],
[
16,
159
],
[
29,
164
],
[
52,
165
],
[
155,
166
],
[
170,
169
],
[
32,
177
],
[
199,
196
]
] |
[
"from collections import deque\n\n\ndef main():\n H, W = list(map(int, input().split()))\n A = [list(input()) for _ in range(H)]\n # 「右or下のみ移動可」で深さ優先探索\n # 移動時、該当マスを左上角とする長方形領域以外に未訪問の '#' があったらNG\n # ゴールに到達できなくてもNG\n que = deque()\n que.append((0, 0))\n ok = False\n while len(que) > 0:\n h, w = que.pop()\n A[h][w] = '.'\n if (h, w) == (H - 1, W - 1):\n ok = True\n break\n # 横方向\n next_h, next_w = h, w + 1\n if next_w < W and A[next_h][next_w] == '#':\n exist_unvisited = False\n for hh in range(next_h, H):\n if A[hh][w] == '#':\n exist_unvisited = True\n break\n if exist_unvisited:\n break\n que.append((next_h, next_w))\n continue\n # 縦方向\n next_h, next_w = h + 1, w\n if next_h < H and A[next_h][next_w] == '#':\n exist_unvisited = False\n for ww in range(next_w, W):\n if A[h][ww] == '#':\n exist_unvisited = True\n break\n if exist_unvisited:\n break\n que.append((next_h, next_w))\n continue\n if ok:\n print('Possible')\n else:\n print('Impossible')\n\n\nif __name__ == '__main__':\n main()",
"from collections import deque",
"def main():\n H, W = list(map(int, input().split()))\n A = [list(input()) for _ in range(H)]\n # 「右or下のみ移動可」で深さ優先探索\n # 移動時、該当マスを左上角とする長方形領域以外に未訪問の '#' があったらNG\n # ゴールに到達できなくてもNG\n que = deque()\n que.append((0, 0))\n ok = False\n while len(que) > 0:\n h, w = que.pop()\n A[h][w] = '.'\n if (h, w) == (H - 1, W - 1):\n ok = True\n break\n # 横方向\n next_h, next_w = h, w + 1\n if next_w < W and A[next_h][next_w] == '#':\n exist_unvisited = False\n for hh in range(next_h, H):\n if A[hh][w] == '#':\n exist_unvisited = True\n break\n if exist_unvisited:\n break\n que.append((next_h, next_w))\n continue\n # 縦方向\n next_h, next_w = h + 1, w\n if next_h < H and A[next_h][next_w] == '#':\n exist_unvisited = False\n for ww in range(next_w, W):\n if A[h][ww] == '#':\n exist_unvisited = True\n break\n if exist_unvisited:\n break\n que.append((next_h, next_w))\n continue\n if ok:\n print('Possible')\n else:\n print('Impossible')",
"main",
"H, W = list(map(int, input().split()))",
"H",
"list(map(int, input().split()))",
"list",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"W",
"list(input()) for _ in range(H)",
"for _ in range(H)",
"_",
"range(H)",
"range",
"H",
"for _ in range(H)",
"list(input())",
"list",
"input()",
"input",
"A = [list(input()) for _ in range(H)]",
"A",
"[list(input()) for _ in range(H)]",
"que = deque()",
"que",
"deque()",
"deque",
"que.append((0, 0))",
"que.append",
"que",
"append",
"(0, 0)",
"0",
"0",
"ok = False",
"ok",
"False",
"while len(que) > 0:\n h, w = que.pop()\n A[h][w] = '.'\n if (h, w) == (H - 1, W - 1):\n ok = True\n break\n # 横方向\n next_h, next_w = h, w + 1\n if next_w < W and A[next_h][next_w] == '#':\n exist_unvisited = False\n for hh in range(next_h, H):\n if A[hh][w] == '#':\n exist_unvisited = True\n break\n if exist_unvisited:\n break\n que.append((next_h, next_w))\n continue\n # 縦方向\n next_h, next_w = h + 1, w\n if next_h < H and A[next_h][next_w] == '#':\n exist_unvisited = False\n for ww in range(next_w, W):\n if A[h][ww] == '#':\n exist_unvisited = True\n break\n if exist_unvisited:\n break\n que.append((next_h, next_w))\n continue\n ",
"len(que) > 0",
"len(que)",
"len",
"que",
"0",
"h, w = que.pop()",
"h",
"que.pop()",
"que.pop",
"que",
"pop",
"w",
"A[h][w] = '.'",
"A[h][w]",
"[h]",
"A",
"h",
"w",
"'.'",
"if (h, w) == (H - 1, W - 1):\n ok = True\n break\n # 横方向\n ",
"(h, w) == (H - 1, W - 1)",
"(h, w)",
"h",
"w",
"(H - 1, W - 1)",
"H - 1",
"H",
"1",
"W - 1",
"W",
"1",
"ok = True",
"ok",
"True",
"break",
"next_h, next_w = h, w + 1",
"next_h",
"h",
"next_w",
"w + 1",
"w",
"1",
"if next_w < W and A[next_h][next_w] == '#':\n exist_unvisited = False\n for hh in range(next_h, H):\n if A[hh][w] == '#':\n exist_unvisited = True\n break\n if exist_unvisited:\n break\n que.append((next_h, next_w))\n continue\n # 縦方向\n ",
"next_w < W and A[next_h][next_w] == '#'",
"next_w < W",
"next_w",
"W",
"A[next_h][next_w] == '#'",
"A[next_h][next_w]",
"[next_h]",
"A",
"next_h",
"next_w",
"'#'",
"exist_unvisited = False",
"exist_unvisited",
"False",
"for hh in range(next_h, H):\n if A[hh][w] == '#':\n exist_unvisited = True\n break\n ",
"hh",
"range(next_h, H)",
"range",
"next_h",
"H",
"if A[hh][w] == '#':\n exist_unvisited = True\n break\n ",
"A[hh][w] == '#'",
"A[hh][w]",
"[hh]",
"A",
"hh",
"w",
"'#'",
"exist_unvisited = True",
"exist_unvisited",
"True",
"break",
"if exist_unvisited:\n break\n ",
"exist_unvisited",
"break",
"que.append((next_h, next_w))",
"que.append",
"que",
"append",
"(next_h, next_w)",
"next_h",
"next_w",
"continue",
"next_h, next_w = h + 1, w",
"next_h",
"h + 1",
"h",
"1",
"next_w",
"w",
"if next_h < H and A[next_h][next_w] == '#':\n exist_unvisited = False\n for ww in range(next_w, W):\n if A[h][ww] == '#':\n exist_unvisited = True\n break\n if exist_unvisited:\n break\n que.append((next_h, next_w))\n continue\n ",
"next_h < H and A[next_h][next_w] == '#'",
"next_h < H",
"next_h",
"H",
"A[next_h][next_w] == '#'",
"A[next_h][next_w]",
"[next_h]",
"A",
"next_h",
"next_w",
"'#'",
"exist_unvisited = False",
"exist_unvisited",
"False",
"for ww in range(next_w, W):\n if A[h][ww] == '#':\n exist_unvisited = True\n break\n ",
"ww",
"range(next_w, W)",
"range",
"next_w",
"W",
"if A[h][ww] == '#':\n exist_unvisited = True\n break\n ",
"A[h][ww] == '#'",
"A[h][ww]",
"[h]",
"A",
"h",
"ww",
"'#'",
"exist_unvisited = True",
"exist_unvisited",
"True",
"break",
"if exist_unvisited:\n break\n ",
"exist_unvisited",
"break",
"que.append((next_h, next_w))",
"que.append",
"que",
"append",
"(next_h, next_w)",
"next_h",
"next_w",
"continue",
"if ok:\n print('Possible')\n else:\n print('Impossible')",
"ok",
"print('Possible')",
"print",
"'Possible'",
"print('Impossible')",
"print",
"'Impossible'",
"if __name__ == '__main__':\n main()",
"__name__ == '__main__'",
"__name__",
"'__main__'",
"main()",
"main",
"def main():\n H, W = list(map(int, input().split()))\n A = [list(input()) for _ in range(H)]\n # 「右or下のみ移動可」で深さ優先探索\n # 移動時、該当マスを左上角とする長方形領域以外に未訪問の '#' があったらNG\n # ゴールに到達できなくてもNG\n que = deque()\n que.append((0, 0))\n ok = False\n while len(que) > 0:\n h, w = que.pop()\n A[h][w] = '.'\n if (h, w) == (H - 1, W - 1):\n ok = True\n break\n # 横方向\n next_h, next_w = h, w + 1\n if next_w < W and A[next_h][next_w] == '#':\n exist_unvisited = False\n for hh in range(next_h, H):\n if A[hh][w] == '#':\n exist_unvisited = True\n break\n if exist_unvisited:\n break\n que.append((next_h, next_w))\n continue\n # 縦方向\n next_h, next_w = h + 1, w\n if next_h < H and A[next_h][next_w] == '#':\n exist_unvisited = False\n for ww in range(next_w, W):\n if A[h][ww] == '#':\n exist_unvisited = True\n break\n if exist_unvisited:\n break\n que.append((next_h, next_w))\n continue\n if ok:\n print('Possible')\n else:\n print('Impossible')",
"def main():\n H, W = list(map(int, input().split()))\n A = [list(input()) for _ in range(H)]\n # 「右or下のみ移動可」で深さ優先探索\n # 移動時、該当マスを左上角とする長方形領域以外に未訪問の '#' があったらNG\n # ゴールに到達できなくてもNG\n que = deque()\n que.append((0, 0))\n ok = False\n while len(que) > 0:\n h, w = que.pop()\n A[h][w] = '.'\n if (h, w) == (H - 1, W - 1):\n ok = True\n break\n # 横方向\n next_h, next_w = h, w + 1\n if next_w < W and A[next_h][next_w] == '#':\n exist_unvisited = False\n for hh in range(next_h, H):\n if A[hh][w] == '#':\n exist_unvisited = True\n break\n if exist_unvisited:\n break\n que.append((next_h, next_w))\n continue\n # 縦方向\n next_h, next_w = h + 1, w\n if next_h < H and A[next_h][next_w] == '#':\n exist_unvisited = False\n for ww in range(next_w, W):\n if A[h][ww] == '#':\n exist_unvisited = True\n break\n if exist_unvisited:\n break\n que.append((next_h, next_w))\n continue\n if ok:\n print('Possible')\n else:\n print('Impossible')",
"main"
] |
from collections import deque
def main():
H, W = list(map(int, input().split()))
A = [list(input()) for _ in range(H)]
# 「右or下のみ移動可」で深さ優先探索
# 移動時、該当マスを左上角とする長方形領域以外に未訪問の '#' があったらNG
# ゴールに到達できなくてもNG
que = deque()
que.append((0, 0))
ok = False
while len(que) > 0:
h, w = que.pop()
A[h][w] = '.'
if (h, w) == (H - 1, W - 1):
ok = True
break
# 横方向
next_h, next_w = h, w + 1
if next_w < W and A[next_h][next_w] == '#':
exist_unvisited = False
for hh in range(next_h, H):
if A[hh][w] == '#':
exist_unvisited = True
break
if exist_unvisited:
break
que.append((next_h, next_w))
continue
# 縦方向
next_h, next_w = h + 1, w
if next_h < H and A[next_h][next_w] == '#':
exist_unvisited = False
for ww in range(next_w, W):
if A[h][ww] == '#':
exist_unvisited = True
break
if exist_unvisited:
break
que.append((next_h, next_w))
continue
if ok:
print('Possible')
else:
print('Impossible')
if __name__ == '__main__':
main()
|
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
0,
13,
13,
0,
13,
4,
18,
13,
13,
39,
2,
13,
17,
2,
13,
17,
0,
13,
13,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
18,
18,
13,
13,
13,
0,
13,
17,
0,
13,
17,
0,
18,
13,
13,
17,
42,
2,
40,
13,
2,
13,
17,
40,
13,
2,
13,
17,
14,
2,
2,
18,
13,
13,
18,
13,
2,
13,
17,
17,
4,
13,
17,
4,
13,
14,
2,
18,
13,
13,
17,
0,
13,
17,
0,
13,
17,
0,
18,
13,
13,
17,
14,
4,
18,
13,
13,
2,
13,
17,
4,
13,
17,
4,
13,
17,
10,
17,
13,
10,
4,
13,
10,
4,
13,
10,
13,
13,
10,
17,
13,
10,
17,
13,
10,
4,
13,
10,
17,
13
] |
[
[
151,
4
],
[
151,
13
],
[
17,
16
],
[
152,
19
],
[
142,
24
],
[
139,
27
],
[
152,
34
],
[
137,
37
],
[
41,
40
],
[
44,
43
],
[
152,
46
],
[
49,
48
],
[
137,
51
],
[
56,
53
],
[
140,
54
],
[
43,
55
],
[
143,
58
],
[
43,
59
],
[
48,
60
],
[
145,
62
],
[
145,
65
],
[
71,
68
],
[
140,
69
],
[
146,
70
],
[
134,
75
],
[
149,
75
],
[
137,
77
],
[
146,
80
],
[
155,
80
],
[
152,
82
],
[
68,
87
],
[
114,
87
],
[
140,
88
],
[
146,
89
],
[
155,
89
],
[
140,
91
],
[
146,
93
],
[
155,
93
],
[
68,
103
],
[
114,
103
],
[
140,
104
],
[
146,
105
],
[
155,
105
],
[
148,
108
],
[
154,
111
],
[
117,
114
],
[
140,
115
],
[
155,
116
],
[
146,
116
],
[
140,
124
],
[
145,
134
],
[
151,
137
],
[
139,
140
],
[
142,
143
],
[
145,
146
],
[
148,
149
],
[
151,
152
],
[
154,
155
]
] |
[
"import numpy as np\nh, w = map(int, input().split())\nA = [input() for _ in range(h)]\nB = np.empty((h+1, w+1), dtype=str)\nfor i in range(h):\n for j in range(w):\n B[i, j] = A[i][j]\n\nx = y = 0\nB[y, x] = '.'\nwhile x != w-1 or y != h-1:\n if B[y, x+1] == B[y+1, x] == '#':\n print('Impossible')\n exit()\n elif B[y, x+1] == '#':\n x += 1\n else:\n y += 1\n B[y, x] = '.'\n\nif np.any(B == '#'):\n print('Impossible')\nelse:\n print('Possible')",
"import numpy as np",
"numpy",
"h, w = map(int, input().split())",
"h",
"map(int, input().split())",
"map",
"int",
"input().split()",
"().split",
"()",
"input",
"split",
"w",
"input() for _ in range(h)",
"for _ in range(h)",
"_",
"range(h)",
"range",
"h",
"for _ in range(h)",
"input()",
"input",
"A = [input() for _ in range(h)]",
"A",
"[input() for _ in range(h)]",
"B = np.empty((h+1, w+1), dtype=str)",
"B",
"np.empty((h+1, w+1), dtype=str)",
"np.empty",
"np",
"empty",
"(h+1, w+1)",
"h+1",
"h",
"1",
"w+1",
"w",
"1",
"dtype=str",
"dtype",
"str",
"for i in range(h):\n for j in range(w):\n B[i, j] = A[i][j]",
"i",
"range(h)",
"range",
"h",
"for j in range(w):\n B[i, j] = A[i][j]",
"j",
"range(w)",
"range",
"w",
"B[i, j] = A[i][j]",
"B[i, j]",
"B",
"i",
"A[i][j]",
"[i]",
"A",
"i",
"j",
"x = y = 0",
"x",
"0",
"= y = 0",
"y",
"0",
"B[y, x] = '.'",
"B[y, x]",
"B",
"y",
"'.'",
"while x != w-1 or y != h-1:\n if B[y, x+1] == B[y+1, x] == '#':\n print('Impossible')\n exit()\n elif B[y, x+1] == '#':\n x += 1\n else:\n y += 1\n B[y, x] = '.'",
"x != w-1 or y != h-1",
"x != w-1",
"x",
"w-1",
"w",
"1",
"y != h-1",
"y",
"h-1",
"h",
"1",
"if B[y, x+1] == B[y+1, x] == '#':\n print('Impossible')\n exit()\n elif B[y, x+1] == '#':\n x += 1\n else:\n y += 1\n ",
"B[y, x+1] == B[y+1, x] == '#'",
"B[y, x+1] == B[y+1, x]",
"B[y, x+1]",
"B",
"y",
"B[y+1, x]",
"B",
"y+1",
"y",
"1",
"'#'",
"print('Impossible')",
"print",
"'Impossible'",
"exit()",
"exit",
"elif B[y, x+1] == '#':\n x += 1\n ",
"B[y, x+1] == '#'",
"B[y, x+1]",
"B",
"y",
"'#'",
"x += 1",
"x",
"1",
"y += 1",
"y",
"1",
"B[y, x] = '.'",
"B[y, x]",
"B",
"y",
"'.'",
"if np.any(B == '#'):\n print('Impossible')\nelse:\n print('Possible')",
"np.any(B == '#')",
"np.any",
"np",
"any",
"B == '#'",
"B",
"'#'",
"print('Impossible')",
"print",
"'Impossible'",
"print('Possible')",
"print",
"'Possible'",
"x = y = 0",
"0",
"x",
"w = map(int, input().split())",
"map(int, input().split())",
"w",
"B = np.empty((h+1, w+1), dtype=str)",
"np.empty((h+1, w+1), dtype=str)",
"B",
"A = [input() for _ in range(h)]",
"[input() for _ in range(h)]",
"A",
"y = 0",
"0",
"y",
"x += 1",
"1",
"x",
"h, w = map(int, input().split())",
"map(int, input().split())",
"h",
"y += 1",
"1",
"y"
] |
import numpy as np
h, w = map(int, input().split())
A = [input() for _ in range(h)]
B = np.empty((h+1, w+1), dtype=str)
for i in range(h):
for j in range(w):
B[i, j] = A[i][j]
x = y = 0
B[y, x] = '.'
while x != w-1 or y != h-1:
if B[y, x+1] == B[y+1, x] == '#':
print('Impossible')
exit()
elif B[y, x+1] == '#':
x += 1
else:
y += 1
B[y, x] = '.'
if np.any(B == '#'):
print('Impossible')
else:
print('Possible')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.