Bruteforce

17281번: ⚾ ⚾는 9명으로 이루어진 두 팀이 공격과 수비를 번갈아 하는 게임이다. 하나의 이닝은 공격과 수비로 이루어져 있고, 총 N이닝 동안 게임을 진행해야 한다. 한 이닝에 3아웃이 발생하면 이닝이 종 www.acmicpc.net 코드 from itertools import permutations import sys input = sys.stdin.readline n = int(input()) result = [list(map(int, input().split())) for _ in range(n)] ans = 0 for comb in permutations(range(1, 9), 8): comb = list(comb) order = comb[:3]+[0]+comb[3:] # 타순 score =..
16985번: Maaaaaaaaaze 첫째 줄부터 25줄에 걸쳐 판이 주어진다. 각 판은 5줄에 걸쳐 주어지며 각 줄에는 5개의 숫자가 빈칸을 사이에 두고 주어진다. 0은 참가자가 들어갈 수 없는 칸, 1은 참가자가 들어갈 수 있는 칸을 www.acmicpc.net 코드 from collections import deque from itertools import permutations boards = [[list(map(int, input().split())) for _ in range(5)] for _ in range(5)] ans = 126 def rotate(board): # 판을 시계 방향 회전 new_board = [[0]*5 for _ in range(5)] for i in range(5): ..
21275번: 폰 호석만 만약 문제의 조건에 맞는 X, A, B가 유일하게 존재한다면, X를 십진법으로 표현한 수와 A와 B를 공백으로 나누어 출력하라. 만약 만족하는 경우가 2가지 이상이라면 "Multiple"을, 없다면 "Impossible"을 www.acmicpc.net 코드 a, b = input().split() res = [] for i in range(2, 37): for j in range(2, 37): if i == j: continue try: if int(a, i) == int(b, j): res.append((int(a, i), i, j)) except: pass if len(res) < 1: print("Impossible") elif len(res) == 1: print(*res..
28075번: 스파이 첫째 줄에는 민겸이가 임무를 수행하는 총 일수 $N$과 민겸이가 얻고 싶은 최소 기여도 $M$이 공백으로 구분되어 주어진다. 둘째 줄에 민겸이가 정보 수집 임무를 수족관, 시청, 학교에서 수행했 www.acmicpc.net 코드 n, m = map(int, input().split()) progress = list(map(int, input().split()))+list(map(int, input().split())) ans = 0 def recursion(d, prev, total): global ans if d == n+1: if total >= m: ans += 1 return for work in range(2): for place in range(3): if place ==..
19699번: 소-난다! 지난 번 헛간 청약의 당첨우(牛)가 발표됐다. 청약에 당첨된 소들은 날아갈 듯이 기뻐하다가 진짜로 하늘을 날았다. 하지만 이후로 소들은 날 수 없었다. 그러던 어느 날, 꿀벌에게 쏘이면 잠깐 www.acmicpc.net 코드 from itertools import combinations n, m = map(int, input().split()) h = list(map(int, input().split())) prime = [True]*10000 for i in range(2, 10000): if prime[i]: for j in range(i*2, 10000, i): prime[j] = False ans = set() for comb in combinations(range(n),..
딜레이레이
'Bruteforce' 태그의 글 목록 (3 Page)