import sys import typing def main(): undergoes_debugging: bool = len(sys.argv) > 1 and sys.argv[1] == "debugging" input_stream: typing.IO = open("input.txt", "r") if undergoes_debugging else sys.stdin solve(input_stream) if undergoes_debugging: input_stream.close() def solve(input_stream: typing.IO) -> None: n = int(input_stream.readline()) qualified = [] contestant_index = 1 while True: s, _ = input_stream.readline().split() if s == "TAK": qualified.append(contestant_index) contestant_index += 1 if len(qualified) == 10: break while True: s, x = input_stream.readline().split() x = int(x) if s == "TAK" and x < 2: qualified.append(contestant_index) contestant_index += 1 if len(qualified) == 20: break print(*qualified) if __name__ == '__main__': main()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | import sys import typing def main(): undergoes_debugging: bool = len(sys.argv) > 1 and sys.argv[1] == "debugging" input_stream: typing.IO = open("input.txt", "r") if undergoes_debugging else sys.stdin solve(input_stream) if undergoes_debugging: input_stream.close() def solve(input_stream: typing.IO) -> None: n = int(input_stream.readline()) qualified = [] contestant_index = 1 while True: s, _ = input_stream.readline().split() if s == "TAK": qualified.append(contestant_index) contestant_index += 1 if len(qualified) == 10: break while True: s, x = input_stream.readline().split() x = int(x) if s == "TAK" and x < 2: qualified.append(contestant_index) contestant_index += 1 if len(qualified) == 20: break print(*qualified) if __name__ == '__main__': main() |