프로세스(프로그램)이 메모장, 크롬, MMORPG 게임이 실행되고 있다고 가정하자. 각 프로그램에는 쓰레드가 존재하고 메모장에 1개, 크롬에 1개, MMORPG에 2개가 있다. CPU의 코어는 한번에 하나의 쓰레드만 동작시킬 수 있는데, 만약 1개의 코어라면? 각 쓰레드를 굉장히 빠른 속도로 이동하며 프로그램을 동시에 돌아갈 수 있도록 만든다. 코어가 2개라면? 2개의 코어가 굉장히 빠른 속도로 이동하며 프로그램을 동시에 돌아갈 수 있도록 만든다. 가장 좋은 방법은 코어와 쓰레드의 개수를 일치시키는 것이다. 코어가 굉장히 빠른 속도로 쓰레드를 돌아가며 프로그램을 실행시키는 것보단 하나의 코어가 하나의 쓰레드에 집중하며 프로그램을 실행시키는 것이 효율 차원에선 이득이다. 간단하게 쓰레드에 대해서 알아보았으..
문제 https://www.acmicpc.net/problem/1012 1012번: 유기농 배추 차세대 영농인 한나는 강원도 고랭지에서 유기농 배추를 재배하기로 하였다. 농약을 쓰지 않고 배추를 재배하려면 배추를 해충으로부터 보호하는 것이 중요하기 때문에, 한나는 해충 방지에 www.acmicpc.net 코드 using System; using System.Collections.Generic; class Dongsik { static int[,] map; static bool[,] visited; static int x, y; static int[] dx = {0, 0, -1, 1}; // 좌우 static int[] dy = {1, -1, 0, 0}; // 상하 static void Main(strin..
문제 https://www.acmicpc.net/problem/2667 2667번: 단지번호붙이기 과 같이 정사각형 모양의 지도가 있다. 1은 집이 있는 곳을, 0은 집이 없는 곳을 나타낸다. 철수는 이 지도를 가지고 연결된 집의 모임인 단지를 정의하고, 단지에 번호를 붙이려 한다. 여 www.acmicpc.net 코드 using System; using System.Collections.Generic; class Dongsik { static int n; static int[,] map; static bool[,] visited; static int[] dy = {1, -1, 0, 0}; // 좌표 static int[] dx = {0, 0, -1, 1}; // 좌표 static void Main(st..
문제 https://www.acmicpc.net/problem/2606 2606번: 바이러스 첫째 줄에는 컴퓨터의 수가 주어진다. 컴퓨터의 수는 100 이하인 양의 정수이고 각 컴퓨터에는 1번 부터 차례대로 번호가 매겨진다. 둘째 줄에는 네트워크 상에서 직접 연결되어 있는 컴퓨터 쌍 www.acmicpc.net 코드 using System; class Algorithm { static int n, m; static List[] computers; static bool[] visited; static void Main(string[] arg) { int n = int.Parse(Console.ReadLine()); // com 총 수 int m = int.Parse(Console.ReadLine()); /..
문제 https://www.acmicpc.net/problem/1926 1926번: 그림 어떤 큰 도화지에 그림이 그려져 있을 때, 그 그림의 개수와, 그 그림 중 넓이가 가장 넓은 것의 넓이를 출력하여라. 단, 그림이라는 것은 1로 연결된 것을 한 그림이라고 정의하자. 가로나 세로 www.acmicpc.net 코드 namespace dongsik { class Algorithm { static int n, m; static int[,] graph; static bool[,] visited; static int[] dx = { 1, -1, 0, 0 }; static int[] dy = { 0, 0, -1, 1 }; static void Main(string[] args) { // n * m 입력 받기 i..
문제 코드 using System; using System.Text; using System.Collections.Generic; namespace dongsik { class Algorithm { static int n, m; // n * m static int[,] map; // 지도 static int[,] dist; // 거리 static bool[,] visited; // 방문처리 static int[] dx = {-1, 0, 1, 0}; // x좌표 이동 static int[] dy = {0, -1, 0, 1}; // y좌표 이동 private static void BFS(int x, int y) { Queue queue = new Queue(); // queue queue.Enqueue(ne..
문제 https://www.acmicpc.net/problem/2110 코드 using System; using System.Text; using System.Collections.Generic; namespace dongsik { class Algorithm { static void Main(string[] str) { int[] nArr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); int num = nArr[0]; int total = nArr[1]; int[] houses = new int[num]; for(int i = 0; i < num; i++) { houses[i] = int.Parse(Console.ReadLine()); }..
문제 https://www.acmicpc.net/problem/10815 코드 using System; using System.Text; using System.Collections.Generic; namespace dongsik { class Algorithm { static void Main(string[] str) { int n = int.Parse(Console.ReadLine()); int[] nArr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); Array.Sort(nArr); int m = int.Parse(Console.ReadLine()); int[] mArr = Array.ConvertAll(Console.ReadLine(..