From 9eddff8b99af5166b313655d4d552f0d305c3acf Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Wed, 29 Oct 2025 20:46:47 +0900 Subject: [PATCH] 20251029 baekjoon --- code_study/Baekjoon/python/4101.py | 2 + code_study/Baekjoon/swift/16236.swift | 107 ++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 code_study/Baekjoon/python/4101.py create mode 100644 code_study/Baekjoon/swift/16236.swift diff --git a/code_study/Baekjoon/python/4101.py b/code_study/Baekjoon/python/4101.py new file mode 100644 index 0000000..d82145d --- /dev/null +++ b/code_study/Baekjoon/python/4101.py @@ -0,0 +1,2 @@ +while (s := list(map(int, input().split()))) != [0]*2 : + print('Yes' if s[0] > s[1] else 'No') \ No newline at end of file diff --git a/code_study/Baekjoon/swift/16236.swift b/code_study/Baekjoon/swift/16236.swift new file mode 100644 index 0000000..53c1250 --- /dev/null +++ b/code_study/Baekjoon/swift/16236.swift @@ -0,0 +1,107 @@ +struct Node { + var x, y, dist: Int + + init(_ x: Int, _ y: Int, _ dist: Int) { + self.x = x + self.y = y + self.dist = dist + } +} + +struct Deque { + var enqueue: [Node] = [] + var dequeue: [Node] = [] + + func isEmpty() -> Bool { + return enqueue.isEmpty && dequeue.isEmpty + } + + mutating func push(_ node: Node) { + enqueue.append(node) + } + + mutating func pop() -> Node? { + if dequeue.isEmpty { + dequeue = enqueue.reversed() + enqueue.removeAll() + } + + return dequeue.popLast() + } +} + +func biteFish(of filed: [[Int]], _ shark: (x: Int, y: Int, size: Int)) -> Node? { + let N = filed.count + var visited = Array(repeating: Array(repeating: false, count: N), count: N) + var qu = Deque() + visited[shark.y][shark.x] = true + qu.push(Node(shark.x, shark.y, 0)) + + var result: [Node] = [] + + while !qu.isEmpty() { + if let current = qu.pop() { + let cx = current.x + let cy = current.y + let cd = current.dist + + if filed[cy][cx] != 0 && filed[cy][cx] < shark.size { + result.append(Node(cx, cy, cd)) + } + + for (nx, ny) in [(cx, cy-1), (cx-1, cy), (cx+1, cy), (cx, cy+1)] { + if 0<=nx && nx