https://www.acmicpc.net/problem/9996코드 (정규표현식)import ren = int(input())pattern = re.compile("^"+input().replace("*", "[a-z]*")+"$")for _ in range(n): string = input() if pattern.match(string): print("DA") else: print("NE") 입력된 패턴을 정규표현식으로 바꾸고, 이를 이용해서 매치되는 문자열은 "DA"(YES), 매치되지 않는 문자열은 "NE"(NO)를 출력한다. 예를 들어, `h*d`가 입력된다고 했을 때, 정규표현식으로 바꾸면 다음과 같다. `^h[a-z]*d$` - `^`: 패턴의 처음을..
전체 글
https://www.acmicpc.net/problem/1248코드n = int(input())input_data = "_"+input()sign_sequence = [[None]*(n+1) for _ in range(n+1)]idx = 1for i in range(1, n+1): for j in range(i, n+1): sign_sequence[i][j] = input_data[idx] idx += 1def bt(idx, arr, acc): if idx == n+1: print(*arr[1:]) exit() for new_num in range(-10, 11): new_acc = acc[-1]+new_num ..

https://www.acmicpc.net/problem/17615 코드 (100점)import sysinput = sys.stdin.readlinen = int(input().strip())balls = input().strip()red_right = (balls.rstrip('R')).count('R')red_left = (balls.lstrip('R')).count('R')blue_right = (balls.rstrip('B')).count('B')blue_left = (balls.lstrip('B')).count('B')print(min([red_right, red_left, blue_left, blue_right])) 빨간색과 파란색이 각각 왼쪽으로 몰았을 때와 오른쪽으로 몰았을 때의 이동 횟수..
https://www.acmicpc.net/problem/13397코드import sysinput = sys.stdin.readlinen, m = map(int, input().split())arr = list(map(int, input().split()))def count_section(target): max_value = min_value = arr[0] cnt = 1 for i in range(1, n): if max_value arr[i]: min_value = arr[i] if max_value - min_value > target: cnt += 1 max_value = min_value = a..
https://www.acmicpc.net/problem/11085코드from heapq import heappop, heappushimport sysinput = sys.stdin.readlinep, w = map(int, input().split())c, v = map(int, input().split())parent = [i for i in range(p)]def find_parent(x): if x != parent[x]: parent[x] = find_parent(parent[x]) return parent[x]def union(a, b): a = find_parent(a) b = find_parent(b) if a == b: return ..
https://www.acmicpc.net/problem/13335코드const fs = require("fs");const filePath = process.platform === "linux" ? "dev/stdin" : "./input.txt";const [n, w, l, ...arr] = fs .readFileSync(filePath) .toString() .trim() .split(/\s/) .filter((item) => item != "") .map((item) => +item);class TruckNode { constructor(weight) { this.next = null; this.weight = weight; this.dist = 0; }}class ..