목록Problem Solving (223)
Life Engineering
https://www.acmicpc.net/problem/17779 17779번: 게리맨더링 2 재현시의 시장 구재현은 지난 몇 년간 게리맨더링을 통해서 자신의 당에게 유리하게 선거구를 획정했다. 견제할 권력이 없어진 구재현은 권력을 매우 부당하게 행사했고, 심지어는 시의 이름 www.acmicpc.net #include #include #include #include #include using namespace std; int N; int A[21][21]; int ans = 987654321; int graph[21][21]; //x,y,d1,d2 가능한 조건인지 체크 bool isPossible(int x, int y, int d1, int d2) { if (x + d1 + d2 > N) { ret..
https://programmers.co.kr/learn/courses/30/lessons/43164 코딩테스트 연습 - 여행경로 [["ICN", "SFO"], ["ICN", "ATL"], ["SFO", "ATL"], ["ATL", "ICN"], ["ATL","SFO"]] ["ICN", "ATL", "ICN", "SFO", "ATL", "SFO"] programmers.co.kr from collections import defaultdict, deque def solution(tickets): answer = [] neighbors=defaultdict(list) for start, end in tickets: neighbors[start].append(end) q=deque() q.append((["..
https://programmers.co.kr/learn/courses/30/lessons/86971?language=python3 코딩테스트 연습 - 9주차_전력망을 둘로 나누기 9 [[1,3],[2,3],[3,4],[4,5],[4,6],[4,7],[7,8],[7,9]] 3 7 [[1,2],[2,7],[3,7],[3,4],[4,5],[6,7]] 1 programmers.co.kr adj=[[] for _ in range(101)] visit=[] def dfs(i): visit[i]=True; for t in adj[i]: if not visit[t]: dfs(t) def check(n, visit): cnt=0 for i in range(1,n+1): if visit[i]: cnt+=1 return ..
https://programmers.co.kr/learn/courses/30/lessons/42577 코딩테스트 연습 - 전화번호 목록 전화번호부에 적힌 전화번호 중, 한 번호가 다른 번호의 접두어인 경우가 있는지 확인하려 합니다. 전화번호가 다음과 같을 경우, 구조대 전화번호는 영석이의 전화번호의 접두사입니다. 구조 programmers.co.kr #include #include #include #include using namespace std; struct { bool operator()(string &first, string &second){ return first.size() < second.size(); } } cmp; bool solution(vector phone_book) { bool a..