def solution(idx): count = util.int_input() sequences = [] for _ in range(0, count * 2 - 1): sequence = map(int, util.list_input()) sequences.append(sequence) grid = Grid.solve(sequences) sol = grid.populate_missed() util.print_case(idx, ' '.join(map(str, sol)))
def solution(idx): count = util.int_input() rels = map(int, util.list_input()) assert count == len(rels) circle = Circle(count) for i, rel in enumerate(rels): # #print i, rel - 1 circle.put_rel(i, rel) for i, person in enumerate(circle.people): pass #print i, person sol = circle.search() util.print_case(idx, sol)
def linear_search(digit, count): indigit = digit - 2 solutions = [] for i in range(0, 2**indigit): i_bin = bin(i)[2:] padded = ('0' * indigit) + i_bin str_coin = '1' + padded[-indigit:] + '1' assert len(str_coin) == digit coin = JamCoin.from_str(str_coin) divisors = coin.validate() if divisors: solutions.append((coin, divisors)) if len(solutions) >= count: break return solutions def solution(idx): N, J = map(int, util.list_input()) util.print_case(idx, '') answers = linear_search(N, J) assert len(answers) == J for coin, divisors in answers: print coin, ' '.join(map(str, divisors)) if __name__ == '__main__': count = util.int_input() util.loop(count, solution) Status API Training Shop Blog About
factors = reduce(lambda a, b: a + b, factorss, []) return set(range(0, self.sequence_size)) == set(factors) def humanize(x): return map(lambda e: e + 1, x) def machinize(x): return map(lambda e: e - 1, x) def solution(idx): K, C, S = map(int, util.list_input()) sequence_size = K complexity = C tester_count = S # K진수의 C자리 숫자(0이 패딩)에서 모든 수를 뽑는 문제와 같음 # 한번에 C자리 뽑을 수 있으므로 C*S가 K보다 작으면 망함 f = Fractal(sequence_size, complexity) indexset = humanize(f.search_indexset()) if len(indexset) > tester_count: util.print_case(idx, 'IMPOSSIBLE') else: util.print_case(idx, ' '.join(map(str, indexset))) if __name__ == '__main__': count = util.int_input() # float_input, list_input util.loop(count, solution)
sequences.sort() for sequence in sequences: self.put(sequence) @classmethod def solve(self, sequences): while True: grid = Grid(count) grid.put_sequences(sequences) try: grid.populate_missed() except AssertionError: raise else: return grid def solution(idx): count = util.int_input() sequences = [] for _ in range(0, count * 2 - 1): sequence = map(int, util.list_input()) sequences.append(sequence) grid = Grid.solve(sequences) sol = grid.populate_missed() util.print_case(idx, ' '.join(map(str, sol))) if __name__ == '__main__': count = util.int_input() # float_input, list_input util.loop(count, solution)
def linear_search(digit, count): indigit = digit - 2 solutions = [] for i in range(0, 2**indigit): i_bin = bin(i)[2:] padded = ('0' * indigit) + i_bin str_coin = '1' + padded[-indigit:] + '1' assert len(str_coin) == digit coin = JamCoin.from_str(str_coin) divisors = coin.validate() if divisors: solutions.append((coin, divisors)) if len(solutions) >= count: break return solutions def solution(idx): N, J = map(int, util.list_input()) # float_input, list_input util.print_case(idx, '') answers = linear_search(N, J) assert len(answers) == J for coin, divisors in answers: print coin, ' '.join(map(str, divisors)) if __name__ == '__main__': count = util.int_input() util.loop(count, solution)