Algorithm37 백준 2606번 : 바이러스 링크 : https://www.acmicpc.net/problem/2606 2606번: 바이러스 첫째 줄에는 컴퓨터의 수가 주어진다. 컴퓨터의 수는 100 이하이고 각 컴퓨터에는 1번 부터 차례대로 번호가 매겨진다. 둘째 줄에는 네트워크 상에서 직접 연결되어 있는 컴퓨터 쌍의 수가 주어 www.acmicpc.net from collections import deque import sys input = sys.stdin.readline N = int(input()) n = int(input()) graph = [[] for _ in range(N+1)] # 편의상 0 추가 for _i in range(n): _x, _y = map(int, input().split()) graph[_x].append(_y).. 2022. 1. 16. 백준 1260번 : DFS와 BFS 링크 : https://www.acmicpc.net/problem/1260 1260번: DFS와 BFS 첫째 줄에 정점의 개수 N(1 ≤ N ≤ 1,000), 간선의 개수 M(1 ≤ M ≤ 10,000), 탐색을 시작할 정점의 번호 V가 주어진다. 다음 M개의 줄에는 간선이 연결하는 두 정점의 번호가 주어진다. 어떤 두 정점 사 www.acmicpc.net from collections import deque import sys input = sys.stdin.readline N, M, V = map(int, input().split()) graph = [[] for _i in range(N+1)] # 편의를 위해 1개 더 추가 for i in range(M): x, y= map(int,input().s.. 2022. 1. 16. 백준 1012번 : 유기농 배추 링크 : https://www.acmicpc.net/problem/1012 1012번: 유기농 배추 차세대 영농인 한나는 강원도 고랭지에서 유기농 배추를 재배하기로 하였다. 농약을 쓰지 않고 배추를 재배하려면 배추를 해충으로부터 보호하는 것이 중요하기 때문에, 한나는 해충 방지에 www.acmicpc.net import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline def dfs(x, y): _x = [0, 0, 1, -1] _y = [1, -1, 0, 0] for i in range(4): m_x = x+_x[i] m_y = y+_y[i] if (0 2022. 1. 16. 백준 1912번 : 연속합 링크 : https://www.acmicpc.net/problem/1912 1912번: 연속합 첫째 줄에 정수 n(1 ≤ n ≤ 100,000)이 주어지고 둘째 줄에는 n개의 정수로 이루어진 수열이 주어진다. 수는 -1,000보다 크거나 같고, 1,000보다 작거나 같은 정수이다. www.acmicpc.net import sys input = sys.stdin.readline n = int(input()) arr = list(map(int, input().split())) arr_sum = [0] * n arr_sum[0] = arr[0] for i in range(1, n): if arr_sum[i-1] > 0 : arr_sum[i] = arr_sum[i-1]+arr[i] else: arr_sum[i].. 2022. 1. 8. 이전 1 ··· 4 5 6 7 8 9 10 다음