FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithm/16932.py at main · Ustay-coder/algorithm · GitHub
Ustay-coder
/
algorithm
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithm
/
16932.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
59 lines (48 loc) · 1.38 KB
Breadcrumbs
algorithm
/
16932.py
Copy path
File metadata and controls
59 lines (48 loc) · 1.38 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import
sys
input
=
sys
.
stdin
.
readline
sys
.
setrecursionlimit
(
222222
)
n
,
m
=
map
(
int
,
input
().
split
())
graph
=
[]
for
_
in
range
(
n
):
graph
.
append
(
list
(
map
(
int
,
input
().
split
())))
#1 타일들의 영역을 그룹화한다.
dy
=
[
-
1
,
0
,
0
,
1
]
dx
=
[
0
,
-
1
,
1
,
0
]
visited
=
[[
False
for
_
in
range
(
m
+
1
)]
for
_
in
range
(
n
+
1
)]
group
=
[
0
for
_
in
range
(
1000001
)]
def
dfs
(
y
,
x
,
num
):
graph
[
y
][
x
]
=
num
ret
=
1
for
i
in
range
(
4
):
ny
,
nx
=
y
+
dy
[
i
],
x
+
dx
[
i
]
if
not
(
0
<=
ny
<
n
and
0
<=
nx
<
m
):
continue
if
visited
[
ny
][
nx
]
or
graph
[
ny
][
nx
]
==
0
:
continue
visited
[
ny
][
nx
]
=
True
ret
+=
dfs
(
ny
,
nx
,
num
)
return
ret
num
=
2
for
i
in
range
(
n
):
for
j
in
range
(
m
):
if
not
visited
[
i
][
j
]
and
graph
[
i
][
j
]
==
1
:
visited
[
i
][
j
]
=
True
size
=
dfs
(
i
,
j
,
num
)
group
[
num
]
=
size
num
+=
1
# 0 타일을 기준으로 탐색한다.
def
search
(
y
,
x
):
ret
=
1
used
=
set
()
for
i
in
range
(
4
):
ny
,
nx
=
y
+
dy
[
i
],
x
+
dx
[
i
]
if
not
(
0
<=
ny
<
n
and
0
<=
nx
<
m
):
continue
if
graph
[
ny
][
nx
]
!=
0
and
graph
[
ny
][
nx
]
not
in
used
:
ret
+=
group
[
graph
[
ny
][
nx
]]
used
.
add
(
graph
[
ny
][
nx
])
return
ret
result
=
0
for
i
in
range
(
n
):
for
j
in
range
(
m
):
if
graph
[
i
][
j
]
==
0
:
tmp
=
search
(
i
,
j
)
result
=
max
(
result
,
tmp
)
print
(
result
)
Back
|
FazBrowse Home
|
New Git URL