코테 대비 python
-
15657 n과 m (8)코테 대비 python/백준 2023. 5. 3. 13:40
https://www.acmicpc.net/problem/15657 15657번: N과 M (8) N개의 자연수와 자연수 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. N개의 자연수는 모두 다른 수이다. N개의 자연수 중에서 M개를 고른 수열 www.acmicpc.net n,m=map(int,input().split()) numlist = list(map(int,input().split())) #즉 리스트 안에 있는거 중 길이가 m개인 수열을 모두 구하라 #오름차순으로 만들고 numlist.sort() result=[] cnt=0 def back(start): global cnt if cnt==m: print(' '.join(map(str,result))..
-
백준 2615 오목코테 대비 python/백준 2023. 4. 21. 16:28
https://www.acmicpc.net/problem/2615 2615번: 오목 오목은 바둑판에 검은 바둑알과 흰 바둑알을 교대로 놓아서 겨루는 게임이다. 바둑판에는 19개의 가로줄과 19개의 세로줄이 그려져 있는데 가로줄은 위에서부터 아래로 1번, 2번, ... ,19번의 번호 www.acmicpc.net ##다섯알을 먼저 놓으면 이김 그러나 6알은 안댐 #검은색이 이겼을 경우1 흰색 2 승부가 결정 안났으면 0 #무식하게 다찾으면 된다 단 가로 세로 대각선(우하, 좌하) #어짜피 출력하는건 맨처음 좌표값이므로 2중 포문으로 구현 from collections import deque #우선 입력 받자 graph = [list(map(int,input().split())) for _ in range(..
-
[복습] 14502 연구소코테 대비 python/백준 2023. 4. 17. 22:30
from collections import deque n,m = map(int,input().split()) graph=[list(map(int,input().split())) for _ in range(n)] #빈칸 위치 체크 blank=[] virus=[] for i in range(n): for j in range(m): if graph[i][j]==0: blank.append((i,j)) elif graph[i][j]==2: virus.append((i,j)) #상하좌우 dx=[-1,1,0,0] dy=[0,0,-1,1] result=0 def bfs(): global result cnt = len(blank)-3 q=deque(virus) while q: x,y=q.popleft() for i i..
-
18115 카드 놓기코테 대비 python/백준 2023. 4. 16. 22:33
https://www.acmicpc.net/problem/18115 18115번: 카드 놓기 수현이는 카드 기술을 연습하고 있다. 수현이의 손에 들린 카드를 하나씩 내려놓아 바닥에 쌓으려고 한다. 수현이가 쓸 수 있는 기술은 다음 3가지다. 제일 위의 카드 1장을 바닥에 내려놓는다. www.acmicpc.net 시간초과 풀이 #####시간초과 풀이 ###### ##1. popleft() ##2. popleft() popleft() insert() ##3. pop() from collections import deque import sys input=sys.stdin.readline n=int(input()) card=list(map(int,input().split())) q=deque([0]*n) for..
-
2580 스도쿠코테 대비 python/백준 2023. 4. 14. 16:16
https://www.acmicpc.net/problem/2580 2580번: 스도쿠 스도쿠는 18세기 스위스 수학자가 만든 '라틴 사각형'이랑 퍼즐에서 유래한 것으로 현재 많은 인기를 누리고 있다. 이 게임은 아래 그림과 같이 가로, 세로 각각 9개씩 총 81개의 작은 칸으로 이루 www.acmicpc.net graph=[list(map(int,input().split())) for _ in range(9)] loc=[] for i in range(9): for j in range(9): if graph[i][j]==0: loc.append((i,j)) ##가로 체크 def row(cnt,x): for i in range(9): if graph[x][i]==cnt: return False return ..
-
복습 1935 후위 표기식2코테 대비 python/백준 2023. 4. 14. 15:02
https://www.acmicpc.net/problem/1935 1935번: 후위 표기식2 첫째 줄에 피연산자의 개수(1 ≤ N ≤ 26) 가 주어진다. 그리고 둘째 줄에는 후위 표기식이 주어진다. (여기서 피연산자는 A~Z의 영대문자이며, A부터 순서대로 N개의 영대문자만이 사용되며, 길이 www.acmicpc.net 언제나 그렇듯 핵심은 자료구조를 사용하여 요구하는 것을 구현할 수 있는가?? 사용한것 key-value 스택자료구조 출력시 f 사용 ==> 맨날까먹어ㅜㅜ n=int(input()) a=list(input()) val=dict() alpa="ABCDEFGHIJKLMNOPQRSTUVWXYZ" cal=[] result=0 for i in range(n): val[alpa[i]]=int(inp..