์ฌ๋ฐฉ๋ฉด์ ๊ฐ์ ์๊น ์๋์ง ๊ฒ์ฌ DFS ๊ทธ๋ฅ DFS ‘R’์ ‘G’๋ก ๋ฐ๊พธ๊ณ DFS ํ๋ฒ ๋ import sys from collections import deque sys.setrecursionlimit(1000000) input = sys.stdin.readline def DFS(x, y): dx = [-1, 1, 0, 0] dy = [0, 0, -1, 1] visited[y][x] = 1 for i in range(4): nowx, nowy = x+dx[i], y+dy[i] if 0
- 2606 ์ ์ญ๋ณ์๋ฅผ ์ฌ์ฉํด์ cnt๊ฐ์ ์ฒดํฌํ๋๋ผ ์ ๋จน์๋๋ฐ ๊ตณ์ด ๊ทธ๋ด ํ์๊ฐ ์์๋ค ์ด์ฐจํผ ๋ฐฉ๋ฌธํ ๊ฐ์ visited์ ์ ์ฅํ๊ธฐ ๋๋ฌธ์ sum(visited) -1 ํด์ฃผ๋ฉด ๋๋ ๊ฒ! *์๊ฐ์ ์ ํ ์๊ฐ์ ๋ฐ์!! import sys from collections import deque input = sys.stdin.readline N = int(input().rstrip()) M = int(input().rstrip()) graph = [[0]*(N+1) for i in range(N+1)] visited = [0]*(N+1) for i in range(M): n1, n2 = map(int, input().rstrip().split()) graph[n1][n2] = graph[n2][n1] = 1..
True → 1, False → 0 ๋ก ๊ตฌํ import sys from collections import deque input = sys.stdin.readline # N : ์ ์ ๊ฐ์, M : ๊ฐ์ ๊ฐ์, V : ํ์์์์ N, M, V = map(int, input().rstrip().split()) # ์ธ์ ํ๋ ฌ์ ๋ชจ๋ 0์ผ๋ก ๊ตฌ์ฑ matrix = [[0]*(N+1) for i in range(N+1)] #๋ฐฉ๋ฌธํ ๊ณณ ์ฒดํฌ ๋ฆฌ์คํธ ์ ์ ๊ฐฏ์๋งํผ ํฌ๊ธฐ ๊ตฌ์ฑ visited_dfs = [0]*(N+1) visited_bfs = [0]*(N+1) # ๊ฐ์ ๊ฐฏ์ ๋งํผ ์ ๋ ฅ๋ฐ๊ธฐ, ์ ๋ ฅ๋ฐ๋ ๊ฐ์ ๋ํด ์ํ๋ ฌ์ 1 ์ฝ์ -> ์ธ์ ๋ฆฌ์คํธ ์์ฑ for i in range(M): n1, n2 = map(int, input(..
์์ ๋ฌธ์ ์ ๋น์ทํ๊ฒ for๋ฌธ ๋๊ฐ๋ฅผ ์ฌ์ฉํด์ ํ๋ฉด ์๊ฐ์ด๊ณผ๊ฐ ๋ฌ๋ค ‘์๋ผํ ์คํ ๋ค์ค์ ์ฒด’๋ฅผ ์ด์ฉํด์ ์ฝ๋๋ฅผ ์์ฑํด์ผ ํ๋ค. ์๊ฐ์ ์ค์ด๊ธฐ ์ํด 2๋ถํฐ i๊น์ง ๋ค ๊ฒ์ฌํ๋ ๊ฒ์ด๋ผ ์๋๋ผ, 2๋ถํฐ i์ ์ ๊ณฑ๊ทผ(๋ฃจํธ)๊น์ง๋ง ๊ฒ์ฌํ๋ฉด ๋๋ค. import sys N, M = map(int, sys.stdin.readline().rstrip().split()) prime_num = [] for i in range(N, M+1): flag = 0 if i == 1 : continue # 1์ ์์๊ฐ X for j in range(2, int(i**0.5) + 1): if i % j == 0: flag = 1 break if flag == 0: prime_num.append(i) print(*prime_num, se..
๋ฐ๋ชฉ๋ฌธ : 6, 7, 12 โ 1์ฐจ์ ๋ฐฐ์ด: 2, 6, 8, 9 โ ํจ์: 2, 3 โ ๋ฌธ์์ด ํ๊ธฐ: 3, 4, 5, 7, 8, 9, 10 โ 4673 : ์ ํ๋๋ฒ ์ถ๋ ฅ 10809 : ์ํ๋ฒณ ์ฐพ๊ธฐ 1157 : ๋จ์ด ๊ณต๋ถ 5622 : ๋ค์ด์ผ 2941 : ํฌ๋ก์ํฐ์ ์ํ๋ฒณ 1316 : ๊ทธ๋ฃน ๋จ์ด ์ฒด์ปค ์ ์ ๊ฐ ์๋ฆฟ์๋ณ๋ก ๋๋๊ธฐ map(int, str(n)) : ๋ฌธ์์ด๋ก ๋์ด์๋ ๊ฐ ์๋ฆฟ์๋ฅผ ์ ์๋ก ๋ฐ๊ฟ์ค๋ค( ex, "123" > ์ ์ 1, 2, 3 ๊ฐ๊ฐ์ผ๋ก ๋ฐ๊ฟ์ค๋ค) # ์ซ์๋ฅผ ์๋ฆฟ์๋ฅผ ๊ธฐ์ค์ผ๋ก ๋ถ๋ฅํด์ ๋๋์ธ์ def digitize(n) : return list(map(int, str(n))) # ์ฝ๋ ๋ถ์ # 1) str(n) : ์ซ์๋ฅผ ๋ฌธ์์ด๋ก ๋ง๋ค์ด์ค๋ค # 2) map(int, str(n)) : ๋ฌธ..
Prim-Jarnik ์๊ณ ๋ฆฌ์ฆ - ๋ฌด๋ฐฉํฅ๊ฐ์ ์ด๊ณ , ํ ์ ์ ์์ ์์์ ๋ค๋ฅธ ์ ์ ์ผ๋ก ๊ฐ๋ ๊ฒฝ๋ก๋ ๋ฐ๋์ ์กด์ฌ - ๊ฐ์ ์ ๋ฌด๊ฒ๋ ์ค๋ณต์ด ์๋ ์์ ์ ์ - ์๊ณ ๋ฆฌ์ฆ ์ํ์ ์ถ๋ฐ์ ์ ์ ๋ฒํธ๊ฐ ๊ฐ์ฅ ๋น ๋ฅธ ์ ์ ์ธ 1๋ถํฐ ์์ #pragma warning(disable:4996) #include #include #define MAX_VERTICES 100 #define INF 10000L int n; int weight[MAX_VERTICES][MAX_VERTICES]; int selected[MAX_VERTICES]; int d[MAX_VERTICES];// ๊ฐ์ ๋ฌด๊ฒ ์ ์ฅํ ๋ฐฐ์ด int getMinVertex(int n) { int u, i; for (i = 0; i < n; i++) { if (!select..
- ๋ฐฉํฅ๊ทธ๋ํ G - ๋ฐฉํฅ ๋น์ธ์ดํด ๊ทธ๋ํ(directed acyclic graph: DAG)๋ฉด ์์์์(topologicalorder)๋ฅผ ๊ตฌํด ์ธ์ - G์ ๋ฐฉํฅ ์ธ์ดํด(directed cycle)์ด ์กด์ฌํ๋ฉด ์์์์๋ฅผ ๊ตฌํ ์ ์์ผ๋ฏ๋ก 0์ ์ธ์ - ์ธ์ ๋ฆฌ์คํธ ๊ตฌ์กฐ๋ก ํํ && ๋ฐฐ์ด๋ก ๊ตฌํ - in-degree (์ง์ ์ฐจ์) ์ด์ฉํด์ ์์์์ ๊ตฌํ๊ธฐ - ์์์์๋ฅผ ๊ตฌํ๋ ๊ณผ์ ์์ ๋ฐฉํฅ์ธ์ดํด์ ์กด์ฌ ์ฌ๋ถ ํ์ธ - ๊ทธ๋ํ์ ๋ํ ์์์์๋ ์ฌ๋ฌ ๊ฐ ์์ ์ ์์ง๋ง, ์๋ ์ฝ๋์์๋ ๋จ ํ ๊ฐ์ ์์์์๋ง ์ถ๋ ฅ ๊ฐ๋ฅํ๋๋ก # include # include # pragma warning(disable:4996) int n, m; int* in; int* topOrder; int* queue; int queu..
์ฝ๋: #pragma warning(disable:4996) #include #include typedef struct Vertex { int vN; struct Vertex* next; }Vertex; typedef struct Edge { int weight; Vertex* v1, * v2; struct Edge* next; }Edge; typedef struct Graph{ Vertex* vHead; Edge* eHead; }Graph; void init(Graph* G) { G->vHead = NULL; G->eHead = NULL; } void createVertex(Graph* G, int vN) { Vertex* v = (Vertex*)malloc(sizeof(Vertex)); v->vN =..
- Total
- Today
- Yesterday
- AIRUSH2023
- ๋ ผ๋ฌธ๋ฆฌ๋ทฐ
- HyperCLOVA
- SKTECHSUMMIT
- gan
- WGAN
- ์ฝ๋ฉ๊ณต๋ถ
- AIRUSH
- ํ ํฌ์๋ฐ
- AI์ปจํผ๋ฐ์ค
- DALLE
- SQL
- Aimers
- dreambooth
- lgaimers
- CLOVAX
- MYSQL
- ๊ธฐ์ ์ปจํผ๋ฐ์ค
- ๋ ผ๋ฌธ์ฝ๊ธฐ
- ๊ตฌ๊ธ์ฝ๋ฉ
- ๋๋ฆผ๋ถ์ค
- ์ฝํ
- ์ฝ๋ฉ์๋ฌ
- ํ์ด์ฌ์ฝํ
- ์ฝํ ์ค๋น
- StableDiffusion
- ํ์ด์ฌ
- C์ธ์ด
- ์คํ ์ด๋ธ๋ํจ์
- ํ๋ก๊ทธ๋๋จธ์ค
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |