{"id":894,"date":"2019-04-07T19:18:41","date_gmt":"2019-04-07T10:18:41","guid":{"rendered":"https:\/\/dong1lkim.oboki.net\/?p=894"},"modified":"2019-09-01T22:23:15","modified_gmt":"2019-09-01T13:23:15","slug":"2606-%eb%b0%94%ec%9d%b4%eb%9f%ac%ec%8a%a4","status":"publish","type":"post","link":"https:\/\/oboki.net\/workspace\/python\/2606-%eb%b0%94%ec%9d%b4%eb%9f%ac%ec%8a%a4\/","title":{"rendered":"[BaekJoon Online Judge] 2606 &#8211; \ubc14\uc774\ub7ec\uc2a4"},"content":{"rendered":"<h1>[BaekJoon Online Judge] 2606 &#8211; \ubc14\uc774\ub7ec\uc2a4<\/h1>\n<h2>\ubb38\uc81c<\/h2>\n<p><a href=\"https:\/\/www.acmicpc.net\/problem\/2606\"><a href=\"https:\/\/www.acmicpc.net\/problem\/2606\">https:\/\/www.acmicpc.net\/problem\/2606<\/a><\/a><\/p>\n<h2>\uc18c\uc2a4\ucf54\ub4dc<\/h2>\n<p><code>dfs<\/code> \ub97c \uc774\uc6a9\ud574\uc11c \ubb38\uc81c\ub97c \ud574\uacb0\ud55c\ub2e4. \uc591\ubc29\ud5a5 \uac04\uc120\uc73c\ub85c \ud45c\ud604\ub41c \ub124\ud2b8\uc6cc\ud06c \uc785\ub825\uc744 \uadf8\ub798\ud504\ub85c \ud45c\ud604\ud55c \ub4a4 <code>1<\/code>\ubc88 \ucef4\ud4e8\ud130\ubd80\ud130 \ud0d0\uc0c9\uc744 \uc2dc\uc791\ud558\uba74 \ubc14\uc774\ub7ec\uc2a4\uc5d0 \uac10\uc5fc\ub418\ub294 \ubaa8\ub4e0 \ucef4\ud4e8\ud130\ub97c \ucc3e\uc544\ub0bc \uc218 \uc788\ub2e4.<\/p>\n<pre><code class=\"py\">N = int(input())\nV = int(input())\ngraph = [[0 for _ in range(N)] for _ in range(N)]\nfor i in range(V):\n    a,b = map(int,input().split())\n    graph[a-1][b-1] = 1\n    graph[b-1][a-1] = 1\n\nstack = [0]\npolluted = []\nwhile stack:\n    curr = stack.pop(0)\n    polluted.append(curr)\n    for i in range(N):\n        if graph[curr][i] == 1 and i not in polluted:\n            stack.append(i)\n\nprint(len(set(polluted))-1)\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>[BaekJoon Online Judge] 2606 &#8211; \ubc14\uc774\ub7ec\uc2a4 \ubb38\uc81c https:\/\/www.acmicpc.net\/problem\/2606 \uc18c\uc2a4\ucf54\ub4dc dfs \ub97c \uc774\uc6a9\ud574\uc11c \ubb38\uc81c\ub97c \ud574\uacb0\ud55c\ub2e4. \uc591\ubc29\ud5a5 \uac04\uc120\uc73c\ub85c \ud45c\ud604\ub41c \ub124\ud2b8\uc6cc\ud06c \uc785\ub825\uc744 \uadf8\ub798\ud504\ub85c \ud45c\ud604\ud55c \ub4a4 1\ubc88 \ucef4\ud4e8\ud130\ubd80\ud130 \ud0d0\uc0c9\uc744 \uc2dc\uc791\ud558\uba74 \ubc14\uc774\ub7ec\uc2a4\uc5d0 \uac10\uc5fc\ub418\ub294 \ubaa8\ub4e0 \ucef4\ud4e8\ud130\ub97c \ucc3e\uc544\ub0bc \uc218 \uc788\ub2e4. N = int(input()) V = int(input()) graph = [[0 for _ in range(N)] for _ in range(N)] for i in range(V): a,b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,10],"tags":[34,95],"class_list":["post-894","post","type-post","status-publish","format-standard","hentry","category-baekjoon-online-judge","category-python","tag-python","tag-95"],"_links":{"self":[{"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/posts\/894","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/comments?post=894"}],"version-history":[{"count":2,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/posts\/894\/revisions"}],"predecessor-version":[{"id":1344,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/posts\/894\/revisions\/1344"}],"wp:attachment":[{"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/media?parent=894"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/categories?post=894"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/tags?post=894"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}