From 9de3692256577120e098be3a08c2e8a571842862 Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Fri, 17 Oct 2025 23:35:52 +0900 Subject: [PATCH] 20251017 baekjoon --- code_study/Baekjoon/c/1865.c | 74 +++++++++++++++++++++++ code_study/Baekjoon/c/2638.c | 88 ++++++++++++++++++++++++++++ code_study/Baekjoon/swift/2440.swift | 8 +++ 3 files changed, 170 insertions(+) create mode 100644 code_study/Baekjoon/c/1865.c create mode 100644 code_study/Baekjoon/c/2638.c create mode 100644 code_study/Baekjoon/swift/2440.swift diff --git a/code_study/Baekjoon/c/1865.c b/code_study/Baekjoon/c/1865.c new file mode 100644 index 0000000..313d1c2 --- /dev/null +++ b/code_study/Baekjoon/c/1865.c @@ -0,0 +1,74 @@ +#include +#include +#include +#include + +#define MAX_SIZE 5200 +#define MAX_NODE 501 + +typedef struct { + int start; + int end; + int time; +} Edge; + +int main() { + int T; + scanf("%d", &T); + + Edge* edge = (Edge*)malloc(sizeof(Edge)*MAX_SIZE); + int* distance = (int*)malloc(sizeof(int)*MAX_NODE); + + while(T--) { + int N, M, W; + scanf("%d %d %d",&N, &M, &W); + + // ROAD + for(int i=0; i<2*M; i+=2) { + int S, E, T; + scanf("%d %d %d",&S, &E, &T); + + Edge temp1 = {S, E, T}; + Edge temp2 = {E, S, T}; + + edge[i] = temp1; + edge[i+1] = temp2; + } + + // WORM HOLE + for(int i=0; i distance[s] + t) { + distance[e] = distance[s] + t; + + if(n==N-1) { + negative_cycle = true; + break; + } + } + } + } + + printf("%s\n", negative_cycle ? "YES" : "NO"); + } + + free(edge); + free(distance); + return 0; +} \ No newline at end of file diff --git a/code_study/Baekjoon/c/2638.c b/code_study/Baekjoon/c/2638.c new file mode 100644 index 0000000..7b1d9f8 --- /dev/null +++ b/code_study/Baekjoon/c/2638.c @@ -0,0 +1,88 @@ +#include +#include +#include + +typedef struct { + int x; + int y; +} Point; + +int main() { + int N, M; + scanf("%d %d", &N, &M); + + int** paper = (int**)malloc(sizeof(int*)*N); + int cheese = 0; + int time = 0; + + for(int i=0; i 1) { + paper[i][j] = 0; + cheese--; + } + } + } + + time++; + } + + printf("%d\n",time); + + for(int i=0; i