s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time int64 0 100 | memory stringlengths 4 6 | code_size int64 15 14.7k | code stringlengths 15 14.7k | problem_id stringlengths 6 6 | problem_description stringlengths 358 9.83k | input stringlengths 2 4.87k | output stringclasses 807
values | __index_level_0__ int64 1.1k 1.22M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s470166112 | p00741 | u980837785 | 1588162977 | Python | Python3 | py | Accepted | 70 | 8372 | 691 | import sys
sys.setrecursionlimit(10000)
def bfs(x, y, graph):
dxy = [(1, 1), (1, 0), (1, -1), (0, 1), (0, -1), (-1, 1), (-1, 0), (-1, -1)]
for dx, dy in dxy:
nextx = x + dx
nexty = y + dy
if (graph[nextx][nexty] == 1):
graph[nextx][nexty] = 0
bfs(nextx, nexty, graph)
while(1):
W, H = map... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,696 |
s938523635 | p00741 | u475213171 | 1587896026 | Python | Python3 | py | Accepted | 80 | 7940 | 711 | import sys
sys.setrecursionlimit(10000000)
while True:
W, H = map(int, input().split())
if W == 0 and H == 0:
break
G = [list(map(int, input().split())) for i in range(H)]
dh = (0, -1, -1, -1, 0, 1, 1, 1)
dw = (-1, -1, 0, 1, 1, 1, 0, -1)
def dfs(h, w):
for i in range(8):
... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,697 |
s491336919 | p00741 | u610816226 | 1587719514 | Python | Python3 | py | Accepted | 90 | 8104 | 913 | import sys
sys.setrecursionlimit(2500)
def dfs(v):
y, x = v
checked[y][x] = 1
ret = 1
for dy, dx in directions:
if y+dy>=h or y+dy<0 or x+dx>=w or x+dx<0:
continue
elif Map[y+dy][x+dx]==0:
continue
if not checked[y+dy][x+dx]:
ret += dfs((y+dy... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,698 |
s271394572 | p00741 | u921537862 | 1587709783 | Python | Python3 | py | Accepted | 90 | 5628 | 1,117 | dy = (-1,-1,0,1,1,1,0,-1)
dx = (0,1,1,1,0,-1,-1,-1)
def main():
while True:
w,h = map(int,input().split())
if h == 0:
return
grid = [list(map(int,input().split())) for _ in range(h)]
visited = [[0] * w for _ in range(h)]
ans = 0
for i in range(h):
... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,699 |
s677914289 | p00741 | u647694976 | 1587348970 | Python | Python3 | py | Accepted | 100 | 9764 | 668 | import sys
sys.setrecursionlimit(10**7)
def DFS(x,y):
color[x][y]="gray"
for i,j in [[-1,1],[-1,0],[-1,-1],[0,1],[0,-1],[1,-1],[1,0],[1,1]]:
X,Y=x+i,y+j
if 0<=X<h and 0<=Y<w:
if C[X][Y]==1 and color[X][Y]=="white":
DFS(x+i,y+j)
color[x][y]="black"
while 1:
... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,700 |
s746958506 | p00741 | u690713461 | 1587270398 | Python | Python3 | py | Accepted | 100 | 8468 | 961 | import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,701 |
s568320779 | p00741 | u804526325 | 1587111832 | Python | Python3 | py | Accepted | 100 | 8056 | 765 | import sys
sys.setrecursionlimit(10 ** 9)
while True:
w, h = map(int, input().split())
if w == 0 and h == 0:
break
c = [list(map(int, input().split())) for _ in range(h)]
seen = [[False for _ in range(w)] for _ in range(h)]
def dfs(x, y, seen):
if not (0 <= x < h and 0 <= y < w):
... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,702 |
s351388410 | p00741 | u776243834 | 1587111457 | Python | Python3 | py | Accepted | 100 | 8112 | 604 | import sys
sys.setrecursionlimit(10**6)
def dfs(pos):
i = pos[0]
j = pos[1]
seen[j][i] = True
for k in range(-1+i,2+i):
for l in range(-1+j,2+j):
if 0 <= k < w and 0 <= l < h:
if field[l][k] == 1 and (not seen[l][k]):
dfs([k,l])
while True:
w, h = map(int,input().split())
if w ... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,703 |
s882706240 | p00741 | u909811933 | 1587110150 | Python | Python3 | py | Accepted | 100 | 7996 | 620 | import sys
sys.setrecursionlimit(10000)
def dfs(x,y):
for i in range(-1,2):
if 0<=x+i<a[1]:
for j in range(-1,2):
if 0<=y+j<a[0]:
if G[x+i][y+j]==1:
G[x+i][y+j] = 0
dfs(x+i,y+j)
while True:
a = list(map(int,... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,704 |
s769710811 | p00741 | u332878765 | 1587020692 | Python | Python3 | py | Accepted | 100 | 7888 | 933 | import sys
sys.setrecursionlimit(10 ** 9)
def search_island(h, w, max_h, max_w):
for i in range(8):
next_h = h + [1, 1, 0, -1, -1, -1, 0, 1][i]
next_w = w + [0, 1, 1, 1, 0, -1, -1, -1][i]
if not 0 <= next_h < max_h or not 0 <= next_w < max_w:
continue
elif step[next_h][n... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,705 |
s687835194 | p00741 | u206124123 | 1586943196 | Python | Python3 | py | Accepted | 80 | 8476 | 2,018 | import sys
sys.setrecursionlimit(10000)
def get_two_int():
two_int = input().split()
for i in range(2):
two_int[i] = int(two_int[i])
return two_int
def get_data_list():
data_list = input().split()
for i, v in enumerate(data_list):
data_list[i] = int(v)
# print("data_list", data... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,706 |
s391899502 | p00741 | u531262486 | 1586921317 | Python | Python3 | py | Accepted | 90 | 8012 | 713 | import sys
sys.setrecursionlimit(10**6)
w=0;h=0;
def dfs(x,y,Map):
#ending condition
if not (0 <= x and x < h and 0 <= y and y < w):
return
if Map[x][y] == 0:
return
#operation
Map[x][y] = 0
#moving deep
for i in [-1,0,1]:
for j in [-1,0,1]:
dfs(x+i... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,707 |
s489549650 | p00741 | u672903396 | 1586804331 | Python | Python3 | py | Accepted | 100 | 8004 | 745 | import sys
sys.setrecursionlimit(10**8)
ans = []
def dfs(x, y):
c[x][y] = 0
for dx in range(-1, 2):
for dy in range(-1, 2):
nx = x + dx
ny = y + dy
if 0 <= nx < h and 0 <= ny < w and c[nx][ny] == 1:
dfs(nx, ny)
while True:
w, h = map(int, inpu... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,708 |
s437478572 | p00741 | u486404145 | 1586689393 | Python | Python3 | py | Accepted | 90 | 6328 | 1,362 | # -*- coding: utf-8 -*-
import sys
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()
def main():
while True:
W,H=map(int,input().split())
if W==H==0:
exit()
C=[[] for _ in range(H+2)]
C[0]=C[H+1]=[-1]*(W+2)
used=[[False]*(W+2) for _ in ran... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,709 |
s270887939 | p00741 | u609549099 | 1586655084 | Python | Python3 | py | Accepted | 90 | 6040 | 984 | import collections
while True:
w, h = map(int, input().split())
if not w and not h:
break
graph = [list(map(int, input().split())) for _ in range(h)]
seen = [[False] * w for i in range(h)]
dy = [0, 1, 0, -1, 1, 1, -1, -1]
dx = [1, 0, -1, 0, 1, -1, 1, -1]
def dfs(v):
stack ... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,710 |
s507214361 | p00741 | u486854614 | 1586580493 | Python | Python3 | py | Accepted | 100 | 8108 | 681 | import sys
sys.setrecursionlimit(10**6)
def is_in_map(x, y, w, h):
return 0 <= x < w and 0 <= y < h
def dfs(x, y, lct):
lct[y][x] = 0
w = len(lct[0])
h = len(lct)
for i in range(-1, 2):
for j in range(-1, 2):
nx = x + i
ny = y + j
if not is_in_map(nx, ny, w, h):
continue
if lct[ny][nx] == 0... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,711 |
s409686454 | p00741 | u746548470 | 1586341500 | Python | Python3 | py | Accepted | 80 | 7960 | 711 | import sys
sys.setrecursionlimit(10 ** 7)
direction = ((1, 0), (-1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (-1, 1), (1, -1))
def dfs(y, x):
board[y][x] = 0
for d in direction:
nh = y + d[1]
nw = x + d[0]
if nh < 0 or nh >= h or nw < 0 or nw >= w:
continue
if boar... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,712 |
s951149064 | p00741 | u115626571 | 1586293862 | Python | Python3 | py | Accepted | 90 | 7972 | 854 | import sys
sys.setrecursionlimit(10**7)
dx = [1,0,-1,0,1,-1,1,-1]
dy = [0,1,0,-1,1,1,-1,-1]
def dfs(C,h,w):
global seen
seen[h][w] = True
for dir in range(8):
nh = h + dx[dir]
nw = w + dy[dir]
if nh < 0 or nh >= H or nw < 0 or nw >= W:
continue
if C[nh][nw] == ... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,713 |
s830553661 | p00741 | u862284621 | 1586073902 | Python | Python3 | py | Accepted | 90 | 8624 | 862 | import sys
sys.setrecursionlimit(10000)
def main():
while 1:
W, H = map(int, input().split())
if W == 0 and H == 0:
break
C = [list(map(int, input().split())) for _ in range(H)]
def dfs(h, w):
C[h][w] = 0
for dh in range(-1, 2):
... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,714 |
s488552436 | p00741 | u344362704 | 1586064147 | Python | Python3 | py | Accepted | 80 | 7980 | 1,135 | import sys
sys.setrecursionlimit(1000000)
while(1):
w, h = map(int, input().split())
if w == 0 and h == 0:
break
else:
maps = [[-1]*(w+2)] + [([-1] + list(map(int, input().split())) + [-1]) for _ in range(h)] + [[-1]*(w+2)]
seen = [[True]*(w+2)] + [([True] + [False]*w + [True]) for ... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,715 |
s985926179 | p00741 | u471247869 | 1585986462 | Python | Python3 | py | Accepted | 80 | 7912 | 893 | import sys
sys.setrecursionlimit(100000)
while True:
w, h = map(int, input().split())
if w == 0:
break
field = [list(map(int, input().split())) for _ in range(h)]
searched = [[False for _ in range(w)] for __ in range(h)]
islands = 0
def search(x, y):
if not (0 <= x < w... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,716 |
s623153074 | p00741 | u560613143 | 1585921989 | Python | Python3 | py | Accepted | 90 | 6012 | 855 | from collections import deque
def dfs(i,j,seen):
q=deque()
q.append((i,j,0))
seen[i][j]=0
dx=[0,1,0,-1,-1,-1,1,1]
dy=[1,0,-1,0,1,-1,1,-1]
while q:
X,Y,S=q.pop()
if S==0:
#下に遷移していくときの処理
#q.append((V,P,1))
for k in range(8):
nx=X+... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,717 |
s777111034 | p00741 | u931913851 | 1585889466 | Python | Python3 | py | Accepted | 80 | 7944 | 740 | import sys
sys.setrecursionlimit(4100000)
def dfs(cy, cx):
# 一回走らせたら一つの島が消滅すると考える
if not (cy < 0 or cy >= H or cx < 0 or cx >= W or gridgraph[cy][cx] == "0"):
gridgraph[cy][cx] = "0"
for dy, dx in adjacent:
ny, nx = cy+dy, cx+dx
dfs(ny, nx)
adjacent = [[-1, -1], [-1, ... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,718 |
s616678396 | p00741 | u258049727 | 1585817318 | Python | Python3 | py | Accepted | 90 | 8632 | 747 | import sys
sys.setrecursionlimit(10**9)
ans = []
dx = (1,1,1,0,0,-1,-1,-1)
dy = (1,0,-1,1,-1,1,0,-1)
def dfs(x,y):
st[x][y] = True
for i,j in zip(dx,dy):
nx = x + i
ny = y + j
if nx < 0 or h <= nx: continue
if ny < 0 or w <= ny: continue
if st[nx][ny]: continue
i... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,719 |
s828950785 | p00741 | u215870135 | 1585637411 | Python | Python3 | py | Accepted | 80 | 9896 | 879 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000000)
def main():
while True:
W, H = map(int, input().split())
if W == 0:
break
board = [list(map(int, input().split())) for i in range(H)]
check = [[False] * W for i in range(H)]
def dfs(x, y):
... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,720 |
s075783103 | p00741 | u951319620 | 1585403981 | Python | Python3 | py | Accepted | 100 | 11268 | 884 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
a = [(x, ... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,721 |
s204689298 | p00741 | u740184621 | 1585290410 | Python | Python3 | py | Accepted | 80 | 8092 | 878 | import sys
sys.setrecursionlimit(10 ** 7)
def dfs(h, w, grid):
grid[h][w] = 0
# 八方向を探索
for dh in range(-1, 2):
for dw in range(-1, 2):
nh = dh + h
nw = dw + w
# 場外だった場合はするー(番兵)
if nh < 0 or nw < 0:
continue
if grid[nh][nw]... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,722 |
s854963488 | p00741 | u942920884 | 1585269952 | Python | Python3 | py | Accepted | 80 | 8684 | 967 | import sys
sys.setrecursionlimit(1000000)
def dfs(map, reached, pos):
global dx, dy
x, y = pos
if reached[x][y] == 1 or map[x][y] == '0':
return 0
reached[x][y] = 1
for dxi, dyi in zip(dx, dy):
if not reached[x + dxi][y + dyi]:
dfs(map, reached, (x + dxi, y + dyi))
... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,723 |
s687827853 | p00741 | u009853378 | 1584871908 | Python | Python3 | py | Accepted | 90 | 7644 | 1,376 | ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
import sys
sys.setrecursionlimit(4000)
class iland:
def __init__(self,w,h):
self.w = w
self.h = h
self.c = [[0]*(w+2) for i in range(h+2)]
c_tmp = [list(int(i) for i in ... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,724 |
s940700200 | p00741 | u802742860 | 1584362689 | Python | Python3 | py | Accepted | 100 | 11116 | 1,002 | import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect
MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(10 ** 8)
def search(i, j):... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,725 |
s950112677 | p00741 | u260266858 | 1584337091 | Python | Python3 | py | Accepted | 100 | 7984 | 752 | import sys
sys.setrecursionlimit(10000)
dx = [1, -1, 0, 0, 1, 1, -1, -1]
dy = [0, 0, 1, -1, 1, -1, 1, -1]
def dfs(y, x):
if x < 0 or w <= x:
return
if y < 0 or h <= y:
return
if V[y][x]:
return
if C[y][x] == 0:
return
V[y][x] = True
for i in range(8):
d... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,726 |
s398010552 | p00741 | u093588014 | 1584195040 | Python | Python3 | py | Accepted | 80 | 8096 | 777 | import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)
def dfs(a,v):
global st,per
if v in st: st.remove(v)
else: return
for tom in per:
if a[v[0]+tom[0]][v[1]+tom[1]]==1: dfs(a,(v[0]+tom[0],v[1]+tom[1]))
while True:
c,r=map(int,input().split())
if c==0 and... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,727 |
s363085716 | p00741 | u284842807 | 1584112748 | Python | Python3 | py | Accepted | 100 | 7992 | 579 | import sys
sys.setrecursionlimit(100000)
def dfs(i, j):
g[i][j] = 0
for x in range(-1, 2):
for y in range(-1, 2):
dx = x + i
dy = y + j
if 0<=dx<h and 0<=dy<w and g[dx][dy] == 1:
dfs(dx, dy)
return
while True:
w, h = map(int, input().split(... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,728 |
s313986176 | p00741 | u076951214 | 1584068199 | Python | Python3 | py | Accepted | 90 | 7944 | 872 | # =============================================================================
# How many Islands?
# =============================================================================
import sys
sys.setrecursionlimit(10**8)
while True:
W,H=map(int,input().split())
if W==0 and H==0:
break
field=[list(map... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,729 |
s063536667 | p00741 | u853158149 | 1584043076 | Python | Python3 | py | Accepted | 80 | 6076 | 1,483 | #!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdi... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,730 |
s331442307 | p00741 | u350045793 | 1582641165 | Python | Python3 | py | Accepted | 100 | 8104 | 714 | import sys
sys.setrecursionlimit(100000)
def dfs(h, w):
global fields
if not (0 <= h < len(fields) and 0 <= w < len(fields[0])):
return
if fields[h][w] == "0":
return
fields[h][w] = "0"
for dh in [-1, 0, 1]:
for dw in [-1, 0, 1]:
if dh == 0 and dw == 0:
... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,731 |
s476058202 | p00741 | u037175009 | 1582639003 | Python | Python3 | py | Accepted | 90 | 7968 | 788 | import sys
sys.setrecursionlimit(5000)
input = sys.stdin.readline
sea_map = []
chk_map = []
h = 0
w = 0
def chk_island(i,j):
chk_map[i][j] = False
if sea_map[i][j] == 0:
return 0
for d in ((-1,0), (-1,1), (0,1), (1,1), (1,0), (1,-1), (0,-1), (-1,-1)):
if 0 <= i + d[0] < h and 0 <= j + d[1] ... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,732 |
s412272260 | p00741 | u439998102 | 1582476788 | Python | Python3 | py | Accepted | 90 | 8080 | 771 | def dfs(c, x, y, w, h):
c[y][x] = -1
for i in range(-1, 2):
for j in range(-1, 2):
if i == 0 and j == 0:
continue
x_ = x + i
y_ = y + j
if 0 <= x_ < w and 0 <= y_ < h and c[y_][x_] == 1:
dfs(c, x_, y_, w, h)
def solve(w, h... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,733 |
s375604348 | p00741 | u798803522 | 1580093317 | Python | Python3 | py | Accepted | 80 | 7920 | 827 | import sys
sys.setrecursionlimit(10 ** 6)
def dfs(here_w, here_h):
if 0 <= here_w < width and 0 <= here_h < height:
if target[here_h][here_w]:
target[here_h][here_w] = 0
for x, y in all_move:
dfs(here_w + x, here_h + y)
all_move = [[1, 1], [1, 0], [1... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,734 |
s474631656 | p00741 | u511037423 | 1578224563 | Python | Python3 | py | Accepted | 100 | 8308 | 603 | import sys
from collections import deque
sys.setrecursionlimit(10**9)
dx = [1,1,0,-1,-1,-1,0,1]
dy = [0,-1,-1,-1,0,1,1,1]
def DFS(y,x):
if table[y][x] == 0:
return
table[y][x] = 0
for i in range(8):
nx = x + dx[i]
ny = y + dy[i]
if 0<=ny<h and 0<=nx<w:
DFS(ny, nx)
while True:
w, h = ... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,735 |
s292954148 | p00741 | u072053884 | 1575900948 | Python | Python3 | py | Accepted | 40 | 8544 | 822 | def solve():
from sys import stdin, setrecursionlimit
setrecursionlimit(4000)
f_i = stdin
def dfs(pos):
area_map[pos] = '0'
for mv in move:
next_pos = pos + mv
if area_map[next_pos] == '1':
dfs(next_pos)
while True:
w, h = map... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,736 |
s153502673 | p00741 | u003984259 | 1574155780 | Python | Python3 | py | Accepted | 100 | 6044 | 910 | from collections import deque
while True:
w,h=map(int,input().split())
if (w,h)==(0,0):
break
p=[]
p.append([False for j in range(w+2)])
for i in range(1,h+1):
p.append([False]+[cij==1 for cij in list(map(int,input().split()))]+[False])
p.append([False for j in range(w+2)])
... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,737 |
s635669470 | p00741 | u073204138 | 1574072126 | Python | Python3 | py | Accepted | 90 | 8020 | 483 | import sys
sys.setrecursionlimit(10000)
def check_island(h,w):
#print(h,w)
for i in [-1,0,1]:
for j in [-1,0,1]:
if (H>(h+i)>=0) and (W>(w+j)>=0) and (c[h+i][w+j]==1):
c[h+i][w+j] = 0
check_island(h+i, w+j)
while(True):
W, H = map(int,input().split())
if W==0 and H == 0 : break
c = [list(int(i) fo... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,738 |
s576895655 | p00741 | u821080069 | 1573561517 | Python | Python3 | py | Accepted | 90 | 7956 | 550 | import sys
sys.setrecursionlimit(1000000)
moves = ((1, 0), (-1, 0), (0, 1), (0, -1), (1, 1), (1, -1), (-1, 1), (-1, -1))
def dfs(y, x):
c[y][x] = 0
for dy, dx in moves:
ny = y + dy
nx = x + dx
if 0 <= ny < h and 0 <= nx < w and c[ny][nx] == 1:
dfs(ny, nx)
while True:
w, h = map(int, input().... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,739 |
s364879548 | p00741 | u943014460 | 1571886859 | Python | Python3 | py | Accepted | 100 | 8324 | 1,108 | import sys
sys.setrecursionlimit(10 ** 6)
islands = []
visited_list = []
w_list = []
h_list = []
while True:
w ,h = map(int,input().split())
if w == 0 and h == 0:
break
w_list.append(w)
h_list.append(h)
island = [list(input().split()) for _ in range(h)]
islands.append(island)
visited... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,740 |
s083375300 | p00741 | u668650835 | 1571470442 | Python | Python3 | py | Accepted | 100 | 6568 | 1,217 | while(1):
w,h = map(int,input().split())
if((w == 0)and(h == 0)): break
Map = []
Map.append(['@']*(w+2))
land = []
for i in range(h):
c = list('@'+input().replace(' ', '')+'@')
Map.append(c)
for j in range(w+2):
if(c[j] == '1'): land.append([i+1,j])
Map.append(['@']*(w+2))
#print(land)
#深さ優先探索
def ... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,741 |
s225031269 | p00741 | u902441873 | 1570847146 | Python | Python3 | py | Accepted | 70 | 7620 | 963 | import sys
sys.setrecursionlimit(10**7)
def dfs(i, j):
if(c[i][j] != "1"):
return 1
else:
c[i][j] = "2"
if(0 < i): dfs(i - 1, j)
if(0 < j): dfs(i, j - 1)
if(i < h - 1): dfs(i + 1, j)
if(j < w - 1): ... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,742 |
s275788501 | p00741 | u537758214 | 1569628603 | Python | Python3 | py | Accepted | 100 | 5744 | 1,273 | def main():
W, H = (int(i) for i in input().split())
while H != 0 or W != 0:
c = [[int(i) for i in input().split()] for j in range(H)]
seen = [[False for i in range(W)] for j in range(H)]
def dfs(G,h,w,seen,H,W):
todo = []
hws = ((1,0),(0,1),(-1,0),(0,-1),(1,1),(1... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,743 |
s669095379 | p00741 | u319938194 | 1569551820 | Python | Python3 | py | Accepted | 100 | 7992 | 671 | import sys
sys.setrecursionlimit(10**8)
def dfs_fill(m, x, y):
if not (0 <= x < W and 0 <= y < H) or m[y][x] == "0":
return False
m[y][x] = "0"
for dx in range(-1, 2):
for dy in range(-1, 2):
if dx == dy == 0:
continue
dfs_fill(m, x+dx, y+dy)
while T... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,744 |
s770934314 | p00741 | u982187482 | 1568290204 | Python | Python3 | py | Accepted | 80 | 7884 | 749 | import sys
sys.setrecursionlimit(1000000)
def rec(y, x, f):
f[y][x] = '0'
for dy, dx in [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0),
(1, 1)]:
if 0 <= y+dy < len(f) and 0 <= x+dx < len(f[0]) and f[y+dy][x+dx] == '1':
rec(y+dy, x+dx, f)
def main():
while ... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,745 |
s320977499 | p00741 | u132112086 | 1567596773 | Python | Python3 | py | Accepted | 100 | 5772 | 821 | while True:
w,h=map(int,input().split())
if h==0 and w==0:
break
c=[list(map(int,input().split())) for _ in [0]*h]
visit=[[c[i][j]==0 for j in range(w)] for i in range(h)]
d=[(1,0),(-1,0),(0,1),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)]
cnt=0
for i in range(h):
for j in ran... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,746 |
s503496148 | p00741 | u317942270 | 1563794095 | Python | Python3 | py | Accepted | 80 | 7988 | 755 | import sys
sys.setrecursionlimit(10**5)
around = [(0,1),(1,0),(0,-1),(-1,0),(1,1),(1,-1),(-1,1),(-1,-1)]
def dfs(i,j):
visited[i][j] = True
for di, dj in around:
ni = i + di
nj = j + dj
if not (0 <= ni < H and 0 <= nj < W):
continue
if C[ni][nj] and not visited[ni][... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,747 |
s118595042 | p00741 | u204344516 | 1562263570 | Python | Python3 | py | Accepted | 100 | 9212 | 827 | import os
import itertools
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
def solve(H, W):
C = [list(map(int, sys.stdin.readline().split())) for _ in range(H)]
def ok(h, w):
return 0 <= h... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,748 |
s235489120 | p00741 | u464321546 | 1562044223 | Python | Python3 | py | Accepted | 70 | 6012 | 841 | move = [[0, 1], [0, -1], [-1, 0], [1, 0], [1, 1], [1, -1], [-1, -1], [-1, 1]]
from collections import deque
def main(w, h):
c = [list(map(int, input().split())) for i in range(h)]
ans = 0
for y in range(h):
for x in range(w):
if c[y][x]:
ans += 1
q = deque... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,749 |
s624520698 | p00741 | u743973970 | 1561534481 | Python | Python3 | py | Accepted | 70 | 8004 | 616 | import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
def dfs(x,y):
c[x][y]='0'
for dx in range(-1,2):
for dy in range(-1,2):
nx=dx+x
ny=dy+y
if c[nx][ny]=='1':dfs(nx,ny)
while 1:
c=[]
w,h=map(int,input().split())
if w==h==0:exit()
w+=2
... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,750 |
s073535614 | p00741 | u595029599 | 1561086000 | Python | Python3 | py | Accepted | 80 | 8620 | 572 | from itertools import product
import sys
sys.setrecursionlimit(1000000)
def s(m, x, y):
m[y][x] = 0
for dx, dy in product(range(-1, 2), range(-1, 2)):
if m[y + dy][x + dx]:
s(m, x + dx, y + dy)
while True:
c = 0
w, h = map(int, input().split())
if w == h == 0:
break
... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,751 |
s685559407 | p00741 | u788553535 | 1560336599 | Python | Python3 | py | Accepted | 90 | 8012 | 560 | import sys
sys.setrecursionlimit(10000)
def f(x,y):
global w,h,c
if x<0 or x>=h or y<0 or y>=w or c[x][y]==0:
return
c[x][y]=0
for a in [-1,0,1]:
for b in [-1,0,1]:
if a==0 and b==0:
continue
f(x+a,y+b)
while True:
w,h = map(int,input().split()... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,752 |
s181062073 | p00741 | u200148444 | 1560165663 | Python | Python3 | py | Accepted | 100 | 8004 | 832 | import sys
sys.setrecursionlimit(10000)
def bom(i,j):
for s in range(-1,2):
for d in range(-1,2):
if i+s==-1 or i+s==h or j+d==-1 or j+d==w:
continue
if l[i+s][j+d]==1:
l[i+s][j+d]=0
bom_2(i+s,j+d)
return 1
return 0
... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,753 |
s615218953 | p00741 | u197615397 | 1558018728 | Python | Python3 | py | Accepted | 50 | 6032 | 770 | def solve():
from collections import deque
while True:
w, h = map(lambda x: int(x)+2, input().split())
if w == 2:
break
result = 0
a = ['0']*w
for _ in [0]*(h-2):
a += ['0'] + input().split() + ['0']
a += ['0']*w
for i in ran... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,754 |
s628500704 | p00741 | u473668220 | 1554743095 | Python | Python3 | py | Accepted | 100 | 8020 | 763 | # -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10000)
while(True):
w,h = map(int,input().split())
if w == 0 and h == 0:
break
c = [0] * h
for i in range(h):
c[i] = list(map(int,input().split()))
checked = [[0] * w for _ in range(h)]
def dfs(x,y):
global checke... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,755 |
s581319257 | p00741 | u089629535 | 1549527507 | Python | Python3 | py | Accepted | 100 | 5628 | 885 | #AOJ1160
def search(w,h,data):
for i in range(h):
if 1 in data[i]:
return (i,data[i].index(1))
return (-1,-1)
def main(w,h):
data=[list(map(int,input().split())) for j in range(h)]
start=search(w,h,data)
island=0
while start!=(-1,-1):
island+=1
checking=[star... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,756 |
s625929155 | p00741 | u550922601 | 1549101765 | Python | Python3 | py | Accepted | 90 | 9160 | 677 | import sys
sys.setrecursionlimit(10**6)
def lake_counting(field):
lake_count = 0
def dfs(x,y):
field[x][y] = 0
dx = [-1,-1,-1,0,0,1,1,1]
dy = [-1,0,1,-1,1,1,0,-1]
for i in range(8):
nx = x + dx[i]
ny = y + dy[i]
if (0 <= nx < h and 0 <= ny < w and field[nx][ny] ==... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,757 |
s885924518 | p00741 | u973203074 | 1548485067 | Python | Python3 | py | Accepted | 90 | 8004 | 811 | import sys
sys.setrecursionlimit(10 ** 4)
w = h = 0
islands = []
def dfs(ii: int, jj: int) -> None:
global islands
islands[jj][ii] = 0
for i in range(ii - 1, ii + 2):
for j in range(jj - 1, jj + 2):
if 0 <= i < w and 0 <= j < h and islands[j][i] > 0:
dfs(i, j)
def ... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,758 |
s109662706 | p00741 | u663560855 | 1539919204 | Python | Python3 | py | Accepted | 80 | 7976 | 613 | import sys
sys.setrecursionlimit(100000)
def islands ( x, y):
s[y][x] = '0'
for dx, dy in ((1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)):
xx,yy = x+dx , y+dy
if 0<=xx<w and 0<=yy<h and s[yy][xx]=='1':
islands(xx,yy)
while True:
w, h = map(int... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,759 |
s888073666 | p00741 | u473666214 | 1539276027 | Python | Python3 | py | Accepted | 60 | 7644 | 1,533 | import sys
sys.setrecursionlimit(10000)
def integrate(x, i, j):
if x[i-1][j-1] != 1 and x[i-1][j] != 1 and x[i-1][j+1] != 1 \
and x[i][j-1] != 1 and x[i][j+1] != 1 and x[i+1][j-1] != 1 \
and x[i+1][j] != 1 and x[i+1][j+1] != 1:
return 0
if x[i-1][j] == 1:
x[i-1][j] = 0
... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,760 |
s203891523 | p00741 | u273756488 | 1533580115 | Python | Python3 | py | Accepted | 100 | 9212 | 728 | from itertools import product
import sys
sys.setrecursionlimit(10 ** 6)
def solve(H, W, C):
def dfs(h, w):
if h < 0 or h >= H or w < 0 or w >= W:
return 0
elif C[h][w] == 0:
return 0
else:
C[h][w] = 0
for dh, dw in product((1, 0, -1), repeat ... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,761 |
s379533036 | p00741 | u281836941 | 1513271036 | Python | Python3 | py | Accepted | 80 | 7900 | 1,202 | # coding: utf-8
import sys
sys.setrecursionlimit(2147483647)
def check(p):
global field
if(field[p[1]][p[0]]=='1'):
field[p[1]][p[0]]='0'
if(0<=p[0]+1<w and field[p[1]][p[0]+1]=='1'):
check((p[0]+1,p[1]))
if(0<=p[0]-1<w and field[p[1]][p[0]-1]=='1'):
check((p[0]-1,p[1]))
if(0... | p00741 |
<h1><font color="#000000">Problem B:</font> How Many Islands?</h1>
<p>
You are given a marine area map that is a mesh of squares, each
representing either a land or sea area.
Figure B-1 is an example of a map.
</p>
<p>
<center>
<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_2009B2"><br>
Figure B-1... | 1 1
0
2 2
0 1
1 0
3 2
1 1 1
1 1 1
5 4
1 0 1 0 0
1 0 0 0 0
1 0 1 0 1
1 0 0 1 0
5 4
1 1 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 1 1
5 5
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
0 0
| 0
1
1
3
1
9
| 24,762 |
s565369422 | p00746 | u847467233 | 1531572353 | Python | Python3 | py | Accepted | 70 | 5612 | 477 | # AOJ 1165: Pablo Squarson's Headache
# Python3 2018.7.14 bal4u
rr, cc = [0]*202, [0]*202
while True:
n = int(input())
if n == 0: break
rr[0] = cc[0] = r1 = r2 = c1 = c2 = 200
for i in range(1, n):
m, d = map(int, input().split())
r, c = rr[m], cc[m]
if d == 0: c -= 1
elif d == 1: r += 1
elif d == 2: c... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,763 |
s327643396 | p00746 | u328199937 | 1555938989 | Python | Python3 | py | Accepted | 90 | 5628 | 1,064 | ans_list = []
while True:
N = int(input())
if N == 0:
break
square = [[0, 0]]
for i in range(N - 1):
n, d = map(int, input().split())
#print(n, d)
if d == 0:
square.append([square[n][0], square[n][1] - 1])
elif d == 2:
square.append([squa... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,764 |
s088653791 | p00746 | u617183767 | 1420389276 | Python | Python | py | Accepted | 40 | 4708 | 1,089 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import itertools
import math
from collections import Counter, defaultdict
class Main(object):
def __init__(self):
pass
def solve(self):
'''
insert your code
'''
while True:
n = input()... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,765 |
s243362043 | p00746 | u766477342 | 1420635090 | Python | Python3 | py | Accepted | 90 | 6736 | 504 | D = ((-1,0),(0,1),(1,0),(0,-1))
while 1:
N = int(input())
if not N:break
min_x = min_y = max_x = max_y = 0
a = [(0,0)]
for i in range(N-1):
n1, d1 = list(map(int, input().split()))
spam = (lambda x: (x[0] + D[d1][0], x[1] + D[d1][1]))(a[n1])
min_x = min(spam[0],min_x)
... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,766 |
s391324872 | p00746 | u316268279 | 1421241064 | Python | Python3 | py | Accepted | 80 | 6744 | 649 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
while True:
N = int(input())
if N == 0:
break
square = []
direct = [(-1,0),(0,-1),(1,0),(0,1)]
square.append((0,0))
topleft = (0,0)
bottomright = (0,0)
for i in range(N-1):
n,d = map(int,input().split(" "))
nextSquare... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,767 |
s290107199 | p00746 | u731235119 | 1421938369 | Python | Python | py | Accepted | 40 | 4228 | 261 | while 1:
N = int(raw_input())
if N == 0:
break
x = [0]
y = [0]
put = [(-1,0),(0,-1),(1,0),(0,1)]
for i in range(1, N):
n,d = map(int, raw_input().split(" "))
x.append(x[n]+put[d][0])
y.append(y[n]+put[d][1])
print max(x)-min(x)+1, max(y)-min(y)+1 | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,768 |
s664405145 | p00746 | u124909914 | 1426564290 | Python | Python3 | py | Accepted | 80 | 6724 | 567 | while True:
n = int(input())
if n == 0: break
squares = [(0,0)]
x_max, x_min, y_max, y_min = 0, 0, 0, 0
for i in range(1,n):
p, d = map(int, input().split())
x, y = squares[p]
if d == 0:
x -= 1
elif d == 1:
y -= 1
elif d == 2:
... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,769 |
s761452772 | p00746 | u966364923 | 1436660105 | Python | Python3 | py | Accepted | 70 | 6720 | 442 | def main():
D = ((-1,0), (0,-1), (1,0), (0,1))
while True:
n = int(input())
if n==0:
exit()
sx = [0]
sy = [0]
for i in range(n-1):
ni, di = [int(x) for x in input().split()]
sx.append(sx[ni]+D[di][0])
sy.append(sy[ni]+D[di]... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,770 |
s511770875 | p00746 | u998188826 | 1443329713 | Python | Python3 | py | Accepted | 70 | 7620 | 500 |
dirs = [(-1,0), (0,1), (1,0), (0,-1)]
while True:
n = int(input())
if n == 0:
break
x, y = 0, 0
nd = [[0, 0, 0, 0]]
for i in range(n-1):
n, d = map(int, input().split())
nd.append([n, d, 0, 0])
for i in range(1, len(nd)):
nd[i][2] = nd[nd[i][0]][2] + dirs[nd[i][1]][0]
nd[i][3] = nd[nd[i][0]][3] + dirs... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,771 |
s984463675 | p00746 | u859393176 | 1466503081 | Python | Python3 | py | Accepted | 70 | 7608 | 520 | while True:
n = int(input())
if n == 0: break
xs = [(0, 0)]
dic = [(-1, 0), (0, 1), (1, 0), (0, -1)]
maxX, minX, maxY, minY = 0, 0, 0, 0
for i in range(n - 1):
n, d = map(int, input().split())
xs.append((xs[n][0] + dic[d][0], xs[n][1] + dic[d][1]))
if xs[-1][0] > maxX: ma... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,772 |
s403715411 | p00746 | u616098312 | 1466507335 | Python | Python3 | py | Accepted | 70 | 7668 | 671 | while True:
N=int(input())
if N==0:break
t=[0]
y=[0]
lst=list(range(N))
for k in lst[1:]:
[x,d]=input().split()
[x,d]=[int(x),int(d)]
if d==0:
t=t+[t[x]]
y=y+[y[x]-1]
if d==1:
t=t+[t[x]-1]
y=y+[y[x]]
if d==2:... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,773 |
s864461546 | p00746 | u858885710 | 1466519110 | Python | Python3 | py | Accepted | 70 | 7652 | 904 |
adjacent_vector = [
(-1, 0), # left
(0, -1), # down
(1, 0), # right
(0, 1) # up
]
while True:
num_squares = int(input())
if num_squares == 0:
break
x_coordinates = [0] # x??§?¨?????????????
y_coordinates = [0] # y??§?¨?????????????
for _ in range(num_squares-1):
... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,774 |
s055784131 | p00746 | u858885710 | 1466522066 | Python | Python3 | py | Accepted | 80 | 7696 | 1,933 | '''
hardest 2.
Aizu Online Judge 1165: Pablo Squarson's Headache
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1165
## ?§£??¬
??£?????¢?????????????????£?????§???????????¢?????\????????????????????¢???????°????????????¨???????????????????????????????????§???
??£?????¢???????????¢???????????????????????????... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,775 |
s779225875 | p00746 | u660912567 | 1481291089 | Python | Python3 | py | Accepted | 70 | 7556 | 306 | d = [[-1,0],[0,1],[1,0],[0,-1]]
while True:
n = int(input())
if not(n): break
# l = [[1,1]]
w,h = [1],[1]
for i in range(n-1):
l = list(map(int,input().split()))
w.append(w[l[0]]+d[l[1]][0])
h.append(h[l[0]]+d[l[1]][1])
print(max(w)-min(w)+1,max(h)-min(h)+1) | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,776 |
s246168044 | p00746 | u166860661 | 1481592111 | Python | Python | py | Accepted | 50 | 6364 | 1,092 | # coding: utf-8
# Here your code !
#coding: utf-8
while True:
n = int(raw_input())
if n == 0:
break
coolist = [(0, 0)]
xmax = 0
xmin = 0
ymax = 0
ymin = 0
for i in range(n-1):
l = map(int, raw_input().split())
if l[1] == 0:
coo = (coolist[l[0]][0] - 1... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,777 |
s448095124 | p00746 | u660912567 | 1481911260 | Python | Python3 | py | Accepted | 70 | 7628 | 262 | d = [[-1,0],[0,1],[1,0],[0,-1]]
while True:
n = int(input())
if n==0: break
x,y = [0],[0]
for _ in range(n-1):
vn,vd = map(int,input().split())
x,y = x+[x[vn]+d[vd][0]],y+[y[vn]+d[vd][1]]
print(max(x)-min(x)+1,max(y)-min(y)+1) | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,778 |
s246186209 | p00746 | u923668099 | 1495620695 | Python | Python3 | py | Accepted | 50 | 7680 | 704 | import sys
def solve():
dx = (-1, 0, 1, 0,)
dy = (0, -1, 0, 1,)
while 1:
N = int(sys.stdin.readline().rstrip())
if N == 0:
return
pos = [None] * N
pos[0] = (0, 0)
top = 0
btm = 0
left = 0
right = 0
for i in range(N - 1... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,779 |
s954506214 | p00746 | u260980560 | 1497561828 | Python | Python | py | Accepted | 50 | 6252 | 359 | dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
while 1:
n = input()
if not n:
break
s = [(0, 0)]
for i in xrange(n-1):
p, d = map(int, raw_input().split())
x, y = s[p]
dx, dy = dd[d]
s.append((x + dx, y + dy))
xs = [e[0] for e in s]
ys = [e[1] for e in s]
pri... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,780 |
s957489830 | p00746 | u506554532 | 1513064406 | Python | Python3 | py | Accepted | 90 | 5620 | 475 | dir = [(-1,0),(0,1),(1,0),(0,-1)]
while True:
N = int(input())
if N == 0: break
sq = [(0,0)]
for i in range(1,N):
n,d = map(int,input().split())
dx,dy = dir[d]
sq.append((sq[n][0]+dx, sq[n][1]+dy))
maxx = maxy = minx = miny = 0
for x,y in sq:
maxx = max(maxx,x)
... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,781 |
s697702289 | p00746 | u741801763 | 1514435656 | Python | Python3 | py | Accepted | 80 | 5620 | 677 | while 1:
N = int(input())
if N ==0:break
max_h = 0
min_h = 0
max_w = 0
min_w = 0
data=[(0,0)]
for _ in range(N-1):
n,d = list(map(int,input().split()))
if d ==0:current = (data[n][0]-1,data[n][1])
if d ==1:current = (data[n][0],data[n][1]-1)
if d ==2:curre... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,782 |
s565274618 | p00746 | u306037418 | 1518243279 | Python | Python3 | py | Accepted | 80 | 5620 | 532 | while True:
N = int(input())
if N == 1:
print(1, 1)
elif N == 0:
quit()
else:
h, w = [0], [0]
for i in range(N-1):
n, d = map(int, input().split())
if d == 0:
x, y = -1, 0
elif d == 1:
x, y = 0, -1
... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,783 |
s203046130 | p00746 | u023471147 | 1527039942 | Python | Python3 | py | Accepted | 60 | 5620 | 351 | dx = (-1, 0, 1, 0)
dy = (0, 1, 0, -1)
while True:
n = int(input())
if n == 0:
break
x = list()
y = list()
x.append(0)
y.append(0)
for i in range(n - 1):
k, d = map(int, input().split())
x.append(x[k] + dx[d])
y.append(y[k] + dy[d])
print(max(x) - mi... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,784 |
s090055205 | p00746 | u509278866 | 1527845212 | Python | Python3 | py | Accepted | 90 | 9080 | 1,086 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF()... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,785 |
s900900158 | p00746 | u136916346 | 1530175703 | Python | Python3 | py | Accepted | 70 | 5616 | 415 | while 1:
n=int(input())
if not n:break
p=[(0,0)]
b=[0,0]
for _ in range(n-1):
idx,d=map(int,input().split())
b=list(p[idx])
if d==0:
b[0]-=1
elif d==1:
b[1]-=1
elif d==2:
b[0]+=1
elif d==3:
b[1]+=1
... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,786 |
s621123737 | p00746 | u109084363 | 1359689744 | Python | Python | py | Accepted | 40 | 4628 | 753 | import sys
import collections
while True:
N = int(sys.stdin.readline())
if N == 0:
break
pos = {0:(0, 0)}
for i in xrange(N - 1):
n, d = map(int, sys.stdin.readline().split())
if d == 0:
pos[i + 1] = (pos[n][0] - 1, pos[n][1])
elif d == 1:
... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,787 |
s755390518 | p00746 | u104911888 | 1372590801 | Python | Python | py | Accepted | 20 | 4260 | 251 | while True:
N=input()
if N==0:break
x,y=[0]*N,[0]*N
tx,ty=(-1,0,1,0),(0,-1,0,1)
for i in range(1,N):
n,d=map(int,raw_input().split())
x[i]=x[n]+tx[d]
y[i]=y[n]+ty[d]
print max(x)-min(x)+1,max(y)-min(y)+1 | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,788 |
s845373695 | p00746 | u633068244 | 1400160800 | Python | Python | py | Accepted | 30 | 4248 | 239 | dx,dy = [-1,0,1,0],[0,-1,0,1]
while 1:
N = input()
if N == 0: break
x,y = [0]*N,[0]*N
for i in range(1,N):
n,d = map(int,raw_input().split())
x[i] = x[n] + dx[d]
y[i] = y[n] + dy[d]
print max(x) - min(x) + 1, max(y) - min(y) + 1 | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,789 |
s396910288 | p00746 | u633068244 | 1400160988 | Python | Python | py | Accepted | 30 | 4244 | 226 | dx,dy = [-1,0,1,0],[0,-1,0,1]
while 1:
N = input()
if N == 0: break
x,y = [0]*N,[0]*N
for i in range(1,N):
n,d = map(int,raw_input().split())
x[i] = x[n]+dx[d]
y[i] = y[n]+dy[d]
print max(x)-min(x)+1,max(y)-min(y)+1 | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,790 |
s303424689 | p00746 | u240091169 | 1595216380 | Python | Python3 | py | Accepted | 80 | 5620 | 772 | def put_S(n, d) :
global square
if d == 0 :
new_i = square[n][0] - 1
new_j = square[n][1]
elif d == 1 :
new_i = square[n][0]
new_j = square[n][1] - 1
elif d == 2 :
new_i = square[n][0] + 1
new_j = square[n][1]
elif d == 3 :
new_i = square[n][0]... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,791 |
s241836739 | p00746 | u994684803 | 1594129099 | Python | Python3 | py | Accepted | 70 | 5616 | 305 | while True:
N = int(input())
w=[0]*N
h=[0]*N
wx=[-1,0,1,0]
hy=[0,-1,0,1]
if N == 0:
break
for i in range(1,N):
n,d = map(int,input().split())
w[i] = w[n]+wx[d]
h[i] = h[n]+hy[d]
print(max(w)-min(w)+1,max(h)-min(h)+1)
| p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,792 |
s358664142 | p00746 | u829695570 | 1578708656 | Python | Python3 | py | Accepted | 60 | 5612 | 517 | while 1:
n = int(input())
if n==0: break
if n==1: print(1, 1); continue
a = [0]
b = [0]
for i in range(n-1):
m, d = map(int,input().split())
if d == 0:
a.append(a[m]-1)
b.append(b[m])
elif d == 1:
a.append(a[m])
b.append(b[m... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,793 |
s185905859 | p00746 | u673194880 | 1567166769 | Python | Python3 | py | Accepted | 90 | 5632 | 1,498 | """
二次元のデータセットをリスト1つとして管理し
これを1つの正方形とする。
まず、指定されたindexのx,y座標リストを取得する
それぞれの方向によって、
"""
while(1):
blocks = []
blocks.append([0,0])
#print(blocks[0])
#print(blocks[0][1])
N = input()
N = int(N)
if N == 0:
break
list_y = []
list_x = []
l_count = N-1
num = 1
while(1):
if l_count == 0:
b... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,794 |
s827572510 | p00746 | u464321546 | 1562051339 | Python | Python3 | py | Accepted | 70 | 5624 | 575 | move = [[-1, 0], [0, 1], [1, 0], [0, -1]]
def main(n):
field = [(0, 0)]
for _ in range(n - 1):
ni, di = map(int, input().split())
field.append((field[ni][0] + move[di][0], field[ni][1] + move[di][1]))
minx = field[0][0]
maxx = field[0][0]
miny = field[0][1]
maxy = field[0][1]
... | p00746 |
<h1><font color="#000000">Problem A:</font> Pablo Squarson's Headache</h1>
<!-- begin en only -->
<p>Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.</p>
<!-- end en only -->
<!-- begin... | 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
| 1 1
3 3
4 4
5 6
| 24,795 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.