From a13fa9d584eba18141a9feeef25512e5be7eaa27 Mon Sep 17 00:00:00 2001 From: ddeonseo Date: Sun, 5 May 2024 22:07:58 +0900 Subject: [PATCH 01/10] =?UTF-8?q?1463=EB=B2=88=20-=201=EB=A1=9C=20?= =?UTF-8?q?=EB=A7=8C=EB=93=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1463-1\353\241\234\353\247\214\353\223\244\352\270\260.py" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "202102649/1463-1\353\241\234\353\247\214\353\223\244\352\270\260.py" diff --git "a/202102649/1463-1\353\241\234\353\247\214\353\223\244\352\270\260.py" "b/202102649/1463-1\353\241\234\353\247\214\353\223\244\352\270\260.py" new file mode 100644 index 0000000..e69de29 From 102f92b988934f8aeae80b3c5c5c0d2ad9c51693 Mon Sep 17 00:00:00 2001 From: ddeonseo Date: Sun, 5 May 2024 22:09:41 +0900 Subject: [PATCH 02/10] =?UTF-8?q?1003=EB=B2=88=20-=20=ED=94=BC=EB=B3=B4?= =?UTF-8?q?=EB=82=98=EC=B9=98=20=ED=95=A8=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...264\353\202\230\354\271\230\355\225\250\354\210\230.py" | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 "202102649/1003-\355\224\274\353\263\264\353\202\230\354\271\230\355\225\250\354\210\230.py" diff --git "a/202102649/1003-\355\224\274\353\263\264\353\202\230\354\271\230\355\225\250\354\210\230.py" "b/202102649/1003-\355\224\274\353\263\264\353\202\230\354\271\230\355\225\250\354\210\230.py" new file mode 100644 index 0000000..f1e8a5a --- /dev/null +++ "b/202102649/1003-\355\224\274\353\263\264\353\202\230\354\271\230\355\225\250\354\210\230.py" @@ -0,0 +1,7 @@ +T = int(input()) +for _ in range(T): + N = int(input()) + a, b = 1, 0 + for i in range(N): + a, b = b, a + b + print(a, b) \ No newline at end of file From 151d254fa2af9f48727120ac0f6b74e4ac76b41b Mon Sep 17 00:00:00 2001 From: ddeonseo Date: Sun, 5 May 2024 22:11:46 +0900 Subject: [PATCH 03/10] =?UTF-8?q?9095=EB=B2=88=20-=201,=202,=203=20?= =?UTF-8?q?=EB=8D=94=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...-123\353\215\224\355\225\230\352\270\260.py" | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 "202102649/9095-123\353\215\224\355\225\230\352\270\260.py" diff --git "a/202102649/9095-123\353\215\224\355\225\230\352\270\260.py" "b/202102649/9095-123\353\215\224\355\225\230\352\270\260.py" new file mode 100644 index 0000000..fc5c6dc --- /dev/null +++ "b/202102649/9095-123\353\215\224\355\225\230\352\270\260.py" @@ -0,0 +1,17 @@ +import sys +input = sys.stdin.readline + +def func(x): + if x == 1: + return 1 + elif x == 2: + return 2 + elif x == 3: + return 4 + else: + return func(x - 1) + func(x - 2) + func(x - 3) + +t = int(input()) +for _ in range(t): + n = int(input()) + print(func(n)) \ No newline at end of file From bf688b41829bede2d596e06e72426e71291c5048 Mon Sep 17 00:00:00 2001 From: ddeonseo Date: Sun, 5 May 2024 22:15:41 +0900 Subject: [PATCH 04/10] =?UTF-8?q?17298=EB=B2=88=20-=20=EC=98=A4=ED=81=B0?= =?UTF-8?q?=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "202102649/17298-\354\230\244\355\201\260\354\210\230.py" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "202102649/17298-\354\230\244\355\201\260\354\210\230.py" diff --git "a/202102649/17298-\354\230\244\355\201\260\354\210\230.py" "b/202102649/17298-\354\230\244\355\201\260\354\210\230.py" new file mode 100644 index 0000000..e69de29 From bdfb1599f0e8e3c6550a287f62013c33668eda22 Mon Sep 17 00:00:00 2001 From: ddeonseo Date: Sun, 12 May 2024 22:43:28 +0900 Subject: [PATCH 05/10] =?UTF-8?q?7575=EB=B2=88=20-=20=ED=86=A0=EB=A7=88?= =?UTF-8?q?=ED=86=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...6-\355\206\240\353\247\210\355\206\240.cc" | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 "202102649/7576-\355\206\240\353\247\210\355\206\240.cc" diff --git "a/202102649/7576-\355\206\240\353\247\210\355\206\240.cc" "b/202102649/7576-\355\206\240\353\247\210\355\206\240.cc" new file mode 100644 index 0000000..80ce415 --- /dev/null +++ "b/202102649/7576-\355\206\240\353\247\210\355\206\240.cc" @@ -0,0 +1,67 @@ +#include +#include + +using namespace std; + +int tomatoMap[1000][1000]; +queue> q; +int result = 0; +int M, N; +int dx[] = {1, 0, -1, 0}; +int dy[] = {0, 1, 0, -1}; +void tomatoBFS() { + while (!q.empty()) { + int xx = q.front().first; + int yy = q.front().second; + + q.pop(); + + for (int i = 0; i < 4; i++) { + int nx = xx + dx[i]; + int ny = yy + dy[i]; + + if (nx >= 0 && ny >= 0 && nx < N && ny < M) { + if (tomatoMap[nx][ny] == 0) { + tomatoMap[nx][ny] = tomatoMap[xx][yy] + 1; + q.push(make_pair(nx, ny)); + } + } + } + } +} + +void tomato() { + cin >> M >> N; + + for (int i = 0; i < N; i++) { + for (int j = 0; j < M; j++) { + cin >> tomatoMap[i][j]; + + if (tomatoMap[i][j] == 1) { + q.push(make_pair(i, j)); + } + } + } + tomatoBFS(); + + + for (int i = 0; i < N; i++) { + for (int j = 0; j < M; j++) { + if (tomatoMap[i][j] == 0) { + cout << -1 << "\n"; + return; + } + + if (result < tomatoMap[i][j]) { + result = tomatoMap[i][j]; + } + } + } + + cout << result - 1 << "\n"; +} +int main() { + tomato(); + + return 0; +} \ No newline at end of file From 812ae1792826b422d426372167b41c2d37deba45 Mon Sep 17 00:00:00 2001 From: ddeonseo Date: Sun, 12 May 2024 22:43:48 +0900 Subject: [PATCH 06/10] =?UTF-8?q?7569=EB=B2=88=20-=20=ED=86=A0=EB=A7=88?= =?UTF-8?q?=ED=86=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...9-\355\206\240\353\247\210\355\206\240.cc" | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 "202102649/7569-\355\206\240\353\247\210\355\206\240.cc" diff --git "a/202102649/7569-\355\206\240\353\247\210\355\206\240.cc" "b/202102649/7569-\355\206\240\353\247\210\355\206\240.cc" new file mode 100644 index 0000000..fe2c353 --- /dev/null +++ "b/202102649/7569-\355\206\240\353\247\210\355\206\240.cc" @@ -0,0 +1,66 @@ +#include +#include +#include + +using namespace std; + + +int m, n, h, ans, dist[102][102][102]; +int dx[] = {0,0,1,-1,0,0}; +int dy[] = {1,-1,0,0,0,0}; +int dz[] = {0,0,0,0,1,-1}; +queue, int>> q; + +void bfs(){ + while(!q.empty()){ + int xx = q.front().first.first; + int yy = q.front().first.second; + int zz = q.front().second; + q.pop(); + for(int i=0;i<6;i++){ + int nx = xx+dx[i]; + int ny = yy+dy[i]; + int nz = zz+dz[i]; + + if(nx>=0&&ny>=0&&nz>=0&&nx> m >> n >> h; + for(int k=0;k> dist[i][j][k]; + if(dist[i][j][k] == 1){ + q.push(make_pair(make_pair(i,j),k)); + } + } + } + } + + bfs(); + + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + for(int k=0;k Date: Sun, 12 May 2024 22:44:22 +0900 Subject: [PATCH 07/10] =?UTF-8?q?10026=EB=B2=88=20-=20=EC=A0=81=EB=A1=9D?= =?UTF-8?q?=EC=83=89=EC=95=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...01\353\241\235\354\203\211\354\225\275.py" | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "202102649/10026-\354\240\201\353\241\235\354\203\211\354\225\275.py" diff --git "a/202102649/10026-\354\240\201\353\241\235\354\203\211\354\225\275.py" "b/202102649/10026-\354\240\201\353\241\235\354\203\211\354\225\275.py" new file mode 100644 index 0000000..9e5b0f7 --- /dev/null +++ "b/202102649/10026-\354\240\201\353\241\235\354\203\211\354\225\275.py" @@ -0,0 +1,44 @@ +import sys +sys.setrecursionlimit(1000000) +input = sys.stdin.readline + +n = int(input().rstrip()) +matrix = [list(input().rstrip()) for _ in range(n)] +visited = [[False] * n for _ in range(n)] + +three_cnt, two_cnt = 0, 0 +dx = [-1,1,0,0] +dy = [0,0,-1,1] + +def dfs(x,y): + visited[x][y] = True + current_color = matrix[x][y] + + for k in range(4): + nx = x + dx[k] + ny = y + dy[k] + if (0 <= nx < n) and (0 <= ny < n): + if visited[nx][ny]==False: + if matrix[nx][ny] == current_color: + dfs(nx,ny) + +for i in range(n): + for j in range(n): + if visited[i][j]==False: + dfs(i,j) + three_cnt += 1 + +for i in range(n): + for j in range(n): + if matrix[i][j]=='R': + matrix[i][j]='G' + +visited = [[False] * n for _ in range(n)] + +for i in range(n): + for j in range(n): + if visited[i][j] == False: + dfs(i,j) + two_cnt += 1 + +print(three_cnt,two_cnt) From d147088002f03819e3c4065c025a9a58bb49e7bc Mon Sep 17 00:00:00 2001 From: ddeonseo Date: Sun, 26 May 2024 21:25:31 +0900 Subject: [PATCH 08/10] =?UTF-8?q?1655=EB=B2=88=20=EA=B0=80=EC=9A=B4?= =?UTF-8?q?=EB=8D=B0=EB=A5=BC=20=EB=A7=90=ED=95=B4=EC=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...74\353\247\220\355\225\264\354\232\224.py" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "202102649/1655-\352\260\200\354\232\264\353\215\260\353\245\274\353\247\220\355\225\264\354\232\224.py" diff --git "a/202102649/1655-\352\260\200\354\232\264\353\215\260\353\245\274\353\247\220\355\225\264\354\232\224.py" "b/202102649/1655-\352\260\200\354\232\264\353\215\260\353\245\274\353\247\220\355\225\264\354\232\224.py" new file mode 100644 index 0000000..f47f412 --- /dev/null +++ "b/202102649/1655-\352\260\200\354\232\264\353\215\260\353\245\274\353\247\220\355\225\264\354\232\224.py" @@ -0,0 +1,23 @@ +import heapq +import sys + +n = int(sys.stdin.readline()) + +leftHeap = [] +rightHeap = [] +for i in range(n): + num = int(sys.stdin.readline()) + + if len(leftHeap) == len(rightHeap): + heapq.heappush(leftHeap, -num) + else: + heapq.heappush(rightHeap, num) + + if rightHeap and rightHeap[0] < -leftHeap[0]: + leftValue = heapq.heappop(leftHeap) + rightValue = heapq.heappop(rightHeap) + + heapq.heappush(leftHeap, -rightValue) + heapq.heappush(rightHeap, -leftValue) + + print(-leftHeap[0]) \ No newline at end of file From efbca33c7dc0f54806a647d84492afcb8d91cb0c Mon Sep 17 00:00:00 2001 From: ddeonseo Date: Sun, 26 May 2024 21:26:36 +0900 Subject: [PATCH 09/10] =?UTF-8?q?1918=EB=B2=88=20-=20=ED=9B=84=EC=9C=84=20?= =?UTF-8?q?=ED=91=9C=EA=B8=B0=EC=8B=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...04\355\221\234\352\270\260\354\213\235.py" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "202102649/1918-\355\233\204\354\234\204\355\221\234\352\270\260\354\213\235.py" diff --git "a/202102649/1918-\355\233\204\354\234\204\355\221\234\352\270\260\354\213\235.py" "b/202102649/1918-\355\233\204\354\234\204\355\221\234\352\270\260\354\213\235.py" new file mode 100644 index 0000000..9cd2841 --- /dev/null +++ "b/202102649/1918-\355\233\204\354\234\204\355\221\234\352\270\260\354\213\235.py" @@ -0,0 +1,24 @@ +strn = list(input()) +stack=[] +res='' +for s in strn: + if s.isalpha(): + res+=s + else: + if s == '(': + stack.append(s) + elif s == '*' or s == '/': + while stack and (stack[-1] == '*' or stack[-1] =='/'): + res += stack.pop() + stack.append(s) + elif s == '+' or s == '-': + while stack and stack[-1] != '(': + res+= stack.pop() + stack.append(s) + elif s == ')': + while stack and stack[-1] != '(': + res += stack.pop() + stack.pop() +while stack : + res+=stack.pop() +print(res) \ No newline at end of file From f22ff8d6d3c8c7f9be5ae47b4c10feaef0263dbb Mon Sep 17 00:00:00 2001 From: ddeonseo Date: Sun, 26 May 2024 21:28:40 +0900 Subject: [PATCH 10/10] =?UTF-8?q?1167=EB=B2=88=20-=20=ED=8A=B8=EB=A6=AC?= =?UTF-8?q?=EC=9D=98=20=EC=A7=80=EB=A6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...54\354\235\230\354\247\200\353\246\204.py" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "202102649/1167-\355\212\270\353\246\254\354\235\230\354\247\200\353\246\204.py" diff --git "a/202102649/1167-\355\212\270\353\246\254\354\235\230\354\247\200\353\246\204.py" "b/202102649/1167-\355\212\270\353\246\254\354\235\230\354\247\200\353\246\204.py" new file mode 100644 index 0000000..faa94b5 --- /dev/null +++ "b/202102649/1167-\355\212\270\353\246\254\354\235\230\354\247\200\353\246\204.py" @@ -0,0 +1,29 @@ +import sys +sys.setrecursionlimit(10**9) +input = sys.stdin.readline + +n = int(input()) +graph = [[] for _ in range(n+1)] + +for _ in range(n): + node = list(map(int, input().split()))[:-1] + for i in range(1, len(node)//2 + 1): + graph[node[0]].append([node[i*2 - 1], node[i*2]]) + +def dfs(x, dist): + for i in graph[x]: + node, wei = i + if distance[node] == -1: + distance[node] = dist + wei + dfs(node, dist + wei) + +distance = [-1] * (n+1) +distance[1] = 0 +dfs(1, 0) + +res = distance.index(max(distance)) +distance = [-1] * (n+1) +distance[res] = 0 +dfs(res, 0) + +print(max(distance)) \ No newline at end of file