전체 글

전체 글

    전구와 스위치 풀이

    문제 링크: https://www.acmicpc.net/problem/2138 백준 알고리즘 중급 1/3 710에서 5번째 - 2138번 전구와 스위치를 풀어보았다. 풀이: https://dogsavestheworld.tistory.com/137 C++ Python n=int(input()) b=list(map(int, input())) target=list(map(int, input())) def change(A, B): L = A[:] press = 0 for i in range(1, n): if L[i-1] == B[i-1]: continue press += 1 for j in range(i-1, i+2): if j

    행렬 풀이

    문제 링크: https://www.acmicpc.net/problem/1080 백준 알고리즘 중급 1/3 710에서 4번째 - 1080번 행렬을 풀어보았다. 풀이: https://jokerldg.github.io/algorithm/2021/03/14/matrix.html C++ Python def reverse(x, y): for i in range(x, x+3): for j in range(y, y+3): A[i][j] = 1 - A[i][j] def check(): for i in range(N): for j in range(M): if A[i][j] != B[i][j]: return False return True N, M = map(int, input().split()) A = [list(map(..

    ATM 풀이

    문제 링크: https://www.acmicpc.net/problem/11399 백준 알고리즘 중급 1/3 710에서 3번째 - 11399번 ATM를 풀어보았다. 풀이: https://puleugo.tistory.com/24 C++ Python n=int(input()) p=list(map(int,input().split())) p.sort() answer=0 for x in range(1,n+1): answer += sum(p[0:x]) print(answer) Java

    회의실 배정 풀이

    문제 링크: https://www.acmicpc.net/problem/1931 백준 알고리즘 중급 1/3 710에서 2번째 - 1931번 회의실 배정을 풀어보았다. 풀이: https://jokerldg.github.io/algorithm/2021/03/11/meeting-room.html C++ Python n=int(input()) time=[] for _ in range(n): st,end=map(int,input().split()) time.append([st,end]) time = sorted(time, key=lambda a: a[0]) time = sorted(time, key=lambda a: a[1]) last = 0 conut = 0 for i, j in time: if i >= last..

    동전 0 풀이

    문제 링크: https://www.acmicpc.net/problem/11047 백준 알고리즘 중급 1/3 710에서 1번째 - 11047번 동전 0을 풀어보았다. 풀이: https://puleugo.tistory.com/20 C++ Python n,k=map(int,input().split()) coins = [] for _ in range(n): coins.append(int(input())) coins.sort(reverse=True) answer = 0 for coin in coins: if k >= coin: answer += k // coin k %= coin if k

    4연산 풀이

    문제 링크: https://www.acmicpc.net/problem/14395 백준 알고리즘 중급 1/3 611에서 16번째 - 14395번 4연산을 풀어보았다. 풀이: https://dalseoin.tistory.com/entry/%EB%B0%B1%EC%A4%80-14395-4%EC%97%B0%EC%82%B0 C++ Python import collections import math s,t = map(int,input().split()) if s == t: print(0) elif t == 1: print('/') else: visited = set() q = collections.deque() q.append((s, '')) while q: tmp, tmp_method = q.popleft() if..

    적록색약 풀이

    문제 링크: https://www.acmicpc.net/problem/10026 백준 알고리즘 중급 1/3 611에서 15번째 - 10026번 적록색약을 풀어보았다. 풀이: https://velog.io/@uoayop/BOJ-10026-%EC%A0%81%EB%A1%9D%EC%83%89%EC%95%BD-Python C++ Python 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..

    소수 경로 풀이

    문제 링크: https://www.acmicpc.net/problem/1963 백준 알고리즘 중급 1/3 611에서 14번째 - 1963번 소수 경로를 풀어보았다. 풀이: https://cijbest.tistory.com/13 C++ Python import sys, math from collections import deque def findPrime(): for i in range(2, 100): if prime[i] == True: for j in range(2*i, 10000, i): prime[j] = False def bfs(): q = deque() q.append([start, 0]) visited = [0 for i in range(10000)] visited[start] = 1 whil..