output_description
stringlengths
15
956
submission_id
stringlengths
10
10
status
stringclasses
3 values
problem_id
stringlengths
6
6
input_description
stringlengths
9
2.55k
attempt
stringlengths
1
13.7k
problem_description
stringlengths
7
5.24k
samples
stringlengths
2
2.72k
Print the number of the sets of bowls of ramen that satisfy the conditions, disregarding order, modulo M. * * *
s250502717
Wrong Answer
p03375
Input is given from Standard Input in the following format: N M
import sys input = sys.stdin.readline import numpy as np N, MOD = map(int, input().split()) """ 余事象を調べる。包除の原理を使う。 A[n] = (1,2,...,n)が1杯以下、他は何でも良い B[n,l] : (1,2,...,n) をlグループに分ける方法の個数 A[n] ・0杯のグループあり ・なし """ B = np.zeros((N + 1, N + 1), dtype=np.int64) B[0, 0] = 1 for n in range(1, N + 1): # 1番を単独で使う B[n, 1:] = B[n - 1, :-1] # 1番をどこかに混ぜてもらう B[n, 1:] += B[n - 1, 1:] * np.arange(1, N + 1) % MOD B[n] %= MOD # 2^{kl} pow_2 = np.ones((N + 1, N + 1), dtype=np.int64) for n in range(1, N + 1): pow_2[1, n] = 2 * pow_2[1, n - 1] % MOD for n in range(2, N + 1): pow_2[n] = pow_2[n - 1] * pow_2[1] % MOD A = np.zeros(N + 1, dtype=np.int64) for n in range(N + 1): A[n] = ( pow(2, pow(2, N - n, MOD - 1), MOD) * B[n, 1:] % MOD * (pow_2[N - n, 1:] + pow_2[N - n, :-1] * np.arange(1, N + 1) % MOD) % MOD ).sum() % MOD comb = np.zeros((N + 1, N + 1), dtype=np.int64) comb[:, 0] = 1 for n in range(1, N + 1): comb[n, 1:] = (comb[n - 1, 1:] + comb[n - 1, :-1]) % MOD A[::2] *= -1 A *= comb[N] answer = pow(2, pow(2, N, MOD - 1), MOD) - A.sum() answer %= MOD print(answer)
Statement In "Takahashi-ya", a ramen restaurant, basically they have one menu: "ramen", but N kinds of toppings are also offered. When a customer orders a bowl of ramen, for each kind of topping, he/she can choose whether to put it on top of his/her ramen or not. There is no limit on the number of toppings, and it is allowed to have all kinds of toppings or no topping at all. That is, considering the combination of the toppings, 2^N types of ramen can be ordered. Akaki entered Takahashi-ya. She is thinking of ordering some bowls of ramen that satisfy both of the following two conditions: * Do not order multiple bowls of ramen with the exactly same set of toppings. * Each of the N kinds of toppings is on two or more bowls of ramen ordered. You are given N and a prime number M. Find the number of the sets of bowls of ramen that satisfy these conditions, disregarding order, modulo M. Since she is in extreme hunger, ordering any number of bowls of ramen is fine.
[{"input": "2 1000000007", "output": "2\n \n\nLet the two kinds of toppings be A and B. Four types of ramen can be ordered:\n\"no toppings\", \"with A\", \"with B\" and \"with A, B\". There are two sets of ramen\nthat satisfy the conditions:\n\n * The following three ramen: \"with A\", \"with B\", \"with A, B\".\n * Four ramen, one for each type.\n\n* * *"}, {"input": "3 1000000009", "output": "118\n \n\nLet the three kinds of toppings be A, B and C. In addition to the four types\nof ramen above, four more types of ramen can be ordered, where C is added to\nthe above four. There are 118 sets of ramen that satisfy the conditions, and\nhere are some of them:\n\n * The following three ramen: \"with A, B\", \"with A, C\", \"with B, C\".\n * The following five ramen: \"no toppings\", \"with A\", \"with A, B\", \"with B, C\", \"with A, B, C\".\n * Eight ramen, one for each type.\n\nNote that the set of the following three does not satisfy the condition:\n\"'with A', 'with B', 'with A, B'\", because C is not on any of them.\n\n* * *"}, {"input": "50 111111113", "output": "1456748\n \n\nRemember to print the number of the sets modulo M. Note that these three\nsample inputs above are included in the test set for the partial score.\n\n* * *"}, {"input": "3000 123456791", "output": "16369789\n \n\nThis sample input is not included in the test set for the partial score."}]
Print the number of the sets of bowls of ramen that satisfy the conditions, disregarding order, modulo M. * * *
s087051639
Wrong Answer
p03375
Input is given from Standard Input in the following format: N M
n, m = map(int, input().split()) MOD = m list_size = 10000 f_list = [1] * list_size f_r_list = [1] * list_size for i in range(list_size - 1): f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD) f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD) for i in range(2, list_size + 1): f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % MOD) def comb(N, r): if N < r: return 0 elif N == 0 or r == 0 or N == r: return 1 else: return (((f_list[N - 1] * f_r_list[N - r - 1]) % MOD) * f_r_list[r - 1]) % MOD st = [[0 for _ in range(n + 1)] for _ in range(n + 1)] st[0][0] = 1 for i in range(1, n + 1): st[i][0] = 1 for j in range(1, i + 1): st[i][j] = (st[i - 1][j - 1] + (j + 1) * st[i - 1][j]) % MOD ans = 0 for i in range(n + 1): res = (comb(n, i) * pow(2, pow(2, n - i, MOD), MOD)) % MOD # print(res) tmp = 0 for j in range(i + 1): tmp += st[i][j] * pow(2, (n - i) * j, MOD) tmp %= MOD res *= tmp res %= MOD if i % 2 == 0: ans += res else: ans -= res ans %= MOD print(ans)
Statement In "Takahashi-ya", a ramen restaurant, basically they have one menu: "ramen", but N kinds of toppings are also offered. When a customer orders a bowl of ramen, for each kind of topping, he/she can choose whether to put it on top of his/her ramen or not. There is no limit on the number of toppings, and it is allowed to have all kinds of toppings or no topping at all. That is, considering the combination of the toppings, 2^N types of ramen can be ordered. Akaki entered Takahashi-ya. She is thinking of ordering some bowls of ramen that satisfy both of the following two conditions: * Do not order multiple bowls of ramen with the exactly same set of toppings. * Each of the N kinds of toppings is on two or more bowls of ramen ordered. You are given N and a prime number M. Find the number of the sets of bowls of ramen that satisfy these conditions, disregarding order, modulo M. Since she is in extreme hunger, ordering any number of bowls of ramen is fine.
[{"input": "2 1000000007", "output": "2\n \n\nLet the two kinds of toppings be A and B. Four types of ramen can be ordered:\n\"no toppings\", \"with A\", \"with B\" and \"with A, B\". There are two sets of ramen\nthat satisfy the conditions:\n\n * The following three ramen: \"with A\", \"with B\", \"with A, B\".\n * Four ramen, one for each type.\n\n* * *"}, {"input": "3 1000000009", "output": "118\n \n\nLet the three kinds of toppings be A, B and C. In addition to the four types\nof ramen above, four more types of ramen can be ordered, where C is added to\nthe above four. There are 118 sets of ramen that satisfy the conditions, and\nhere are some of them:\n\n * The following three ramen: \"with A, B\", \"with A, C\", \"with B, C\".\n * The following five ramen: \"no toppings\", \"with A\", \"with A, B\", \"with B, C\", \"with A, B, C\".\n * Eight ramen, one for each type.\n\nNote that the set of the following three does not satisfy the condition:\n\"'with A', 'with B', 'with A, B'\", because C is not on any of them.\n\n* * *"}, {"input": "50 111111113", "output": "1456748\n \n\nRemember to print the number of the sets modulo M. Note that these three\nsample inputs above are included in the test set for the partial score.\n\n* * *"}, {"input": "3000 123456791", "output": "16369789\n \n\nThis sample input is not included in the test set for the partial score."}]
For each datasets, prints the result of calculation.
s827224095
Runtime Error
p00109
The input is a sequence of datasets. The first line contains an integer _n_ which represents the number of datasets. There will be _n_ lines where each line contains an expression.
def f1(line): p = None q = None for i, s in enumerate(line): if s == "(": p = i elif s == ")": q = i if q: break else: return f2(line) before = line[:p] after = line[q + 1 :] x = f2(line[p + 1 : q]) return f1(before + str(x) + after) def f2(f_line): foo = [] digit = "" for x in f_line: if x.isdigit(): digit += x else: foo.append(int(digit)) foo.append(x) digit = "" foo.append(int(digit)) return f3(foo, "first") def f3(foo, flg): if len(foo) == 1: return foo[0] target = None for i, fo in enumerate(foo): if flg == "first": target = f4(foo, fo, i) elif flg == "second": target = f5(foo, fo, i) if target: break else: flg = "second" return f3(foo, flg) foo = foo[: i - 1] + [target] + foo[i + 2 :] return f3(foo, flg) def f4(foo, fo, i): target = None if fo == "*": target = foo[i - 1] * foo[i + 1] elif fo == "/": target = int(foo[i - 1] / foo[i + 1]) return target def f5(foo, fo, i): target = None if fo == "+": target = foo[i - 1] + foo[i + 1] elif fo == "-": target = int(foo[i - 1] - foo[i + 1]) return target for _ in range(int(input())): ans = f1(input()) print(ans)
Smart Calculator Your task is to write a program which reads an expression and evaluates it. * The expression consists of numerical values, operators and parentheses, and the ends with '='. * The operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division. * Precedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right. * You may assume that there is no division by zero. * All calculation is performed as integers, and after the decimal point should be truncated * Length of the expression will not exceed 100. * -1 × 109 ≤ intermediate results of computation ≤ 109
[{"input": "4-2*3=\n 4*(8+4+3)=", "output": "-2\n 60"}]
For each datasets, prints the result of calculation.
s647801461
Accepted
p00109
The input is a sequence of datasets. The first line contains an integer _n_ which represents the number of datasets. There will be _n_ lines where each line contains an expression.
def solve(s): def expr(l): left, mid = term(l) return edum(mid, left) def edum(l, lval): if s[l] == "+": val, mid = term(l + 1) return edum(mid, lval + val) if s[l] == "-": val, mid = term(l + 1) return edum(mid, lval - val) else: return lval, l def term(l): left, mid = value(l) return tdum(mid, left) def tdum(l, lval): if s[l] == "*": l += 1 val1, mid = value(l) return tdum(mid, lval * val1) if s[l] == "/": l += 1 val1, mid = value(l) return tdum( mid, (abs(lval) // abs(val1)) * (-1 if (lval < 0) ^ (val1 < 0) else 1) ) else: return lval, l def value(l): if s[l] == "(": val1, mid = expr(l + 1) return val1, mid + 1 else: val = 0 fl = s[l] == "-" if fl: l += 1 while s[l].isdecimal(): val *= 10 val += int(s[l]) l += 1 if fl: val *= -1 return val, l res = expr(0)[0] """ gnd = eval(''.join(s[:-1]).replace('/', '//')) while res != gnd: pass """ print(res) def main(): q = int(input()) for _ in range(q): solve(list(input())) if __name__ == "__main__": main()
Smart Calculator Your task is to write a program which reads an expression and evaluates it. * The expression consists of numerical values, operators and parentheses, and the ends with '='. * The operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division. * Precedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right. * You may assume that there is no division by zero. * All calculation is performed as integers, and after the decimal point should be truncated * Length of the expression will not exceed 100. * -1 × 109 ≤ intermediate results of computation ≤ 109
[{"input": "4-2*3=\n 4*(8+4+3)=", "output": "-2\n 60"}]
For each datasets, prints the result of calculation.
s994852280
Accepted
p00109
The input is a sequence of datasets. The first line contains an integer _n_ which represents the number of datasets. There will be _n_ lines where each line contains an expression.
import sys # from me.io import dup_file_stdin def prec(op): if op in "+-": return 1 if op in "*/": return 2 raise NotImplementedError() def postFix(expr): stack = [] operators = [] num = 0 isdigit = False for ch in expr: if ch.isdigit(): isdigit = True num *= 10 num += int(ch) continue else: if isdigit: stack.append(num) num = 0 isdigit = False if ch == ")": while len(operators) > 0: op = operators.pop() if op == "(": break else: stack.append(op) else: raise ValueError elif ch == "(": operators.append(ch) else: while ( len(operators) > 0 and operators[-1] != "(" and prec(operators[-1]) >= prec(ch) ): stack.append(operators.pop()) operators.append(ch) if isdigit: stack.append(num) for op in operators[::-1]: if op not in "()": stack.append(op) return stack def evaluate(stack): op = stack.pop() if type(op) is int: return op else: b = evaluate(stack) a = evaluate(stack) return int(eval(str(a) + op + str(b))) # @dup_file_stdin def solve(): for _ in range(int(sys.stdin.readline())): expr = sys.stdin.readline()[:-1].strip("=") print(evaluate(postFix(expr))) solve()
Smart Calculator Your task is to write a program which reads an expression and evaluates it. * The expression consists of numerical values, operators and parentheses, and the ends with '='. * The operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division. * Precedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right. * You may assume that there is no division by zero. * All calculation is performed as integers, and after the decimal point should be truncated * Length of the expression will not exceed 100. * -1 × 109 ≤ intermediate results of computation ≤ 109
[{"input": "4-2*3=\n 4*(8+4+3)=", "output": "-2\n 60"}]
For each datasets, prints the result of calculation.
s731003221
Wrong Answer
p00109
The input is a sequence of datasets. The first line contains an integer _n_ which represents the number of datasets. There will be _n_ lines where each line contains an expression.
l = [eval(input()[:-1]) for i in range(int(input()))] [print(i) for i in l]
Smart Calculator Your task is to write a program which reads an expression and evaluates it. * The expression consists of numerical values, operators and parentheses, and the ends with '='. * The operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division. * Precedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right. * You may assume that there is no division by zero. * All calculation is performed as integers, and after the decimal point should be truncated * Length of the expression will not exceed 100. * -1 × 109 ≤ intermediate results of computation ≤ 109
[{"input": "4-2*3=\n 4*(8+4+3)=", "output": "-2\n 60"}]
For each datasets, prints the result of calculation.
s831225620
Wrong Answer
p00109
The input is a sequence of datasets. The first line contains an integer _n_ which represents the number of datasets. There will be _n_ lines where each line contains an expression.
[print(int(eval(input()[:-1]))) for _ in range(int(input()))]
Smart Calculator Your task is to write a program which reads an expression and evaluates it. * The expression consists of numerical values, operators and parentheses, and the ends with '='. * The operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division. * Precedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right. * You may assume that there is no division by zero. * All calculation is performed as integers, and after the decimal point should be truncated * Length of the expression will not exceed 100. * -1 × 109 ≤ intermediate results of computation ≤ 109
[{"input": "4-2*3=\n 4*(8+4+3)=", "output": "-2\n 60"}]
For each datasets, prints the result of calculation.
s797230481
Wrong Answer
p00109
The input is a sequence of datasets. The first line contains an integer _n_ which represents the number of datasets. There will be _n_ lines where each line contains an expression.
N = int(input()) for i in range(N): print(eval(input().strip("=")))
Smart Calculator Your task is to write a program which reads an expression and evaluates it. * The expression consists of numerical values, operators and parentheses, and the ends with '='. * The operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division. * Precedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right. * You may assume that there is no division by zero. * All calculation is performed as integers, and after the decimal point should be truncated * Length of the expression will not exceed 100. * -1 × 109 ≤ intermediate results of computation ≤ 109
[{"input": "4-2*3=\n 4*(8+4+3)=", "output": "-2\n 60"}]
For each datasets, prints the result of calculation.
s679905832
Wrong Answer
p00109
The input is a sequence of datasets. The first line contains an integer _n_ which represents the number of datasets. There will be _n_ lines where each line contains an expression.
[print(eval(input()[:-1].replace("/", "//"))) for i in range(int(input()))]
Smart Calculator Your task is to write a program which reads an expression and evaluates it. * The expression consists of numerical values, operators and parentheses, and the ends with '='. * The operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division. * Precedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right. * You may assume that there is no division by zero. * All calculation is performed as integers, and after the decimal point should be truncated * Length of the expression will not exceed 100. * -1 × 109 ≤ intermediate results of computation ≤ 109
[{"input": "4-2*3=\n 4*(8+4+3)=", "output": "-2\n 60"}]
For each datasets, prints the result of calculation.
s834005574
Wrong Answer
p00109
The input is a sequence of datasets. The first line contains an integer _n_ which represents the number of datasets. There will be _n_ lines where each line contains an expression.
r = [eval(input()[:-1].replace("/", "//")) for i in range(int(input()))] [print(i) for i in r]
Smart Calculator Your task is to write a program which reads an expression and evaluates it. * The expression consists of numerical values, operators and parentheses, and the ends with '='. * The operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division. * Precedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right. * You may assume that there is no division by zero. * All calculation is performed as integers, and after the decimal point should be truncated * Length of the expression will not exceed 100. * -1 × 109 ≤ intermediate results of computation ≤ 109
[{"input": "4-2*3=\n 4*(8+4+3)=", "output": "-2\n 60"}]
For each datasets, prints the result of calculation.
s235594179
Wrong Answer
p00109
The input is a sequence of datasets. The first line contains an integer _n_ which represents the number of datasets. There will be _n_ lines where each line contains an expression.
def get_input(): while True: try: yield "".join(input()) except EOFError: break N = int(input()) for l in range(N): S = input() if S == "exit": break S = S[0 : len(S) - 1] print(eval(S))
Smart Calculator Your task is to write a program which reads an expression and evaluates it. * The expression consists of numerical values, operators and parentheses, and the ends with '='. * The operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division. * Precedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right. * You may assume that there is no division by zero. * All calculation is performed as integers, and after the decimal point should be truncated * Length of the expression will not exceed 100. * -1 × 109 ≤ intermediate results of computation ≤ 109
[{"input": "4-2*3=\n 4*(8+4+3)=", "output": "-2\n 60"}]
For each datasets, prints the result of calculation.
s395728278
Accepted
p00109
The input is a sequence of datasets. The first line contains an integer _n_ which represents the number of datasets. There will be _n_ lines where each line contains an expression.
# -*- coding: utf-8 -*- """ 所要時間は、分位であった。 """ # ライブラリのインポート # import re import sys input = sys.stdin.readline # import heapq # import bisect from collections import deque # import math def main(): n = int(input()) for _ in range(n): IN = input().strip() exp1 = calcmold(IN) exp2 = calc1(exp1) exp3 = calcmult(exp2) print(calcplus(exp3)) def calcmold(exp): # seikei tmp = "" EXP = deque() oplist = ["+", "-", "*", "/", "(", ")", "="] for i in range(len(exp)): if exp[i] not in oplist: tmp += exp[i] else: if tmp == "": EXP.append(exp[i]) continue EXP.append(int(tmp)) EXP.append(exp[i]) tmp = "" return EXP def calc1(IN): # calculate() EXP = deque() while IN: check = IN.popleft() if check == ")": TMP = deque() while 1: look = EXP.pop() if look == "(": break TMP.appendleft(look) TMP.append("=") EXP.append(calcplus(calcmult(TMP))) else: EXP.append(check) return EXP def calcmult(exp): # no() EXP = deque() while exp: check = exp.popleft() if check == "*": arg1 = EXP.pop() arg2 = exp.popleft() EXP.append(arg1 * arg2) elif check == "/": arg1 = EXP.pop() arg2 = exp.popleft() EXP.append(int(arg1 / arg2)) else: EXP.append(check) return EXP def calcplus(exp): # no() EXP = deque() while exp: check = exp.popleft() if check == "+": arg1 = EXP.pop() arg2 = exp.popleft() EXP.append(arg1 + arg2) elif check == "-": arg1 = EXP.pop() arg2 = exp.popleft() EXP.append(arg1 - arg2) elif check == "=": return EXP.pop() else: EXP.append(check) return EXP if __name__ == "__main__": main()
Smart Calculator Your task is to write a program which reads an expression and evaluates it. * The expression consists of numerical values, operators and parentheses, and the ends with '='. * The operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division. * Precedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right. * You may assume that there is no division by zero. * All calculation is performed as integers, and after the decimal point should be truncated * Length of the expression will not exceed 100. * -1 × 109 ≤ intermediate results of computation ≤ 109
[{"input": "4-2*3=\n 4*(8+4+3)=", "output": "-2\n 60"}]
For each datasets, prints the result of calculation.
s323764589
Wrong Answer
p00109
The input is a sequence of datasets. The first line contains an integer _n_ which represents the number of datasets. There will be _n_ lines where each line contains an expression.
[print(eval(input()[:-1])) for _ in range(int(input()))]
Smart Calculator Your task is to write a program which reads an expression and evaluates it. * The expression consists of numerical values, operators and parentheses, and the ends with '='. * The operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division. * Precedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right. * You may assume that there is no division by zero. * All calculation is performed as integers, and after the decimal point should be truncated * Length of the expression will not exceed 100. * -1 × 109 ≤ intermediate results of computation ≤ 109
[{"input": "4-2*3=\n 4*(8+4+3)=", "output": "-2\n 60"}]
For each datasets, prints the result of calculation.
s895760480
Wrong Answer
p00109
The input is a sequence of datasets. The first line contains an integer _n_ which represents the number of datasets. There will be _n_ lines where each line contains an expression.
while True: try: for i in range(int(input())): print(str(int(eval(input().replace("=", ""))))) except: break
Smart Calculator Your task is to write a program which reads an expression and evaluates it. * The expression consists of numerical values, operators and parentheses, and the ends with '='. * The operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division. * Precedence of the operators is based on usual laws. That is one should perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, they are applied from left to right. * You may assume that there is no division by zero. * All calculation is performed as integers, and after the decimal point should be truncated * Length of the expression will not exceed 100. * -1 × 109 ≤ intermediate results of computation ≤ 109
[{"input": "4-2*3=\n 4*(8+4+3)=", "output": "-2\n 60"}]
Print 1+K lines, where K is the number of strongly connected components. Print K on the first line. Print the information of each strongly connected component in next K lines in the following format, where l is the number of vertices in the strongly connected component and v_i is the index of the vertex in it. l v_0 v_1 ... v_{l-1} Here, for each edge (a_i, b_i), b_i should not appear in **earlier** line than a_i. If there are multiple correct output, print any of them. * * *
s823528932
Wrong Answer
p02564
Input is given from Standard Input in the following format: N M a_0 b_0 a_1 b_1 : a_{M - 1} b_{M - 1}
N, M = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) MOD = 998244353 class Convolution: def __init__(self): self.first = True def _ceil_pow2(self, n): assert n >= 0 x = 0 while (1 << x) < n: x += 1 return x def _bsf(self, n): assert n >= 1 return len(bin(n & -n)) - 3 def _butterfly(self, a, mod): n = len(a) h = self._ceil_pow2(n) self.sum_e = [0] * 30 if self.first: self.first = False es = [0] * 30 ies = [0] * 30 cnt2 = self._bsf(mod - 1) g = 3 # TODO primitive_root ?? e = pow(g, (mod - 1) >> cnt2, mod) ie = pow(e, mod - 2, mod) for i in range(cnt2, 1, -1): es[i - 2] = e ies[i - 2] = ie e *= e e %= mod ie *= ie ie %= mod now = 1 for i in range(cnt2 - 2): self.sum_e[i] = (es[i] * now) % mod now *= ies[i] now %= mod for ph in range(1, h + 1): w = 1 << (ph - 1) p = 1 << (h - ph) now = 1 for s in range(w): offset = s << (h - ph + 1) for i in range(p): l = a[i + offset] r = a[i + offset + p] * now a[i + offset] = (l + r) % mod a[i + offset + p] = (l - r) % mod now *= self.sum_e[self._bsf(((1 << 32) - 1) ^ s)] now %= mod def _butterfly_inv(self, a, mod): n = len(a) h = self._ceil_pow2(n) self.sum_ie = [0] * 30 if self.first: self.first = False es = [0] * 30 ies = [0] * 30 cnt2 = self._bsf(mod - 1) g = 3 # TODO primitive_root ?? e = pow(g, (mod - 1) >> cnt2, mod) ie = pow(e, mod - 2, mod) for i in range(cnt2, 1, -1): es[i - 2] = e ies[i - 2] = ie e *= e e %= mod ie *= ie ie %= mod now = 1 for i in range(cnt2 - 2): self.sum_ie[i] = (ies[i] * now) % mod now *= es[i] now %= mod for ph in range(h, 0, -1): w = 1 << (ph - 1) p = 1 << (h - ph) inow = 1 for s in range(w): offset = s << (h - ph + 1) for i in range(p): l = a[i + offset] r = a[i + offset + p] a[i + offset] = (l + r) % mod a[i + offset + p] = ((l - r) * inow) % mod inow *= self.sum_ie[self._bsf(((1 << 32) - 1) ^ s)] inow %= mod def convolution_mod(self, a, b, mod): n, m = len(a), len(b) if n == 0 or m == 0: return [] if min(n, m) <= 60: if n < m: a, b, n, m = b, a, m, n ans = [0] * (n + m - 1) for i in range(n): for j in range(m): ans[i + j] += a[i] * b[j] ans[i + j] %= mod return ans z = 1 << self._ceil_pow2(n + m - 1) a += [0] * (z - n) self._butterfly(a, mod) b += [0] * (z - m) self._butterfly(b, mod) for i in range(z): a[i] *= b[i] a[i] %= mod self._butterfly_inv(a, mod) a = a[: n + m - 1] iz = pow(z, mod - 2, mod) for i in range(n + m - 1): a[i] *= iz a[i] %= mod return a ans = Convolution().convolution_mod(A, B, MOD) print(*ans)
Statement You are given a directed graph with N vertices and M edges, not necessarily simple. The i-th edge is oriented from the vertex a_i to the vertex b_i. Divide this graph into strongly connected components and print them in their topological order.
[{"input": "6 7\n 1 4\n 5 2\n 3 0\n 5 5\n 4 1\n 0 3\n 4 2", "output": "4\n 1 5\n 2 4 1\n 1 2\n 2 3 0"}]
Print 1+K lines, where K is the number of strongly connected components. Print K on the first line. Print the information of each strongly connected component in next K lines in the following format, where l is the number of vertices in the strongly connected component and v_i is the index of the vertex in it. l v_0 v_1 ... v_{l-1} Here, for each edge (a_i, b_i), b_i should not appear in **earlier** line than a_i. If there are multiple correct output, print any of them. * * *
s441747553
Wrong Answer
p02564
Input is given from Standard Input in the following format: N M a_0 b_0 a_1 b_1 : a_{M - 1} b_{M - 1}
import os import sys import numpy as np def solve(inp): def dfs(links, s, checked, postorder): n = len(links) d = 1 while d <= n: d <<= 1 q = [s] checked[s] = 1 while q: v = q.pop() if v < d: q.append(v | d) for u in links[v]: if checked[u] == 0: q.append(u) checked[u] = 1 else: postorder.append(v ^ d) return def dfs2(rev_links, s, checked): q = [s] checked[s] = 1 scc = [s] while q: v = q.pop() for u in rev_links[v]: if checked[u] == 0: q.append(u) checked[u] = 1 scc.append(u) return scc n = inp[0] m = inp[1] aaa = inp[2::2] bbb = inp[3::2] int_list = [0] int_list.clear() links = [int_list.copy() for _ in range(n)] rev_links = [int_list.copy() for _ in range(n)] for i in range(m): a = aaa[i] b = bbb[i] if a != b: links[a].append(b) rev_links[b].append(a) links = [list(set(link)) for link in links] rev_links = [list(set(link)) for link in rev_links] checked = np.zeros(n, np.int8) postorder = [] for v in range(n): if checked[v]: continue dfs(links, v, checked, postorder) postorder.reverse() checked = np.zeros(n, np.int8) sccs = [] for v in postorder: if checked[v]: continue sccs.append(dfs2(rev_links, v, checked)) return sccs if sys.argv[-1] == "ONLINE_JUDGE": from numba.pycc import CC cc = CC("my_module") cc.export("solve", "(i8[:],)")(solve) cc.compile() exit() if os.name == "posix": # noinspection PyUnresolvedReferences from my_module import solve else: from numba import njit solve = njit("(i8[:],)", cache=True)(solve) print("compiled", file=sys.stderr) inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=" ") ans = solve(inp) print(len(ans)) for scc in ans: print(len(scc), *scc)
Statement You are given a directed graph with N vertices and M edges, not necessarily simple. The i-th edge is oriented from the vertex a_i to the vertex b_i. Divide this graph into strongly connected components and print them in their topological order.
[{"input": "6 7\n 1 4\n 5 2\n 3 0\n 5 5\n 4 1\n 0 3\n 4 2", "output": "4\n 1 5\n 2 4 1\n 1 2\n 2 3 0"}]
Print 1+K lines, where K is the number of strongly connected components. Print K on the first line. Print the information of each strongly connected component in next K lines in the following format, where l is the number of vertices in the strongly connected component and v_i is the index of the vertex in it. l v_0 v_1 ... v_{l-1} Here, for each edge (a_i, b_i), b_i should not appear in **earlier** line than a_i. If there are multiple correct output, print any of them. * * *
s135947057
Wrong Answer
p02564
Input is given from Standard Input in the following format: N M a_0 b_0 a_1 b_1 : a_{M - 1} b_{M - 1}
import sys def input(): return sys.stdin.buffer.readline()[:-1] class SCC: def __init__(self, adj): self.n = len(adj) self.adj = adj self.cnt = 0 self.post_order = [-1 for _ in range(self.n)] self.visited = [0 for _ in range(self.n)] self.dag_v_to_num = [-1 for _ in range(self.n)] self.dag_num_to_v = [] self.inv = [[] for _ in range(self.n)] for i, l in enumerate(self.adj): for j in l: self.inv[j].append(i) return def dfs1(self, root): stack = [root] self.visited[root] = 1 while stack: i = stack[-1] if self.visited[i] == 2: self.post_order[self.cnt] = i self.cnt += 1 stack.pop() else: for j in self.adj[i]: if self.visited[j] == 0: self.visited[j] = 1 stack.append(j) self.visited[i] = 2 return def dfs2(self, root, num): stack = [root] self.visited[root] = 1 self.dag_num_to_v.append(list()) while stack: i = stack[-1] if self.visited[i] == 2: self.dag_v_to_num[i] = num self.dag_num_to_v[num].append(i) stack.pop() else: for j in self.inv[i]: if self.visited[j] == 0: self.visited[j] = 1 stack.append(j) self.visited[i] = 2 return def make_scc(self): self.visited = [0 for _ in range(self.n)] for i in range(self.n): if self.visited[i] == 0: self.dfs1(i) self.visited = [0 for _ in range(self.n)] group = 0 for i in range(self.n - 1, -1, -1): if self.visited[self.post_order[i]] == 0: self.dfs2(self.post_order[i], group) group += 1 return self.dag_v_to_num, self.dag_num_to_v n, m = map(int, input().split()) adj = [set() for _ in range(n)] for _ in range(m): u, v = map(int, input().split()) if u != v: adj[u].add(v) adj = [list(x) for x in adj] scc = SCC(adj) v_to_num, num_to_v = scc.make_scc() print(len(num_to_v)) for x in num_to_v: print(len(x), end=" ") print(*x)
Statement You are given a directed graph with N vertices and M edges, not necessarily simple. The i-th edge is oriented from the vertex a_i to the vertex b_i. Divide this graph into strongly connected components and print them in their topological order.
[{"input": "6 7\n 1 4\n 5 2\n 3 0\n 5 5\n 4 1\n 0 3\n 4 2", "output": "4\n 1 5\n 2 4 1\n 1 2\n 2 3 0"}]
Print 1+K lines, where K is the number of strongly connected components. Print K on the first line. Print the information of each strongly connected component in next K lines in the following format, where l is the number of vertices in the strongly connected component and v_i is the index of the vertex in it. l v_0 v_1 ... v_{l-1} Here, for each edge (a_i, b_i), b_i should not appear in **earlier** line than a_i. If there are multiple correct output, print any of them. * * *
s216378653
Runtime Error
p02564
Input is given from Standard Input in the following format: N M a_0 b_0 a_1 b_1 : a_{M - 1} b_{M - 1}
def scc(N, G, RG): order = [] used = [0] * N group = [None] * N def dfs(s): used[s] = 1 for t in G[s]: if not used[t]: dfs(t) order.append(s) def rdfs(s, col): group[s] = col used[s] = 1 for t in RG[s]: if not used[t]: rdfs(t, col) for i in range(N): if not used[i]: dfs(i) used = [0] * N label = 0 for s in reversed(order): if not used[s]: rdfs(s, label) label += 1 return label, group # 縮約後のグラフを構築 def construct(N, G, label, group): G0 = [set() for i in range(label)] GP = [[] for i in range(label)] for v in range(N): lbs = group[v] for w in G[v]: lbt = group[w] if lbs == lbt: continue G0[lbs].add(lbt) GP[lbs].append(v) return G0, GP N, M = list(map(int, input().split())) G = [[] for i in range(N)] RG = [[] for i in range(N)] for i in range(M): A, B = list(map(int, input().split())) G[A].append(B) RG[B].append(A) label, group = scc(N, G, RG) G0, GP = construct(N, G, label, group) print(label) for G in GP: print(len(G), *G)
Statement You are given a directed graph with N vertices and M edges, not necessarily simple. The i-th edge is oriented from the vertex a_i to the vertex b_i. Divide this graph into strongly connected components and print them in their topological order.
[{"input": "6 7\n 1 4\n 5 2\n 3 0\n 5 5\n 4 1\n 0 3\n 4 2", "output": "4\n 1 5\n 2 4 1\n 1 2\n 2 3 0"}]
Print 1+K lines, where K is the number of strongly connected components. Print K on the first line. Print the information of each strongly connected component in next K lines in the following format, where l is the number of vertices in the strongly connected component and v_i is the index of the vertex in it. l v_0 v_1 ... v_{l-1} Here, for each edge (a_i, b_i), b_i should not appear in **earlier** line than a_i. If there are multiple correct output, print any of them. * * *
s881570245
Runtime Error
p02564
Input is given from Standard Input in the following format: N M a_0 b_0 a_1 b_1 : a_{M - 1} b_{M - 1}
from scipy.sparse.csgraph import connected_components from scipy.sparse import csr_matrix N, M, *AB = map(int, open(0).read().split()) G = csr_matrix(([1] * M, (AB[::2], AB[1::2]))) K, labels = connected_components(G, connection="strong") C = [[] for _ in range(K)] for i, l in enumerate(labels): C[l].append(i) print(K) for c in reversed((C)): print(len(c), *c)
Statement You are given a directed graph with N vertices and M edges, not necessarily simple. The i-th edge is oriented from the vertex a_i to the vertex b_i. Divide this graph into strongly connected components and print them in their topological order.
[{"input": "6 7\n 1 4\n 5 2\n 3 0\n 5 5\n 4 1\n 0 3\n 4 2", "output": "4\n 1 5\n 2 4 1\n 1 2\n 2 3 0"}]
Print 1+K lines, where K is the number of strongly connected components. Print K on the first line. Print the information of each strongly connected component in next K lines in the following format, where l is the number of vertices in the strongly connected component and v_i is the index of the vertex in it. l v_0 v_1 ... v_{l-1} Here, for each edge (a_i, b_i), b_i should not appear in **earlier** line than a_i. If there are multiple correct output, print any of them. * * *
s561948216
Accepted
p02564
Input is given from Standard Input in the following format: N M a_0 b_0 a_1 b_1 : a_{M - 1} b_{M - 1}
import sys input = sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): def scc(Edge): N = len(Edge) Edgeinv = [[] for _ in range(N)] for vn in range(N): for vf in Edge[vn]: Edgeinv[vf].append(vn) used = [False] * N dim = [len(Edge[i]) for i in range(N)] order = [] for st in range(N): if not used[st]: stack = [st, 0] while stack: vn, i = stack[-2], stack[-1] if not i and used[vn]: stack.pop() stack.pop() else: used[vn] = True if i < dim[vn]: stack[-1] += 1 stack.append(Edge[vn][i]) stack.append(0) else: stack.pop() order.append(stack.pop()) res = [None] * N used = [False] * N cnt = -1 for st in order[::-1]: if not used[st]: cnt += 1 stack = [st] res[st] = cnt used[st] = True while stack: vn = stack.pop() for vf in Edgeinv[vn]: if not used[vf]: used[vf] = True res[vf] = cnt stack.append(vf) M = cnt + 1 components = [[] for _ in range(M)] for i in range(N): components[res[i]].append(i) return res, components N, M = MI() adj = [[] for _ in range(N)] for i in range(M): a, b = MI() adj[a].append(b) res, compo = scc(adj) M = max(res) + 1 print(M) for i in range(M): length = len(compo[i]) print(" ".join(map(str, [length] + compo[i]))) main()
Statement You are given a directed graph with N vertices and M edges, not necessarily simple. The i-th edge is oriented from the vertex a_i to the vertex b_i. Divide this graph into strongly connected components and print them in their topological order.
[{"input": "6 7\n 1 4\n 5 2\n 3 0\n 5 5\n 4 1\n 0 3\n 4 2", "output": "4\n 1 5\n 2 4 1\n 1 2\n 2 3 0"}]
Print 1+K lines, where K is the number of strongly connected components. Print K on the first line. Print the information of each strongly connected component in next K lines in the following format, where l is the number of vertices in the strongly connected component and v_i is the index of the vertex in it. l v_0 v_1 ... v_{l-1} Here, for each edge (a_i, b_i), b_i should not appear in **earlier** line than a_i. If there are multiple correct output, print any of them. * * *
s747606975
Wrong Answer
p02564
Input is given from Standard Input in the following format: N M a_0 b_0 a_1 b_1 : a_{M - 1} b_{M - 1}
import sys def SCC(G): D = [] U = [1] * len(G) Z = [] for x in range(len(G)): if U[x]: U[x] = 0 Z.append((x, 1)) for i in range(len(G[x])): if U[G[x][i]]: Z.append((G[x][i], 0)) U[G[x][i]] = 0 while len(Z): if Z[-1][1]: D.append(Z[-1][0]) del Z[-1] else: x = Z[-1][0] del Z[-1] Z.append((x, 1)) for i in range(len(G[x])): if U[G[x][i]]: Z.append((G[x][i], 0)) U[G[x][i]] = 0 GR = [[] for i in range(len(G))] for i in range(N): for j in range(len(G[i])): GR[G[i][j]].append(i) R = [] U = [1] * len(G) for x in range(len(G) - 1, -1, -1): x = D[x] if U[x]: R.append([x]) U[x] = 0 for i in range(len(GR[x])): if U[GR[x][i]]: Z.append(GR[x][i]) U[GR[x][i]] = 0 while len(Z): x = Z[-1] del Z[-1] R[-1].append(x) for i in range(len(GR[x])): if U[GR[x][i]]: Z.append(GR[x][i]) U[GR[x][i]] = 0 return R S = sys.stdin.readlines() N, M = map(int, S[0].split()) G = [[] for i in range(N)] a, b = 0, 0 for i in range(M): a, b = map(int, S[i + 1].split()) G[a].append(b) P = SCC(G) print(len(P)) for i in range(len(P)): print(*([len(P[i])] + P[i]))
Statement You are given a directed graph with N vertices and M edges, not necessarily simple. The i-th edge is oriented from the vertex a_i to the vertex b_i. Divide this graph into strongly connected components and print them in their topological order.
[{"input": "6 7\n 1 4\n 5 2\n 3 0\n 5 5\n 4 1\n 0 3\n 4 2", "output": "4\n 1 5\n 2 4 1\n 1 2\n 2 3 0"}]
Print the final scores of Taro and Hanako respectively. Put a single space character between them.
s310708721
Accepted
p02421
In the first line, the number of cards n is given. In the following n lines, the cards for n turns are given respectively. For each line, the first string represents the Taro's card and the second one represents Hanako's card.
cards = int(input()) tarou_win = 0 hanako_win = 0 hikiwake = 0 for _ in range(cards): tarou_word, hanako_word = input().split() if tarou_word > hanako_word: tarou_win += 1 elif tarou_word < hanako_word: hanako_win += 1 else: hikiwake += 1 print(tarou_win * 3 + hikiwake, hanako_win * 3 + hikiwake)
Card Game Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner obtains 3 points. In the case of a draw, they obtain 1 point each. Write a program which reads a sequence of cards Taro and Hanako have and reports the final scores of the game.
[{"input": "cat dog\n fish fish\n lion tiger", "output": "7"}]
Print the final scores of Taro and Hanako respectively. Put a single space character between them.
s381140685
Runtime Error
p02421
In the first line, the number of cards n is given. In the following n lines, the cards for n turns are given respectively. For each line, the first string represents the Taro's card and the second one represents Hanako's card.
zisyo = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", ] turn = int(input()) ten = [0, 0] for _ in range(turn): hikaku = input().split() if zisyo.index(hikaku[0][0]) < zisyo.index(hikaku[1][0]): ten[1] += 3 elif zisyo.index(hikaku[0][0]) == zisyo.index(hikaku[1][0]): ten[0] += 1 ten[1] += 1 elif zisyo.index(hikaku[0][0]) > zisyo.index(hikaku[1][0]): ten[0] += 3 print(" ".join(ten))
Card Game Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner obtains 3 points. In the case of a draw, they obtain 1 point each. Write a program which reads a sequence of cards Taro and Hanako have and reports the final scores of the game.
[{"input": "cat dog\n fish fish\n lion tiger", "output": "7"}]
Print the final scores of Taro and Hanako respectively. Put a single space character between them.
s908506207
Accepted
p02421
In the first line, the number of cards n is given. In the following n lines, the cards for n turns are given respectively. For each line, the first string represents the Taro's card and the second one represents Hanako's card.
n = int(input()) scoreT = 0 scoreH = 0 for i in range(0, n): words = input().split(" ") if words[0] < words[1]: scoreH += 3 elif words[1] < words[0]: scoreT += 3 elif words[0] == words[1]: scoreT += 1 scoreH += 1 print(str(scoreT) + " " + str(scoreH))
Card Game Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner obtains 3 points. In the case of a draw, they obtain 1 point each. Write a program which reads a sequence of cards Taro and Hanako have and reports the final scores of the game.
[{"input": "cat dog\n fish fish\n lion tiger", "output": "7"}]
Print the final scores of Taro and Hanako respectively. Put a single space character between them.
s482885986
Accepted
p02421
In the first line, the number of cards n is given. In the following n lines, the cards for n turns are given respectively. For each line, the first string represents the Taro's card and the second one represents Hanako's card.
turn = int(input()) taro_score = 0 hanako_score = 0 for i in range(turn): tcard, hcard = input().split() tcard = str(tcard) hcard = str(hcard) taro_card = [0] * len(tcard) hanako_card = [0] * len(hcard) for j in range(len(tcard)): taro_card[j] = ord(tcard[j]) for k in range(len(hcard)): hanako_card[k] = ord(hcard[k]) if len(tcard) == len(hcard): for l in range(len(tcard)): if taro_card[l] > hanako_card[l]: taro_score += 3 break elif taro_card[l] < hanako_card[l]: hanako_score += 3 break else: if l == len(tcard) - 1: taro_score += 1 hanako_score += 1 else: continue elif len(tcard) < len(hcard): for a in range(len(tcard)): if taro_card[a] > hanako_card[a]: taro_score += 3 break elif taro_card[a] < hanako_card[a]: hanako_score += 3 break else: if a == len(tcard) - 1: # taro_score += 3 hanako_score += 3 else: continue else: for b in range(len(hcard)): if taro_card[b] > hanako_card[b]: taro_score += 3 break elif taro_card[b] < hanako_card[b]: hanako_score += 3 break else: if b == len(hcard) - 1: # hanako_score += 3 taro_score += 3 else: continue print("%d %d" % (taro_score, hanako_score))
Card Game Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner obtains 3 points. In the case of a draw, they obtain 1 point each. Write a program which reads a sequence of cards Taro and Hanako have and reports the final scores of the game.
[{"input": "cat dog\n fish fish\n lion tiger", "output": "7"}]
Print the final scores of Taro and Hanako respectively. Put a single space character between them.
s411969440
Accepted
p02421
In the first line, the number of cards n is given. In the following n lines, the cards for n turns are given respectively. For each line, the first string represents the Taro's card and the second one represents Hanako's card.
# coding:utf-8 n = int(input().rstrip()) toku = [0, 0] narabe = [] for i in range(n): taro, hana = input().rstrip().split() if taro == hana: toku[0] += 1 toku[1] += 1 else: narabe = [taro, hana] narabe.sort() toku[0] += narabe.index(taro) * 3 toku[1] += narabe.index(hana) * 3 print(" ".join(list(map(str, toku))))
Card Game Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner obtains 3 points. In the case of a draw, they obtain 1 point each. Write a program which reads a sequence of cards Taro and Hanako have and reports the final scores of the game.
[{"input": "cat dog\n fish fish\n lion tiger", "output": "7"}]
Print the final scores of Taro and Hanako respectively. Put a single space character between them.
s965834031
Accepted
p02421
In the first line, the number of cards n is given. In the following n lines, the cards for n turns are given respectively. For each line, the first string represents the Taro's card and the second one represents Hanako's card.
num_of_match = int(input()) poi_of_1 = 0 poi_of_2 = 0 for i in range(num_of_match): car_1, car_2 = input().split() if car_1 == car_2: poi_of_1 += 1 poi_of_2 += 1 elif car_1 > car_2: poi_of_1 += 3 elif car_1 < car_2: poi_of_2 += 3 print(poi_of_1, poi_of_2)
Card Game Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner obtains 3 points. In the case of a draw, they obtain 1 point each. Write a program which reads a sequence of cards Taro and Hanako have and reports the final scores of the game.
[{"input": "cat dog\n fish fish\n lion tiger", "output": "7"}]
Print the final scores of Taro and Hanako respectively. Put a single space character between them.
s649795248
Wrong Answer
p02421
In the first line, the number of cards n is given. In the following n lines, the cards for n turns are given respectively. For each line, the first string represents the Taro's card and the second one represents Hanako's card.
import string from itertools import zip_longest turn = int(input()) dic = {s: i for i, s in enumerate(string.ascii_lowercase)} t_s, h_s = 0, 0 for _ in range(turn): t, h = input().split() for t_c, h_c in zip_longest(t, h, fillvalue="a"): if dic[t_c] > dic[h_c]: t_s += 3 break elif dic[t_c] < dic[h_c]: h_s += 3 break elif t_c == h_c: t_s += 1 h_s += 1 break print(t_s, h_s)
Card Game Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner obtains 3 points. In the case of a draw, they obtain 1 point each. Write a program which reads a sequence of cards Taro and Hanako have and reports the final scores of the game.
[{"input": "cat dog\n fish fish\n lion tiger", "output": "7"}]
If a good set of choices does not exist, print `-1`. If a good set of choices exists, print one such set of choices in the following format: M b_1 b_2 ... b_M where M denotes the number of boxes that will contain a ball, and b_1,\ b_2,\ ...,\ b_M are the integers written on these boxes, in any order. * * *
s902143352
Wrong Answer
p02972
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
import sys s2nn = lambda s: [int(c) for c in s.split(" ")] ss2nn = lambda ss: [int(s) for s in ss] ss2nnn = lambda ss: [s2nn(s) for s in ss] i2s = lambda: sys.stdin.readline().rstrip() i2n = lambda: int(i2s()) i2nn = lambda: s2nn(i2s()) ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)] ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)] ii2nn = lambda n: ss2nn(ii2ss(n)) ii2nnn = lambda n: ss2nnn(ii2ss(n)) def main(): N = i2n() A = i2nn() B = [0] * N i = N b = 2 while i > N / b: B[i - 1] = A[i - 1] i -= 1 b = 3 while i > 0: while i > N / b: B[i - 1] = (A[i - 1] + B[i * 2 - 1]) % 2 i -= 1 b += 1 C = [] for i, b in enumerate(B): if b > 0: C.append(i + 1) M = len(C) print(M) for c in C: print(c, end=" ") print() main()
Statement There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
[{"input": "3\n 1 0 0", "output": "1\n 1\n \n\nConsider putting a ball only in the box with 1 written on it.\n\n * There are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n * There is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n * There is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\n* * *"}, {"input": "5\n 0 0 0 0 0", "output": "0\n \n\nPutting nothing in the boxes can be a good set of choices."}]
If a good set of choices does not exist, print `-1`. If a good set of choices exists, print one such set of choices in the following format: M b_1 b_2 ... b_M where M denotes the number of boxes that will contain a ball, and b_1,\ b_2,\ ...,\ b_M are the integers written on these boxes, in any order. * * *
s705920456
Wrong Answer
p02972
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
n = int(input()) a_list = [9] a_list += list(map(int, input().split())) ans_list = [0] * (n + 1) output = [] for i in range(n, 0, -1): siji = a_list[i] num = n // i tmp = 0 for j in range(1, num): tmp += ans_list[i * num] if tmp % 2 == siji: ans_list[i] = 0 else: ans_list[i] = 1 output.append(i) print(sum(ans_list[1:])) for i in range(len(output)): if i == len(output) - 1: print(output[i]) else: print(output[i], end=" ")
Statement There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
[{"input": "3\n 1 0 0", "output": "1\n 1\n \n\nConsider putting a ball only in the box with 1 written on it.\n\n * There are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n * There is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n * There is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\n* * *"}, {"input": "5\n 0 0 0 0 0", "output": "0\n \n\nPutting nothing in the boxes can be a good set of choices."}]
If a good set of choices does not exist, print `-1`. If a good set of choices exists, print one such set of choices in the following format: M b_1 b_2 ... b_M where M denotes the number of boxes that will contain a ball, and b_1,\ b_2,\ ...,\ b_M are the integers written on these boxes, in any order. * * *
s273650180
Wrong Answer
p02972
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
print("-1")
Statement There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
[{"input": "3\n 1 0 0", "output": "1\n 1\n \n\nConsider putting a ball only in the box with 1 written on it.\n\n * There are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n * There is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n * There is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\n* * *"}, {"input": "5\n 0 0 0 0 0", "output": "0\n \n\nPutting nothing in the boxes can be a good set of choices."}]
If a good set of choices does not exist, print `-1`. If a good set of choices exists, print one such set of choices in the following format: M b_1 b_2 ... b_M where M denotes the number of boxes that will contain a ball, and b_1,\ b_2,\ ...,\ b_M are the integers written on these boxes, in any order. * * *
s891466495
Wrong Answer
p02972
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
n = int(input()) a_ls = list(map(int, input().split())) a_ls = [0] + a_ls box_ls = [0] * (n + 1) root = n**0.5 for i in range(n, 0, -1): if i > root: box_ls[i] = a_ls[i] else: Sum = 0 num = i + i # ここの条件式不安あり while num <= n: Sum += a_ls[num] num += i rest = Sum % 2 if (rest == 1 and a_ls[i] == 1) or (rest == 0 and a_ls[i] == 0): box_ls[i] = 0 else: box_ls[i] = 1 ans_ls = [] for box_name, ball_num in enumerate(box_ls[1:], 1): if ball_num == 1: ans_ls.append(str(box_name)) M = len(ans_ls) print(M) if M > 0: print(" ".join(ans_ls))
Statement There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
[{"input": "3\n 1 0 0", "output": "1\n 1\n \n\nConsider putting a ball only in the box with 1 written on it.\n\n * There are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n * There is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n * There is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\n* * *"}, {"input": "5\n 0 0 0 0 0", "output": "0\n \n\nPutting nothing in the boxes can be a good set of choices."}]
If a good set of choices does not exist, print `-1`. If a good set of choices exists, print one such set of choices in the following format: M b_1 b_2 ... b_M where M denotes the number of boxes that will contain a ball, and b_1,\ b_2,\ ...,\ b_M are the integers written on these boxes, in any order. * * *
s976368799
Wrong Answer
p02972
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
N = int(input()) li = input().split() a = 0 list2 = [0] * N for i in range(N, 0, -1): s = 0 for t in range(i, N + 1, i): s += t if li[i - 1] == 1: if s % 2 == 0: list2[i - 1] = 1 a += 1 if li[i - 1] == 0: if s % 2 == 1: list2[i - 1] = 1 a += 1 list2 = list(map(str, list2)) print(a) if a != 0: print(" ".join(list2))
Statement There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
[{"input": "3\n 1 0 0", "output": "1\n 1\n \n\nConsider putting a ball only in the box with 1 written on it.\n\n * There are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n * There is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n * There is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\n* * *"}, {"input": "5\n 0 0 0 0 0", "output": "0\n \n\nPutting nothing in the boxes can be a good set of choices."}]
If a good set of choices does not exist, print `-1`. If a good set of choices exists, print one such set of choices in the following format: M b_1 b_2 ... b_M where M denotes the number of boxes that will contain a ball, and b_1,\ b_2,\ ...,\ b_M are the integers written on these boxes, in any order. * * *
s896951415
Wrong Answer
p02972
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
import glob import numpy as np # 問題ごとのディレクトリのトップからの相対パス REL_PATH = "ABC\\134\\D" # テスト用ファイル置き場のトップ TOP_PATH = "C:\\AtCoder" class Common: problem = [] index = 0 def __init__(self, rel_path): self.rel_path = rel_path def initialize(self, path): file = open(path) self.problem = file.readlines() self.index = 0 return def input_data(self): try: IS_TEST self.index += 1 return self.problem[self.index - 1] except NameError: return input() def resolve(self): pass def exec_resolve(self): try: IS_TEST for path in glob.glob(TOP_PATH + "\\" + self.rel_path + "/*.txt"): print("Test: " + path) self.initialize(path) self.resolve() print("\n\n") except NameError: self.resolve() class D(Common): def resolve(self): box_num = int(self.input_data()) remain = [int(i) for i in self.input_data().split()] boxes = np.zeros(box_num, dtype=np.int) for box in range(box_num, 0, -1): sum = np.max(boxes[box - 1 :: box]) if sum % 2 != remain[box - 1]: boxes[box - 1] = 1 print(str(np.sum(boxes))) for i in range(box_num): if boxes[i] == 1: print(str(i + 1), end=" ") solver = D(REL_PATH) solver.exec_resolve()
Statement There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
[{"input": "3\n 1 0 0", "output": "1\n 1\n \n\nConsider putting a ball only in the box with 1 written on it.\n\n * There are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n * There is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n * There is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\n* * *"}, {"input": "5\n 0 0 0 0 0", "output": "0\n \n\nPutting nothing in the boxes can be a good set of choices."}]
If a good set of choices does not exist, print `-1`. If a good set of choices exists, print one such set of choices in the following format: M b_1 b_2 ... b_M where M denotes the number of boxes that will contain a ball, and b_1,\ b_2,\ ...,\ b_M are the integers written on these boxes, in any order. * * *
s385832579
Accepted
p02972
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
N = int(input()) A = list(map(int, input().split())) cur = [0 for i in range(N)] ball = [] ball_num = 0 for x in range(N): i = N - 1 - x n = i + 1 if A[i] != cur[i]: ball.append(n) ball_num += 1 for j in range(n // 2 + 1): m = j + 1 if m * m > n: break if n % m == 0: cur[j] = 1 - cur[j] if n // m != m: cur[n // m - 1] = 1 - cur[n // m - 1] print(ball_num) print(" ".join(list(map(str, ball))))
Statement There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
[{"input": "3\n 1 0 0", "output": "1\n 1\n \n\nConsider putting a ball only in the box with 1 written on it.\n\n * There are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n * There is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n * There is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\n* * *"}, {"input": "5\n 0 0 0 0 0", "output": "0\n \n\nPutting nothing in the boxes can be a good set of choices."}]
If a good set of choices does not exist, print `-1`. If a good set of choices exists, print one such set of choices in the following format: M b_1 b_2 ... b_M where M denotes the number of boxes that will contain a ball, and b_1,\ b_2,\ ...,\ b_M are the integers written on these boxes, in any order. * * *
s172882443
Wrong Answer
p02972
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
n = int(input()) a = [int(i) for i in input().split()] li = [0] * n a = a[::-1] for i in range(n): if a[i] != li[i] % 2: for j in range(n - i): if (n - i) % (j + 1) == 0: li[j] += 1 li2 = [] for i in range(n): if li[i] % 2 == 1: li2 += [i + 1] print(len(li2)) print(*li2)
Statement There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
[{"input": "3\n 1 0 0", "output": "1\n 1\n \n\nConsider putting a ball only in the box with 1 written on it.\n\n * There are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.\n * There is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.\n * There is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.\n\nThus, the condition is satisfied, so this set of choices is good.\n\n* * *"}, {"input": "5\n 0 0 0 0 0", "output": "0\n \n\nPutting nothing in the boxes can be a good set of choices."}]
If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`. * * *
s214207064
Accepted
p03660
Input is given from Standard Input in the following format: N a_1 b_1 : a_{N-1} b_{N-1}
#!/usr/bin/env python3 import sys # import time # import math # import numpy as np # import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall # import random # random, uniform, randint, randrange, shuffle, sample # import string # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits # import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s) # from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]). from collections import ( deque, ) # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate() # from collections import defaultdict # subclass of dict. defaultdict(facroty) # from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter) # from datetime import date, datetime # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj # from datetime.datetime import strptime # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj # from datetime import timedelta # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available. # from copy import copy, deepcopy # use deepcopy to copy multi-dimentional matrix without reference # from functools import reduce # reduce(f, iter[, init]) # from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed) # from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn). # from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn). # from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n]) # from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])] # from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9] # from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r]) # from itertools import combinations, combinations_with_replacement # from itertools import accumulate # accumulate(iter[, f]) # from operator import itemgetter # itemgetter(1), itemgetter('key') # from fractions import gcd # for Python 3.4 (previous contest @AtCoder) def main(): mod = 1000000007 # 10^9+7 inf = float("inf") # sys.float_info.max = 1.79...e+308 # inf = 2 ** 64 - 1 # (for fast JIT compile in PyPy) 1.84...e+19 sys.setrecursionlimit(10**6) # 1000 -> 1000000 def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def mi(): return map(int, input().split()) def mi_0(): return map(lambda x: int(x) - 1, input().split()) def lmi(): return list(map(int, input().split())) def lmi_0(): return list(map(lambda x: int(x) - 1, input().split())) def li(): return list(input()) def restore_path(seq, start, goal): buf = [] current = goal while current != start: buf.append(current) current = seq[current] buf.append(start) buf.reverse() return buf def calc_dist_path_in_bfs(adj, start, goal): q = deque() q.append([[start, None], 0]) prev_memo = [None] * n while q: (u, prev), dist = q.popleft() if u == goal: prev_memo[u] = prev return dist, restore_path(prev_memo, start, goal) if not visited[u]: visited[u] = True prev_memo[u] = prev for v in adj[u]: if not visited[v]: q.append([[v, u], dist + 1]) def calc_node_in_dfs(adj, start): cnt = 1 stack = [start] visited[start] = True while stack: # print(stack) u = stack[-1] for v in adj[u]: if not visited[v]: stack.append(v) visited[v] = True cnt += 1 break else: stack.pop() return cnt n = ii() adj = [[] for _ in range(n)] for _ in range(n - 1): a, b = mi_0() adj[a].append(b) adj[b].append(a) visited = [False] * n dist, path = calc_dist_path_in_bfs(adj, start=0, goal=n - 1) # print(dist) # print(path) visited = [False] * n if dist % 2 == 1: i = path[(dist - 1) // 2] j = path[(dist - 1) // 2 + 1] adj[i].remove(j) adj[j].remove(i) # i 彩色数 > j 彩色数 で Fennec 勝ち i_color = calc_node_in_dfs(adj, i) j_color = calc_node_in_dfs(adj, j) print("Fennec") if i_color > j_color else print("Snuke") else: i = path[dist // 2] j = path[dist // 2 + 1] adj[i].remove(j) adj[j].remove(i) # i 彩色数 >= j 彩色数 で Fennec 勝ち i_color = calc_node_in_dfs(adj, i) j_color = calc_node_in_dfs(adj, j) print("Fennec") if i_color >= j_color else print("Snuke") if __name__ == "__main__": main()
Statement Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
[{"input": "7\n 3 6\n 1 2\n 3 1\n 7 4\n 5 7\n 1 4", "output": "Fennec\n \n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of\nSnuke's moves.\n\n* * *"}, {"input": "4\n 1 4\n 4 2\n 2 3", "output": "Snuke"}]
If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`. * * *
s500676246
Accepted
p03660
Input is given from Standard Input in the following format: N a_1 b_1 : a_{N-1} b_{N-1}
import sys input = sys.stdin.readline n = int(input()) connect_list = [[] for i in range(n)] for i in range(n - 1): a, b = [int(v) - 1 for v in input().split()] connect_list[a].append(b) connect_list[b].append(a) def djkstra(in_connect_list): out_parent_list = [-1 for i in range(n)] out_shortest_list = [-1 for i in range(n)] out_shortest_list[0] = 0 searching_list = [0] while searching_list != []: new_search_list = [] for i in searching_list: for j in in_connect_list[i]: if out_shortest_list[j] == -1: out_shortest_list[j] = 1 + out_shortest_list[i] out_parent_list[j] = i new_search_list.append(j) searching_list = new_search_list return out_shortest_list, out_parent_list shortest_list, parent_list = djkstra(connect_list) nto1_list = [n - 1] while nto1_list[-1] != 0: nto1_list.append(parent_list[nto1_list[-1]]) nto1_list = list(reversed(nto1_list)) shortest_length = len(nto1_list) if shortest_length % 2 == 0: p = nto1_list[(shortest_length // 2) - 1] q = nto1_list[shortest_length // 2] else: p = nto1_list[shortest_length // 2] q = nto1_list[(shortest_length // 2) + 1] del connect_list[p][connect_list[p].index(q)] del connect_list[q][connect_list[q].index(p)] shortest_list, parent_list = djkstra(connect_list) snu, fen = shortest_list.count(-1), n - shortest_list.count(-1) if fen > snu: print("Fennec") else: print("Snuke")
Statement Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
[{"input": "7\n 3 6\n 1 2\n 3 1\n 7 4\n 5 7\n 1 4", "output": "Fennec\n \n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of\nSnuke's moves.\n\n* * *"}, {"input": "4\n 1 4\n 4 2\n 2 3", "output": "Snuke"}]
If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`. * * *
s045513247
Wrong Answer
p03660
Input is given from Standard Input in the following format: N a_1 b_1 : a_{N-1} b_{N-1}
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) INF = 10**18 MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() YesNo = lambda b: bool([print("Yes")] if b else print("No")) YESNO = lambda b: bool([print("YES")] if b else print("NO")) int1 = lambda x: int(x) - 1 def main(): N = int(input()) edge = [[] for _ in range(N)] for _ in range(N - 1): a, b = map(int1, input().split()) edge[a].append(b) edge[b].append(a) cost = [INF] * N cost[0] = 0 stack = [0] while stack: v = stack.pop() for nv in edge[v]: if cost[nv] == INF: cost[nv] = cost[v] + 1 stack.append(nv) if nv == N - 1: break d = cost[N - 1] v = N - 1 for i in range(d // 2 + 1): for nv in edge[v]: if cost[nv] == cost[v] - 1: v = nv if i == d // 2 - 1: s = nv elif i == d // 2: f = nv if d // 2 == 0: s = N - 1 class UnionFind: def __init__(self, n): self.par = [i for i in range(n)] self.siz = [1] * n def root(self, x): while self.par[x] != x: self.par[x] = self.par[self.par[x]] x = self.par[x] return x def unite(self, x, y): x = self.root(x) y = self.root(y) if x == y: return False if self.siz[x] < self.siz[y]: x, y = y, x self.siz[x] += self.siz[y] self.par[y] = x return True def is_same(self, x, y): return self.root(x) == self.root(y) def size(self, x): return self.siz[self.root(x)] stack = [s] used = [False] * N c = 0 while stack: v = stack.pop() used[v] = True c += 1 for nv in edge[v]: if not used[nv] and nv != f: stack.append(nv) if c >= N - c: print("Snuke") else: print("Fennec") if __name__ == "__main__": main()
Statement Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
[{"input": "7\n 3 6\n 1 2\n 3 1\n 7 4\n 5 7\n 1 4", "output": "Fennec\n \n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of\nSnuke's moves.\n\n* * *"}, {"input": "4\n 1 4\n 4 2\n 2 3", "output": "Snuke"}]
If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`. * * *
s735304250
Wrong Answer
p03660
Input is given from Standard Input in the following format: N a_1 b_1 : a_{N-1} b_{N-1}
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math # from math import gcd import bisect import heapq from collections import defaultdict from collections import deque from collections import Counter from functools import lru_cache ############# # Constants # ############# MOD = 10**9 + 7 INF = float("inf") AZ = "abcdefghijklmnopqrstuvwxyz" ############# # Functions # ############# ######INPUT###### def I(): return int(input().strip()) def S(): return input().strip() def IL(): return list(map(int, input().split())) def SL(): return list(map(str, input().split())) def ILs(n): return list(int(input()) for _ in range(n)) def SLs(n): return list(input().strip() for _ in range(n)) def ILL(n): return [list(map(int, input().split())) for _ in range(n)] def SLL(n): return [list(map(str, input().split())) for _ in range(n)] ######OUTPUT###### def P(arg): print(arg) return def Y(): print("Yes") return def N(): print("No") return def E(): exit() def PE(arg): print(arg) exit() def YE(): print("Yes") exit() def NE(): print("No") exit() #####Shorten##### def DD(arg): return defaultdict(arg) #####Inverse##### def inv(n): return pow(n, MOD - 2, MOD) ######Combination###### kaijo_memo = [] def kaijo(n): if len(kaijo_memo) > n: return kaijo_memo[n] if len(kaijo_memo) == 0: kaijo_memo.append(1) while len(kaijo_memo) <= n: kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD) return kaijo_memo[n] gyaku_kaijo_memo = [] def gyaku_kaijo(n): if len(gyaku_kaijo_memo) > n: return gyaku_kaijo_memo[n] if len(gyaku_kaijo_memo) == 0: gyaku_kaijo_memo.append(1) while len(gyaku_kaijo_memo) <= n: gyaku_kaijo_memo.append( gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD ) return gyaku_kaijo_memo[n] def nCr(n, r): if n == r: return 1 if n < r or r < 0: return 0 ret = 1 ret = ret * kaijo(n) % MOD ret = ret * gyaku_kaijo(r) % MOD ret = ret * gyaku_kaijo(n - r) % MOD return ret ######Factorization###### def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr == []: arr.append([n, 1]) return arr #####MakeDivisors###### def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) return divisors #####MakePrimes###### def make_primes(N): max = int(math.sqrt(N)) seachList = [i for i in range(2, N + 1)] primeNum = [] while seachList[0] <= max: primeNum.append(seachList[0]) tmp = seachList[0] seachList = [i for i in seachList if i % tmp != 0] primeNum.extend(seachList) return primeNum #####GCD##### def gcd(a, b): while b: a, b = b, a % b return a #####LCM##### def lcm(a, b): return a * b // gcd(a, b) #####BitCount##### def count_bit(n): count = 0 while n: n &= n - 1 count += 1 return count #####ChangeBase##### def base_10_to_n(X, n): if X // n: return base_10_to_n(X // n, n) + [X % n] return [X % n] def base_n_to_10(X, n): return sum(int(str(X)[-i - 1]) * n**i for i in range(len(str(X)))) def base_10_to_n_without_0(X, n): X -= 1 if X // n: return base_10_to_n_without_0(X // n, n) + [X % n] return [X % n] #####IntLog##### def int_log(n, a): count = 0 while n >= a: n //= a count += 1 return count ############# # Main Code # ############# N = I() graph = [[] for i in range(N)] for _ in range(N - 1): a, b = IL() graph[a - 1].append(b - 1) graph[b - 1].append(a - 1) s = 0 d1 = [INF] * N d1[s] = 0 q = deque([s]) while q: u = q.popleft() for v in graph[u]: if d1[v] != INF: continue d1[v] = d1[u] + 1 q.append(v) s = N - 1 d2 = [INF] * N d2[s] = 0 q = deque([s]) while q: u = q.popleft() for v in graph[u]: if d2[v] != INF: continue d2[v] = d2[u] + 1 q.append(v) ans = 0 for i in range(N): if d1[i] <= d2[i]: ans += 1 if ans >= (N + 1) // 2: print("Fennec") else: print("Snuke")
Statement Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
[{"input": "7\n 3 6\n 1 2\n 3 1\n 7 4\n 5 7\n 1 4", "output": "Fennec\n \n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of\nSnuke's moves.\n\n* * *"}, {"input": "4\n 1 4\n 4 2\n 2 3", "output": "Snuke"}]
If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`. * * *
s128631990
Accepted
p03660
Input is given from Standard Input in the following format: N a_1 b_1 : a_{N-1} b_{N-1}
def examA(): def calc_L(x1, y1, x2, y2): return ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5 N = I() X = [LI() for _ in range(N)] ans = 0 for x in itertools.permutations(X): cur = 0 for i in range(1, N): cur += calc_L(x[i - 1][0], x[i - 1][1], x[i][0], x[i][1]) # print(x,cur) ans += cur for i in range(1, N + 1): ans /= i print(ans) return def examB(): def judge(n): sn = 0 for i in n: sn += int(i) if int(n) % sn == 0: return "Yes" return "No" N = SI() ans = judge(N) print(ans) return def examC(): N, K = LI() P = LI() ans = 0 S = [0] * (N + 1) for i in range(N): S[i + 1] = S[i] + (P[i] + 1) / 2 for i in range(N - K + 1): cur = S[i + K] - S[i] if cur > ans: ans = cur print(ans) return def examD(): def bfs(n, V, s, W): visited = [False] * n que = deque() que.append(s) while que: now = que.pop() visited[now] = True for ne in V[now]: if visited[ne]: continue W[ne] += W[now] que.append(ne) return W N, Q = LI() V = [[] for _ in range(N)] for _ in range(N - 1): a, b = LI() a -= 1 b -= 1 V[a].append(b) V[b].append(a) W = [0] * N for _ in range(Q): p, x = LI() W[p - 1] += x ans = bfs(N, V, 0, W) print(" ".join(map(str, ans))) return def examE(): def bfs(n, edges, s): L = [inf] * n que = deque() que.append(s) L[s] = 0 while que: now = que.popleft() for ne in edges[now]: if L[ne] > L[now] + 1: L[ne] = L[now] + 1 que.append(ne) return L N = I() V = [[] for _ in range(N)] for _ in range(N - 1): a, b = LI() a -= 1 b -= 1 V[a].append(b) V[b].append(a) F = bfs(N, V, 0) S = bfs(N, V, N - 1) f = 0 s = 0 for i in range(N): if F[i] > S[i]: s += 1 else: f += 1 if f > s: print("Fennec") else: print("Snuke") return def examF(): ans = 0 print(ans) return import sys, bisect, itertools, heapq, math, random from copy import deepcopy from heapq import heappop, heappush, heapify from collections import Counter, defaultdict, deque def I(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LSI(): return list(map(str, sys.stdin.readline().split())) def LS(): return sys.stdin.readline().split() def SI(): return sys.stdin.readline().strip() global mod, mod2, inf, alphabet, _ep mod = 10**9 + 7 mod2 = 998244353 inf = 10**18 _ep = 10 ** (-12) alphabet = [chr(ord("a") + i) for i in range(26)] sys.setrecursionlimit(10**6) if __name__ == "__main__": examE() """ """
Statement Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
[{"input": "7\n 3 6\n 1 2\n 3 1\n 7 4\n 5 7\n 1 4", "output": "Fennec\n \n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of\nSnuke's moves.\n\n* * *"}, {"input": "4\n 1 4\n 4 2\n 2 3", "output": "Snuke"}]
If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`. * * *
s255125825
Wrong Answer
p03660
Input is given from Standard Input in the following format: N a_1 b_1 : a_{N-1} b_{N-1}
import heapq class Graph: def __init__(self, v, edgelist, w_v=None, directed=False): super().__init__() self.v = v self.w_e = [{} for _ in [0] * self.v] self.neighbor = [[] for _ in [0] * self.v] self.w_v = w_v self.directed = directed for i, j, w in edgelist: self.w_e[i][j] = w self.neighbor[i].append(j) def dijkstra(self, v_n): d = [float("inf")] * self.v d[v_n] = 0 prev = [-1] * self.v queue = [] for i, d_i in enumerate(d): heapq.heappush(queue, (d_i, i)) while len(queue) > 0: d_u, u = queue.pop() if d[u] < d_u: continue for v in self.neighbor[u]: alt = d[u] + self.w_e[u][v] if d[v] > alt: d[v] = alt prev[v] = u heapq.heappush(queue, (alt, v)) return d, prev def warshallFloyd(self): d = [[10**18] * self.v for _ in [0] * self.v] for i in range(self.v): d[i][i] = 0 for i in range(self.v): for j in self.neighbor[i]: d[i][j] = self.w_e[i][j] for i in range(self.v): for j in self.neighbor[i]: d[i][j] = self.w_e[i][j] for k in range(self.v): for i in range(self.v): for j in range(self.v): check = d[i][k] + d[k][j] if d[i][j] > check: d[i][j] = check return d def prim(self): gb = GraphBuilder(self.v, self.directed) queue = [] for i, w in self.w_e[0].items(): heapq.heappush(queue, (w, 0, i)) rest = [True] * self.v rest[0] = False while len(queue) > 0: w, i, j = heapq.heappop(queue) if rest[j]: gb.addEdge(i, j, w) rest[j] = False for k, w in self.w_e[j].items(): if rest[k]: heapq.heappush(queue, (w, j, k)) return gb class Tree: def __init__(self, v, e): pass class GraphBuilder: def __init__(self, v, directed=False): self.v = v self.directed = directed self.edge = [] def addEdge(self, i, j, w=1): if not self.directed: self.edge.append((j, i, w)) self.edge.append((i, j, w)) def addEdges(self, edgelist, weight=True): if weight: if self.directed: for i, j, w in edgelist: self.edge.append((i, j, w)) else: for i, j, w in edgelist: self.edge.append((i, j, w)) self.edge.append((j, i, w)) else: if self.directed: for i, j in edgelist: self.edge.append((i, j, 1)) else: for i, j in edgelist: self.edge.append((i, j, 1)) self.edge.append((j, i, 1)) def addAdjMat(self, mat): for i, mat_i in enumerate(mat): for j, w in enumerate(mat_i): self.edge.append((i, j, w)) def buildTree(self): pass def buildGraph(self): return Graph(self.v, self.edge, directed=self.directed) def main(): n = int(input()) edge = [tuple([int(t) - 1 for t in input().split()]) for _ in [0] * (n - 1)] gb = GraphBuilder(n) gb.addEdges(edge, False) g = gb.buildGraph() node = [0] * n head = [0] tail = [n - 1] while len(head) > 0 or len(tail) > 0: t = [] while len(head) > 0: h = head.pop() for i in g.neighbor[h]: if node[i] == 0: t.append(i) node[i] = 1 head = t t = [] while len(tail) > 0: h = tail.pop() for i in g.neighbor[h]: if node[i] == 0: t.append(i) node[i] = -1 tail = t ans = sum(node) if ans > 0: print("Fennec") else: print("Snuke")
Statement Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
[{"input": "7\n 3 6\n 1 2\n 3 1\n 7 4\n 5 7\n 1 4", "output": "Fennec\n \n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of\nSnuke's moves.\n\n* * *"}, {"input": "4\n 1 4\n 4 2\n 2 3", "output": "Snuke"}]
If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`. * * *
s077777555
Wrong Answer
p03660
Input is given from Standard Input in the following format: N a_1 b_1 : a_{N-1} b_{N-1}
x = int(input()) if x % 2 == 0: print("Snuke") else: print("Fennec")
Statement Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
[{"input": "7\n 3 6\n 1 2\n 3 1\n 7 4\n 5 7\n 1 4", "output": "Fennec\n \n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of\nSnuke's moves.\n\n* * *"}, {"input": "4\n 1 4\n 4 2\n 2 3", "output": "Snuke"}]
If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`. * * *
s979584373
Runtime Error
p03660
Input is given from Standard Input in the following format: N a_1 b_1 : a_{N-1} b_{N-1}
import collections N = int(input()) G = [set() for i in range(N)] for i in range(N-1): a, b = map(int, input().split()) a -= 1 b -= 1 G[a].add(b) G[b].add(a) F = [-1]*N F[0] = 0 q = collections.deque() q.append(0) while(q): x = q.popleft() for y in G[x]: if F[y] < 0: F[y] = F[x] + 1 q.append(y) S = [-1]*N S[N-1] = 0 q.append(N-1) while(q): x = q.popleft() for y in G[x]: if S[y] < 0: S[y] = S[x] + 1 q.append(y) # print(F) # print(S) ans = 0 for i in range(N): if F[i] + S[i] == F[-1]: if ans > N // 2: print("Fennec") else: print("Snuke")
Statement Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
[{"input": "7\n 3 6\n 1 2\n 3 1\n 7 4\n 5 7\n 1 4", "output": "Fennec\n \n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of\nSnuke's moves.\n\n* * *"}, {"input": "4\n 1 4\n 4 2\n 2 3", "output": "Snuke"}]
If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`. * * *
s593410500
Runtime Error
p03660
Input is given from Standard Input in the following format: N a_1 b_1 : a_{N-1} b_{N-1}
n=int(input()) s=[[]for i in range(n+1)] for i in range(n-1): a,b=map(int,input().split()) s[a].append(b) s[b].append(a) def f(a,b): c,flag,ans=[[a,[0,a]]],False,[] while c or flag=False: p,q=c.pop() for i in s[p]: if i==b: ans=q[1:]+[b] break else: if q[-2]!=i: c.append([i,q+[i]]) else: return ans def f(x,l): c=0 p,d=[x],[0]*(n+1) while p: a=p.pop() if a not in x or a==x: c+=1 d[a]=1 for i in s[a]: if d[i]==0: p.append(i) else: return c t=f(a,b) t=[f(i,ans)for i in t] print("Fennec"if sum(t[:-len(t)//2])>sum(t[-len(t)//2:]) else"Snuke")
Statement Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
[{"input": "7\n 3 6\n 1 2\n 3 1\n 7 4\n 5 7\n 1 4", "output": "Fennec\n \n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of\nSnuke's moves.\n\n* * *"}, {"input": "4\n 1 4\n 4 2\n 2 3", "output": "Snuke"}]
If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`. * * *
s035111991
Runtime Error
p03660
Input is given from Standard Input in the following format: N a_1 b_1 : a_{N-1} b_{N-1}
// Created by sz #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, d1[N], dn[N]; vector<int> g[N]; void dfs(int u, int pre,int* d ){ for(auto i: g[u]){ if (i==pre)continue; d[i] = d[pre] + 1; dfs(i, u, d); } } int main(){ #ifdef LOCAL freopen("./input.txt", "r", stdin); #endif ios_base::sync_with_stdio(false); cin.tie(0); cin>>n; int a,b; for (int i = 1; i <= n-1; i++){ cin>>a>>b; g[a].push_back(b); g[b].push_back(a); } dfs(1, -1, d1); dfs(n, -1, dn); int ans = 0; for (int i = 2; i <= n-1; i++){ if(d1[i]<= dn[i])ans++; else ans --; } if(ans >0) cout<<"Fennec"<<endl; else cout<<"Snuke"<<endl; return 0; }
Statement Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
[{"input": "7\n 3 6\n 1 2\n 3 1\n 7 4\n 5 7\n 1 4", "output": "Fennec\n \n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of\nSnuke's moves.\n\n* * *"}, {"input": "4\n 1 4\n 4 2\n 2 3", "output": "Snuke"}]
If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`. * * *
s515358231
Runtime Error
p03660
Input is given from Standard Input in the following format: N a_1 b_1 : a_{N-1} b_{N-1}
N=int(input()) G=[[] for i in range(N+1)] for_in range(N-1): a, b = inpl() G[a].append(b) G[b].append(a) F=["" for i in range(N+1)] S=["" for i in range(N+1)] visited = [False for i in range(N+1)] Q = deque([(1, 0)]) while len(Q): m, d = Q.popleft() if visited[m]: continue else: F[m] = d visited[m] = True for nm in G[m]: Q.append((nm, d+1)) visited = [False for i in range(N+1)] Q = deque([(N, 0)]) while len(Q): m, d = Q.popleft() if visited[m]: continue else: S[m]=d visited[m]=True for nm in G[m]: Q.append((nm, d+1)) black = 0 for i in range(1, N+1): if F[i]<=S[i]: black+=1 if 2*black>N: print("Fennec") else: print("Snuke")
Statement Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
[{"input": "7\n 3 6\n 1 2\n 3 1\n 7 4\n 5 7\n 1 4", "output": "Fennec\n \n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of\nSnuke's moves.\n\n* * *"}, {"input": "4\n 1 4\n 4 2\n 2 3", "output": "Snuke"}]
If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`. * * *
s981350490
Accepted
p03660
Input is given from Standard Input in the following format: N a_1 b_1 : a_{N-1} b_{N-1}
from sys import stdout printn = lambda x: stdout.write(str(x)) inn = lambda: int(input()) inl = lambda: list(map(int, input().split())) inm = lambda: map(int, input().split()) ins = lambda: input().strip() DBG = True # and False BIG = 999999999 R = 10**9 + 7 def ddprint(x): if DBG: print(x) n = inn() dst = [[] for i in range(n)] for i in range(n - 1): a, b = inm() dst[a - 1].append(b - 1) dst[b - 1].append(a - 1) b = [0] w = [n - 1] c = [0] * n c[0] = 1 c[n - 1] = -1 while len(b) > 0 or len(w) > 0: nxtb = [] while len(b) > 0: x = b.pop() for y in dst[x]: if c[y] == 0: c[y] = 1 nxtb.append(y) b = nxtb nxtw = [] while len(w) > 0: x = w.pop() for y in dst[x]: if c[y] == 0: c[y] = -1 nxtw.append(y) w = nxtw print("Snuke" if sum(c) <= 0 else "Fennec")
Statement Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
[{"input": "7\n 3 6\n 1 2\n 3 1\n 7 4\n 5 7\n 1 4", "output": "Fennec\n \n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of\nSnuke's moves.\n\n* * *"}, {"input": "4\n 1 4\n 4 2\n 2 3", "output": "Snuke"}]
If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`. * * *
s938857834
Wrong Answer
p03660
Input is given from Standard Input in the following format: N a_1 b_1 : a_{N-1} b_{N-1}
from collections import deque def get_root(s): if s != root[s]: root[s] = get_root(root[s]) return root[s] return s def unite(s, t): root_s = get_root(s) root_t = get_root(t) if not root_s == root_t: if rank[s] == rank[t]: root[root_t] = root_s rank[root_s] += 1 union_count[root_s] += union_count[root_t] elif rank[s] > rank[t]: root[root_t] = root_s union_count[root_s] += union_count[root_t] else: root[root_s] = root_t union_count[root_t] += union_count[root_s] def same(s, t): if get_root(s) == get_root(t): return True else: return False def dfs(i, j): q = deque() q.append(i) p = i while q: u = g[p] v = c[p] if sum(v) == len(v): p = q.pop() u = g[p] v = c[p] for k in range(len(u)): if v[k] == 0: if not u[k] in q: q.append(u[k]) p = u[k] v[k] = 1 break else: v[k] = 1 if p == j: return q n = int(input()) root = [i for i in range(n)] rank = [1 for _ in range(n)] union_count = [1 for _ in range(n)] t = [list(map(int, input().split())) for _ in range(n - 1)] g = [-1] * (n + 1) c = [-1] * (n + 1) for s in t: if g[s[0]] == -1: g[s[0]] = [s[1]] c[s[0]] = [0] else: g[s[0]].append(s[1]) c[s[0]].append(0) if g[s[1]] == -1: g[s[1]] = [s[0]] c[s[1]] = [0] else: g[s[1]].append(s[0]) c[s[1]].append(0) q = dfs(1, n) if len(q) % 2 == 0: a, b = q[len(q) // 2 - 1], q[len(q) // 2] else: a, b = q[len(q) // 2], q[len(q) // 2 + 1] for s in t: if s != [a, b] and s != [b, a]: unite(s[0] - 1, s[1] - 1) F = union_count[get_root(0)] S = union_count[get_root(n - 1)] if F > S: print("Fennec") else: print("Snuke")
Statement Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
[{"input": "7\n 3 6\n 1 2\n 3 1\n 7 4\n 5 7\n 1 4", "output": "Fennec\n \n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of\nSnuke's moves.\n\n* * *"}, {"input": "4\n 1 4\n 4 2\n 2 3", "output": "Snuke"}]
If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`. * * *
s366433158
Wrong Answer
p03660
Input is given from Standard Input in the following format: N a_1 b_1 : a_{N-1} b_{N-1}
N = int(input()) tr = [[] for i in range(N)] for i in range(N - 1): a, b = map(int, input().split()) a, b = a - 1, b - 1 tr[a].append(b) tr[b].append(a) def canGoCnt(start, wall): stack = [start] visited = [0 for i in range(N)] count = 0 while stack: a = stack.pop() visited[a] = 1 count += 1 for b in tr[a]: if visited[b] == 0 and b != wall: stack.append(b) return count - 1 def route(fr, to): stack = [[fr]] visited = [0 for i in range(N)] while stack: rt = stack.pop() now = rt[-1] if now == to: return rt visited[now] = 1 for nxt in tr[now]: if visited[nxt] == 0: newrt = rt[:] newrt.append(nxt) stack.append(newrt) r = route(0, N - 1) w = (len(r) - 1) // 2 f = canGoCnt(0, r[w + 1]) s = canGoCnt(N - 1, r[w]) print("Fennec" if f >= s else "Snuke")
Statement Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
[{"input": "7\n 3 6\n 1 2\n 3 1\n 7 4\n 5 7\n 1 4", "output": "Fennec\n \n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of\nSnuke's moves.\n\n* * *"}, {"input": "4\n 1 4\n 4 2\n 2 3", "output": "Snuke"}]
If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`. * * *
s505902746
Runtime Error
p03660
Input is given from Standard Input in the following format: N a_1 b_1 : a_{N-1} b_{N-1}
N = int(input()) edges = [[] for _ in range(N)] for _ in range(N): A, B = map(int, input().split()) edges[A - 1].append(B - 1) edges[B - 1].append(A - 1) prevs = [0] * N def dfs(prev, curr): prevs[curr] = prev if curr == N - 1: return for c in edges[curr]: if c != prev: dfs(curr, c) dfs(-1, 0) paths = [N - 1] tmp = N - 1 while tmp != 0: paths.append(prevs[tmp]) tmp = prevs[tmp] points = [0, 0] def count(prev, curr, player): points[player] += 1 for c in edges[curr]: if c != prev: count(curr, c, player) nf = (len(paths) + 1) // 2 f, s = paths[nf - 1], paths[nf] count(s, f, 0) count(f, s, 1) pf, ps = points print("Fennec" if pf > ps else "Snuke")
Statement Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
[{"input": "7\n 3 6\n 1 2\n 3 1\n 7 4\n 5 7\n 1 4", "output": "Fennec\n \n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of\nSnuke's moves.\n\n* * *"}, {"input": "4\n 1 4\n 4 2\n 2 3", "output": "Snuke"}]
If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`. * * *
s964240065
Accepted
p03660
Input is given from Standard Input in the following format: N a_1 b_1 : a_{N-1} b_{N-1}
# coding=UTF-8 N = int(input()) moti = list(range(0, N, 1)) # initalize for idx in range(0, N, 1): moti[idx] = [] # input for idx in range(0, N - 1, 1): mozir = input() hyo = mozir.split(" ") a = int(hyo[0]) - 1 b = int(hyo[1]) - 1 moti[a].append(b) moti[b].append(a) # path 0 to N-1 # width serach belong = list(range(0, N, 1)) for idx in range(0, N, 1): belong[idx] = None belong[0] = "F" belong[N - 1] = "S" fennec_watch = [0] sunuke_watch = [N - 1] fennec_haven = 1 sunuke_haven = 1 fennec_zou = 1 # for breaking cond sunuke_zou = 1 # also Teban = "F" while True: if Teban == "F": fennec_next = [] for mono in fennec_watch: kouho = moti[mono] for butu in kouho: if belong[butu] == None: fennec_next.append(butu) belong[butu] = "F" fennec_watch = fennec_next fennec_zou = len(fennec_next) fennec_haven = fennec_haven + fennec_zou else: sunuke_next = [] for mono in sunuke_watch: kouho = moti[mono] for butu in kouho: if belong[butu] == None: sunuke_next.append(butu) belong[butu] = "S" sunuke_watch = sunuke_next sunuke_zou = len(sunuke_next) sunuke_haven = sunuke_haven + sunuke_zou if fennec_zou == 0 and sunuke_zou == 0: break Teban = "F" if Teban == "S" else "S" # when fennec_haven==sunuke_haven==k # k+1 th turn fennec 33-4 if fennec_haven > sunuke_haven: print("Fennec") else: print("Snuke")
Statement Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
[{"input": "7\n 3 6\n 1 2\n 3 1\n 7 4\n 5 7\n 1 4", "output": "Fennec\n \n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of\nSnuke's moves.\n\n* * *"}, {"input": "4\n 1 4\n 4 2\n 2 3", "output": "Snuke"}]
If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`. * * *
s736598081
Accepted
p03660
Input is given from Standard Input in the following format: N a_1 b_1 : a_{N-1} b_{N-1}
N = int(input()) S = [[] for i in range(N)] for i in range(N - 1): a, b = map(int, input().split()) S[a - 1].append(b - 1) S[b - 1].append(a - 1) M = [0] * N M[0], M[N - 1] = 1, -1 # 1=黒=フェネック F_que = S[0] S_que = S[-1] while F_que != S_que: n_que = [] for i in F_que: if M[i] == 0: M[i] = 1 for j in S[i]: n_que.append(j) F_que = n_que n_que = [] for i in S_que: if M[i] == 0: M[i] = -1 for j in S[i]: n_que.append(j) S_que = n_que print(["Snuke", "Fennec"][sum(M) > 0])
Statement Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree. Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn: * Fennec: selects an uncolored cell that is adjacent to a **black** cell, and paints it **black**. * Snuke: selects an uncolored cell that is adjacent to a **white** cell, and paints it **white**. A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
[{"input": "7\n 3 6\n 1 2\n 3 1\n 7 4\n 5 7\n 1 4", "output": "Fennec\n \n\nFor example, if Fennec first paints Cell 2 black, she will win regardless of\nSnuke's moves.\n\n* * *"}, {"input": "4\n 1 4\n 4 2\n 2 3", "output": "Snuke"}]
If a tuple of subsets of \\{1,2,...N\\} that satisfies the conditions does not exist, print `No`. If such a tuple exists, print `Yes` first, then print such subsets in the following format: k |S_1| S_{1,1} S_{1,2} ... S_{1,|S_1|} : |S_k| S_{k,1} S_{k,2} ... S_{k,|S_k|} where S_i={S_{i,1},S_{i,2},...,S_{i,|S_i|}}. If there are multiple such tuples, any of them will be accepted. * * *
s768541646
Accepted
p03230
Input is given from Standard Input in the following format: N
n = int(input()) tri = [1] for i in range(2, 450): tri.append(i * (i + 1) // 2) if not n in tri: exit(print("No")) print("Yes") ind = tri.index(n) + 2 ans = [[] for i in range(ind)] cur = 1 print(ind) for i in range(ind): for j in range(i + 1, ind): ans[i].append(cur) ans[j].append(cur) cur += 1 for i in ans: print(len(i), *i)
Statement You are given an integer N. Determine if there exists a tuple of subsets of \\{1,2,...N\\}, (S_1,S_2,...,S_k), that satisfies the following conditions: * Each of the integers 1,2,...,N is contained in exactly two of the sets S_1,S_2,...,S_k. * Any two of the sets S_1,S_2,...,S_k have exactly one element in common. If such a tuple exists, construct one such tuple.
[{"input": "3", "output": "Yes\n 3\n 2 1 2\n 2 3 1\n 2 2 3\n \n\nIt can be seen that (S_1,S_2,S_3)=(\\\\{1,2\\\\},\\\\{3,1\\\\},\\\\{2,3\\\\}) satisfies\nthe conditions.\n\n* * *"}, {"input": "4", "output": "No"}]
If a tuple of subsets of \\{1,2,...N\\} that satisfies the conditions does not exist, print `No`. If such a tuple exists, print `Yes` first, then print such subsets in the following format: k |S_1| S_{1,1} S_{1,2} ... S_{1,|S_1|} : |S_k| S_{k,1} S_{k,2} ... S_{k,|S_k|} where S_i={S_{i,1},S_{i,2},...,S_{i,|S_i|}}. If there are multiple such tuples, any of them will be accepted. * * *
s627241066
Runtime Error
p03230
Input is given from Standard Input in the following format: N
N = int(input()) k = 1 n = 0 while n < N: n += k k += 1 if n!=N: print('No') exit() print('Yes') print(k) ans = [[] for _ in range(k)] v = 1 for i in range(k-1): for j in range(i+1,k): ans[i].append(v) ans[j].append(v) v += 1 for row in ans: print(len(row)+ *row))
Statement You are given an integer N. Determine if there exists a tuple of subsets of \\{1,2,...N\\}, (S_1,S_2,...,S_k), that satisfies the following conditions: * Each of the integers 1,2,...,N is contained in exactly two of the sets S_1,S_2,...,S_k. * Any two of the sets S_1,S_2,...,S_k have exactly one element in common. If such a tuple exists, construct one such tuple.
[{"input": "3", "output": "Yes\n 3\n 2 1 2\n 2 3 1\n 2 2 3\n \n\nIt can be seen that (S_1,S_2,S_3)=(\\\\{1,2\\\\},\\\\{3,1\\\\},\\\\{2,3\\\\}) satisfies\nthe conditions.\n\n* * *"}, {"input": "4", "output": "No"}]
If a tuple of subsets of \\{1,2,...N\\} that satisfies the conditions does not exist, print `No`. If such a tuple exists, print `Yes` first, then print such subsets in the following format: k |S_1| S_{1,1} S_{1,2} ... S_{1,|S_1|} : |S_k| S_{k,1} S_{k,2} ... S_{k,|S_k|} where S_i={S_{i,1},S_{i,2},...,S_{i,|S_i|}}. If there are multiple such tuples, any of them will be accepted. * * *
s680275071
Runtime Error
p03230
Input is given from Standard Input in the following format: N
N = int(input()) if N == 3: print("Yes") print(3) print(2,1,2) print(2,3,1) print(2,2,3) elif N == 1: print("Yes") print(2) print(1, 1) print(1, 1) else("No")
Statement You are given an integer N. Determine if there exists a tuple of subsets of \\{1,2,...N\\}, (S_1,S_2,...,S_k), that satisfies the following conditions: * Each of the integers 1,2,...,N is contained in exactly two of the sets S_1,S_2,...,S_k. * Any two of the sets S_1,S_2,...,S_k have exactly one element in common. If such a tuple exists, construct one such tuple.
[{"input": "3", "output": "Yes\n 3\n 2 1 2\n 2 3 1\n 2 2 3\n \n\nIt can be seen that (S_1,S_2,S_3)=(\\\\{1,2\\\\},\\\\{3,1\\\\},\\\\{2,3\\\\}) satisfies\nthe conditions.\n\n* * *"}, {"input": "4", "output": "No"}]
If a tuple of subsets of \\{1,2,...N\\} that satisfies the conditions does not exist, print `No`. If such a tuple exists, print `Yes` first, then print such subsets in the following format: k |S_1| S_{1,1} S_{1,2} ... S_{1,|S_1|} : |S_k| S_{k,1} S_{k,2} ... S_{k,|S_k|} where S_i={S_{i,1},S_{i,2},...,S_{i,|S_i|}}. If there are multiple such tuples, any of them will be accepted. * * *
s150993258
Runtime Error
p03230
Input is given from Standard Input in the following format: N
import itertools import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) n = int(input()) a = 0 for i in range(n // 2): if n*2 == combinations_count(n, i): a = i for j in itertools.combinations(n, a): print(len(j),j)
Statement You are given an integer N. Determine if there exists a tuple of subsets of \\{1,2,...N\\}, (S_1,S_2,...,S_k), that satisfies the following conditions: * Each of the integers 1,2,...,N is contained in exactly two of the sets S_1,S_2,...,S_k. * Any two of the sets S_1,S_2,...,S_k have exactly one element in common. If such a tuple exists, construct one such tuple.
[{"input": "3", "output": "Yes\n 3\n 2 1 2\n 2 3 1\n 2 2 3\n \n\nIt can be seen that (S_1,S_2,S_3)=(\\\\{1,2\\\\},\\\\{3,1\\\\},\\\\{2,3\\\\}) satisfies\nthe conditions.\n\n* * *"}, {"input": "4", "output": "No"}]
If a tuple of subsets of \\{1,2,...N\\} that satisfies the conditions does not exist, print `No`. If such a tuple exists, print `Yes` first, then print such subsets in the following format: k |S_1| S_{1,1} S_{1,2} ... S_{1,|S_1|} : |S_k| S_{k,1} S_{k,2} ... S_{k,|S_k|} where S_i={S_{i,1},S_{i,2},...,S_{i,|S_i|}}. If there are multiple such tuples, any of them will be accepted. * * *
s927536888
Wrong Answer
p03230
Input is given from Standard Input in the following format: N
print("Yes") print(3) print("2 2 3") print("2 3 1") print("2 1 2")
Statement You are given an integer N. Determine if there exists a tuple of subsets of \\{1,2,...N\\}, (S_1,S_2,...,S_k), that satisfies the following conditions: * Each of the integers 1,2,...,N is contained in exactly two of the sets S_1,S_2,...,S_k. * Any two of the sets S_1,S_2,...,S_k have exactly one element in common. If such a tuple exists, construct one such tuple.
[{"input": "3", "output": "Yes\n 3\n 2 1 2\n 2 3 1\n 2 2 3\n \n\nIt can be seen that (S_1,S_2,S_3)=(\\\\{1,2\\\\},\\\\{3,1\\\\},\\\\{2,3\\\\}) satisfies\nthe conditions.\n\n* * *"}, {"input": "4", "output": "No"}]
If a tuple of subsets of \\{1,2,...N\\} that satisfies the conditions does not exist, print `No`. If such a tuple exists, print `Yes` first, then print such subsets in the following format: k |S_1| S_{1,1} S_{1,2} ... S_{1,|S_1|} : |S_k| S_{k,1} S_{k,2} ... S_{k,|S_k|} where S_i={S_{i,1},S_{i,2},...,S_{i,|S_i|}}. If there are multiple such tuples, any of them will be accepted. * * *
s934125487
Accepted
p03230
Input is given from Standard Input in the following format: N
#!/usr/bin/env python3 import sys from typing import ( Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union, ) # import time # import math # import numpy as np # import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall # import random # random, uniform, randint, randrange, shuffle, sample # import string # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits # import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s) # from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]). # from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate() # from collections import defaultdict # subclass of dict. defaultdict(facroty) # from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter) # from datetime import date, datetime # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj # from datetime.datetime import strptime # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj # from datetime import timedelta # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available. # from copy import copy, deepcopy # use deepcopy to copy multi-dimentional matrix without reference # from functools import reduce # reduce(f, iter[, init]) # from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed) # from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn). # from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn). # from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n]) # from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])] # from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9] # from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r]) from itertools import combinations, combinations_with_replacement # from itertools import accumulate # accumulate(iter[, f]) # from operator import itemgetter # itemgetter(1), itemgetter('key') # from fractions import Fraction # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10) def main(): mod = 1000000007 # 10^9+7 inf = float("inf") # sys.float_info.max = 1.79e+308 # inf = 2 ** 63 - 1 # (for fast JIT compile in PyPy) 9.22e+18 sys.setrecursionlimit(10**6) # 1000 -> 1000000 def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def isp(): return input().split() def mi(): return map(int, input().split()) def mi_0(): return map(lambda x: int(x) - 1, input().split()) def lmi(): return list(map(int, input().split())) def lmi_0(): return list(map(lambda x: int(x) - 1, input().split())) def li(): return list(input()) def check_k(n): for k in range(2, 10**3): if k * (k - 1) > 2 * n: return -1 if k * (k - 1) == 2 * n: return k n = ii() k = check_k(n) if k == -1: print("No") else: print("Yes") print(k) num = 0 groups = [[] for _ in range(k)] for pattern in combinations(range(k), r=2): num += 1 a, b = pattern groups[a].append(num) groups[b].append(num) for g in groups: print(2 * n // k, end=" ") print(*g, sep=" ") if __name__ == "__main__": main()
Statement You are given an integer N. Determine if there exists a tuple of subsets of \\{1,2,...N\\}, (S_1,S_2,...,S_k), that satisfies the following conditions: * Each of the integers 1,2,...,N is contained in exactly two of the sets S_1,S_2,...,S_k. * Any two of the sets S_1,S_2,...,S_k have exactly one element in common. If such a tuple exists, construct one such tuple.
[{"input": "3", "output": "Yes\n 3\n 2 1 2\n 2 3 1\n 2 2 3\n \n\nIt can be seen that (S_1,S_2,S_3)=(\\\\{1,2\\\\},\\\\{3,1\\\\},\\\\{2,3\\\\}) satisfies\nthe conditions.\n\n* * *"}, {"input": "4", "output": "No"}]
If a tuple of subsets of \\{1,2,...N\\} that satisfies the conditions does not exist, print `No`. If such a tuple exists, print `Yes` first, then print such subsets in the following format: k |S_1| S_{1,1} S_{1,2} ... S_{1,|S_1|} : |S_k| S_{k,1} S_{k,2} ... S_{k,|S_k|} where S_i={S_{i,1},S_{i,2},...,S_{i,|S_i|}}. If there are multiple such tuples, any of them will be accepted. * * *
s739700514
Runtime Error
p03230
Input is given from Standard Input in the following format: N
import sys,collections as cl,bisect as bs sys.setrecursionlimit(100000) input = sys.stdin.readline mod = 10**9+7 Max = sys.maxsize def l(): #intのlist return list(map(int,input().split())) def m(): #複数文字 return map(int,input().split()) def onem(): #Nとかの取得 return int(input()) def s(x): #圧縮 a = [] if len(x) == 0: return [] aa = x[0] su = 1 for i in range(len(x)-1): if aa != x[i+1]: a.append([aa,su]) aa = x[i+1] su = 1 else: su += 1 a.append([aa,su]) return a def jo(x): #listをスペースごとに分ける return " ".join(map(str,x)) def max2(x): #他のときもどうように作成可能 return max(map(max,x)) def In(x,a): #aがリスト(sorted) k = bs.bisect_left(a,x) if k != len(a) and a[k] == x: return True else: return False """ def nibu(x,n,r): ll = 0 rr = r while True: mid = (ll+rr)//2 if rr == mid: return ll if (ここに評価入れる): rr = mid else: ll = mid+1 """ n=onem() if not (n == 3 or n == 6 or (n % 2 == 2 and n >= 3): print(-1)
Statement You are given an integer N. Determine if there exists a tuple of subsets of \\{1,2,...N\\}, (S_1,S_2,...,S_k), that satisfies the following conditions: * Each of the integers 1,2,...,N is contained in exactly two of the sets S_1,S_2,...,S_k. * Any two of the sets S_1,S_2,...,S_k have exactly one element in common. If such a tuple exists, construct one such tuple.
[{"input": "3", "output": "Yes\n 3\n 2 1 2\n 2 3 1\n 2 2 3\n \n\nIt can be seen that (S_1,S_2,S_3)=(\\\\{1,2\\\\},\\\\{3,1\\\\},\\\\{2,3\\\\}) satisfies\nthe conditions.\n\n* * *"}, {"input": "4", "output": "No"}]
If a tuple of subsets of \\{1,2,...N\\} that satisfies the conditions does not exist, print `No`. If such a tuple exists, print `Yes` first, then print such subsets in the following format: k |S_1| S_{1,1} S_{1,2} ... S_{1,|S_1|} : |S_k| S_{k,1} S_{k,2} ... S_{k,|S_k|} where S_i={S_{i,1},S_{i,2},...,S_{i,|S_i|}}. If there are multiple such tuples, any of them will be accepted. * * *
s634631609
Accepted
p03230
Input is given from Standard Input in the following format: N
ans_data = [] def get_num_shugou(num): num_shuugou = -1 for i in range(1, num + 2): if 2 * num == i * (i - 1): num_shuugou = i break elif 2 * num < i * (i - 1): break return num_shuugou def get_piramid(num_shuugou): piramid = [[1]] for i in range(num_shuugou - 2): data = [piramid[-1][-1] + j + 1 for j in range(len(piramid) + 1)] piramid.append(data) return piramid def data_append(now_list): print("{} {}".format(len(now_list), " ".join(list(map(str, now_list))))) def make_data(high, width, piramid, now_list_kari, down_flg): now_list = now_list_kari.copy() now_list.append(piramid[high][width]) if len(now_list) == len(piramid): data_append(now_list) return if down_flg: make_data(high + 1, width, piramid, now_list, down_flg) elif width == len(piramid[high]) - 1: down_flg = 1 make_data(high + 1, width, piramid, now_list, down_flg) else: make_data(high, width + 1, piramid, now_list, down_flg) def write_shugou(num_shuugou): piramid = get_piramid(num_shuugou) now_list = [piramid[i][-1] for i in range(len(piramid))] data_append(now_list) for i in range(num_shuugou - 1): make_data(i, 0, piramid, [], 0) def main(): num = int(input()) num_shuugou = get_num_shugou(num) if num_shuugou == -1: print("No") else: print("Yes") print(num_shuugou) write_shugou(num_shuugou) if __name__ == "__main__": main()
Statement You are given an integer N. Determine if there exists a tuple of subsets of \\{1,2,...N\\}, (S_1,S_2,...,S_k), that satisfies the following conditions: * Each of the integers 1,2,...,N is contained in exactly two of the sets S_1,S_2,...,S_k. * Any two of the sets S_1,S_2,...,S_k have exactly one element in common. If such a tuple exists, construct one such tuple.
[{"input": "3", "output": "Yes\n 3\n 2 1 2\n 2 3 1\n 2 2 3\n \n\nIt can be seen that (S_1,S_2,S_3)=(\\\\{1,2\\\\},\\\\{3,1\\\\},\\\\{2,3\\\\}) satisfies\nthe conditions.\n\n* * *"}, {"input": "4", "output": "No"}]
Print the number of possible values of the sum, modulo (10^9+7). * * *
s470063401
Accepted
p02708
Input is given from Standard Input in the following format: N K
nk = [int(s) for s in input().split()] n, k = nk[0], nk[1] tot = 0 all_sums = [0] for i in range(1, 200001): all_sums.append(i + all_sums[-1]) for i in range(k, n + 1): tot = (tot + (all_sums[n] - all_sums[n - i]) - (all_sums[i - 1]) + 1) % 1000000007 print(tot + 1)
Statement We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).
[{"input": "3 2", "output": "10\n \n\nThe sum can take 10 values, as follows:\n\n * (10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n * (10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n * (10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n * (10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n * (10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n * (10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n * (10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n * (10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n * (10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n * (10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\n* * *"}, {"input": "200000 200001", "output": "1\n \n\nWe must choose all of the integers, so the sum can take just 1 value.\n\n* * *"}, {"input": "141421 35623", "output": "220280457"}]
Print the number of possible values of the sum, modulo (10^9+7). * * *
s648947274
Accepted
p02708
Input is given from Standard Input in the following format: N K
N = [int(e) for e in input().split()] nums = [] u = 10**9 + 7 t = 0 s = 0 Min = 0 Max = 0 for i in range(0, N[1]): Min += i t = i + 1 Max += N[0] - i s = N[0] - i - 1 ans = Max - Min + 1 for k in range(N[1] + 1, N[0] + 2): Min += t t += 1 Max += s s -= 1 ans += Max - Min + 1 print(ans % u)
Statement We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).
[{"input": "3 2", "output": "10\n \n\nThe sum can take 10 values, as follows:\n\n * (10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n * (10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n * (10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n * (10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n * (10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n * (10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n * (10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n * (10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n * (10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n * (10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\n* * *"}, {"input": "200000 200001", "output": "1\n \n\nWe must choose all of the integers, so the sum can take just 1 value.\n\n* * *"}, {"input": "141421 35623", "output": "220280457"}]
Print the number of possible values of the sum, modulo (10^9+7). * * *
s517527194
Wrong Answer
p02708
Input is given from Standard Input in the following format: N K
NK = input().split(" ") N, K = int(NK[0]), int(NK[1]) number = 0 base = 0 m = 0 h = 0 for i in range(0, N + 1): m += N - i h += i # print(m ,h) if i >= K - 1 and i <= N + 1: number += m - h + 1 print(number)
Statement We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).
[{"input": "3 2", "output": "10\n \n\nThe sum can take 10 values, as follows:\n\n * (10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n * (10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n * (10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n * (10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n * (10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n * (10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n * (10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n * (10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n * (10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n * (10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\n* * *"}, {"input": "200000 200001", "output": "1\n \n\nWe must choose all of the integers, so the sum can take just 1 value.\n\n* * *"}, {"input": "141421 35623", "output": "220280457"}]
Print the number of possible values of the sum, modulo (10^9+7). * * *
s025803069
Wrong Answer
p02708
Input is given from Standard Input in the following format: N K
1
Statement We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).
[{"input": "3 2", "output": "10\n \n\nThe sum can take 10 values, as follows:\n\n * (10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n * (10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n * (10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n * (10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n * (10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n * (10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n * (10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n * (10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n * (10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n * (10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\n* * *"}, {"input": "200000 200001", "output": "1\n \n\nWe must choose all of the integers, so the sum can take just 1 value.\n\n* * *"}, {"input": "141421 35623", "output": "220280457"}]
Print the number of possible values of the sum, modulo (10^9+7). * * *
s420996548
Wrong Answer
p02708
Input is given from Standard Input in the following format: N K
a = list(map(int, input().split())) N = a[0] k = a[1] n = N - k + 2 w = int( (-n * (n + 1) * (2 * n + 1) + (N - 2 * k + 3) * n * (n + 1)) / 2 + n * ((k - 1) * (N - k + 2) + 1) ) print(w)
Statement We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).
[{"input": "3 2", "output": "10\n \n\nThe sum can take 10 values, as follows:\n\n * (10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n * (10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n * (10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n * (10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n * (10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n * (10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n * (10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n * (10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n * (10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n * (10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\n* * *"}, {"input": "200000 200001", "output": "1\n \n\nWe must choose all of the integers, so the sum can take just 1 value.\n\n* * *"}, {"input": "141421 35623", "output": "220280457"}]
Print the number of possible values of the sum, modulo (10^9+7). * * *
s300504089
Accepted
p02708
Input is given from Standard Input in the following format: N K
N, K = list(map(int, input().split(" "))) # Memo: # sum of k numbers from 0 ~ N # -> min: k(k-1)/2 # max: min + k(N-k+1) # -> num of sum patterns: k(N-k+1)+1 # sum up values above from k=K to k=N+1 val = (N * (N + 1) * (N + 2) - K * (K - 1) * (3 * N - 2 * K + 4)) // 6 + N + 2 - K print(val % (10**9 + 7))
Statement We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).
[{"input": "3 2", "output": "10\n \n\nThe sum can take 10 values, as follows:\n\n * (10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n * (10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n * (10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n * (10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n * (10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n * (10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n * (10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n * (10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n * (10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n * (10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\n* * *"}, {"input": "200000 200001", "output": "1\n \n\nWe must choose all of the integers, so the sum can take just 1 value.\n\n* * *"}, {"input": "141421 35623", "output": "220280457"}]
Print the number of possible values of the sum, modulo (10^9+7). * * *
s635864685
Accepted
p02708
Input is given from Standard Input in the following format: N K
N, k = map(int, input().split()) n = N + 1 a1 = -(n**3 - k**3) * 2 a2 = -(n**2 + k**2) * 3 a3 = -(n - k) * 1 A = (a1 + a2 + a3) // 6 B = n * (n + k) * (n - k + 1) // 2 C = n - k + 1 print((A + B + C) % (10**9 + 7))
Statement We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).
[{"input": "3 2", "output": "10\n \n\nThe sum can take 10 values, as follows:\n\n * (10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n * (10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n * (10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n * (10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n * (10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n * (10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n * (10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n * (10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n * (10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n * (10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\n* * *"}, {"input": "200000 200001", "output": "1\n \n\nWe must choose all of the integers, so the sum can take just 1 value.\n\n* * *"}, {"input": "141421 35623", "output": "220280457"}]
Print the number of possible values of the sum, modulo (10^9+7). * * *
s660195077
Runtime Error
p02708
Input is given from Standard Input in the following format: N K
def check(s, i, c): if i >= len(s): return c if int(s[i : i + 4]) % 2019 == 0: c += 1 return check(s, i + 4, c) elif ( len(str(int(s[i : i + 5]))) == 5 and int(s[i : i + 5]) % 2019 == 0 and int(s[i : i + 5]) != int(s[i : i + 4]) ): c += 1 return check(s, i + 5, c) else: return c s = input() cnt = 0 li = [] for i in range(0, len(s) - 3): a = int(s[i : i + 4]) b = int(s[i : i + 5]) if a % 2019 == 0: cnt += 1 cnt += check(s, i + 4, 0) if b % 2019 == 0 and len(str(b)) == 5: cnt += 1 cnt += check(s, i + 5, 0) print(cnt)
Statement We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).
[{"input": "3 2", "output": "10\n \n\nThe sum can take 10 values, as follows:\n\n * (10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n * (10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n * (10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n * (10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n * (10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n * (10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n * (10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n * (10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n * (10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n * (10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\n* * *"}, {"input": "200000 200001", "output": "1\n \n\nWe must choose all of the integers, so the sum can take just 1 value.\n\n* * *"}, {"input": "141421 35623", "output": "220280457"}]
Print the number of possible values of the sum, modulo (10^9+7). * * *
s814358777
Accepted
p02708
Input is given from Standard Input in the following format: N K
Z = list(map(int, input().split())) N = Z[0] K = Z[1] x = int(N * (N + 1) * (N + 2) / 6 + (K - 1) * K * (2 * K - 3 * N - 4) / 6 + N + 2 - K) y = x % 1000000007 print(y)
Statement We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).
[{"input": "3 2", "output": "10\n \n\nThe sum can take 10 values, as follows:\n\n * (10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n * (10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n * (10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n * (10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n * (10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n * (10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n * (10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n * (10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n * (10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n * (10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\n* * *"}, {"input": "200000 200001", "output": "1\n \n\nWe must choose all of the integers, so the sum can take just 1 value.\n\n* * *"}, {"input": "141421 35623", "output": "220280457"}]
Print the number of possible values of the sum, modulo (10^9+7). * * *
s546109586
Accepted
p02708
Input is given from Standard Input in the following format: N K
N, K = [int(s) for s in input().split()] MOD = 10**9 + 7 a = N - K + 2 a += (N + 1) * (N * (N + 1) - K * (K - 1)) // 2 a -= N * (N + 1) * (2 * N + 1) // 6 a += K * (K - 1) * (2 * K - 1) // 6 print(a % MOD)
Statement We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).
[{"input": "3 2", "output": "10\n \n\nThe sum can take 10 values, as follows:\n\n * (10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n * (10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n * (10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n * (10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n * (10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n * (10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n * (10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n * (10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n * (10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n * (10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\n* * *"}, {"input": "200000 200001", "output": "1\n \n\nWe must choose all of the integers, so the sum can take just 1 value.\n\n* * *"}, {"input": "141421 35623", "output": "220280457"}]
Print the number of possible values of the sum, modulo (10^9+7). * * *
s852827197
Accepted
p02708
Input is given from Standard Input in the following format: N K
# -*- coding: utf-8 -*- """ Created on Sun Jul 5 00:28:02 2020 @author: Aruto Hosaka """ def modinv(a, mod=10**9 + 7): return pow(a, mod - 2, mod) mod = 10**9 + 7 N, K = map(int, input().split()) ans1 = N + 1 ans1 *= N + K + 1 ans1 %= mod ans1 *= N + 2 - K ans1 %= mod ans1 *= modinv(2) ans1 %= mod ans2 = N + 1 ans2 *= N + 2 ans2 %= mod ans2 *= 2 * N + 3 ans2 %= mod ans2 *= modinv(6) ans2 %= mod ans3 = K - 1 ans3 *= K ans3 %= mod ans3 *= 2 * K - 1 ans3 %= mod ans3 *= modinv(6) ans3 %= mod ans4 = N + 2 - K ans = ans1 - ans2 + ans3 + ans4 ans %= mod print(ans)
Statement We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).
[{"input": "3 2", "output": "10\n \n\nThe sum can take 10 values, as follows:\n\n * (10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n * (10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n * (10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n * (10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n * (10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n * (10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n * (10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n * (10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n * (10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n * (10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\n* * *"}, {"input": "200000 200001", "output": "1\n \n\nWe must choose all of the integers, so the sum can take just 1 value.\n\n* * *"}, {"input": "141421 35623", "output": "220280457"}]
Print the number of possible values of the sum, modulo (10^9+7). * * *
s358449019
Wrong Answer
p02708
Input is given from Standard Input in the following format: N K
n, k = map(int, input().split()) a = [0] * 200099 for i in range(200099): a[i] = i s = 1 for i in range(n, k - 1, -1): s += sum(a[i : n + 1]) - sum(a[0 : n - i + 1]) + 1 print(s)
Statement We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).
[{"input": "3 2", "output": "10\n \n\nThe sum can take 10 values, as follows:\n\n * (10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n * (10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n * (10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n * (10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n * (10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n * (10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n * (10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n * (10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n * (10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n * (10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\n* * *"}, {"input": "200000 200001", "output": "1\n \n\nWe must choose all of the integers, so the sum can take just 1 value.\n\n* * *"}, {"input": "141421 35623", "output": "220280457"}]
Print the number of possible values of the sum, modulo (10^9+7). * * *
s693918327
Runtime Error
p02708
Input is given from Standard Input in the following format: N K
# 初期入力 import numpy as np N, Q = (int(x) for x in input().split()) aa = 0 bb = 0 a = [0] b = [0] a_set = set() ki_kouzou = np.zeros((N + 1, 1), dtype=np.int32) ki_kouzou_dic = {i: set() for i in range(1, N + 1)} # 木の構造を入力 for i in range(1, N): # 直接つながっているところ。 aa, bb = (int(x) for x in input().split()) if bb in a_set: # 親子判定 頂点3⇒頂点2もありうる # np.append(ki_kouzou[bb,:],aa,axis=1) a_set.add(aa) ki_kouzou_dic[bb].add(aa) else: # np.append(ki_kouzou[aa,:],bb,axis=1) # ki_kouzou[aa].append(bb) ki_kouzou_dic[aa].add(bb) a_set.add(bb) a.append(aa) b.append(bb) # 間接的に繋がっているところ kansetu = {i: set() for i in range(1, N + 1)} for ki_key in range(1, N + 1): for v_v in ki_kouzou_dic[ki_key]: if v_v in ki_kouzou_dic.keys(): kansetu[ki_key] = kansetu[ki_key] | ki_kouzou_dic[v_v] for i in range(1, N + 1): ki_kouzou_dic[i] = ki_kouzou_dic[i] | kansetu[i] # 直接 + 間接 ki_kouzou_dic[i].add(i) # 各頂点自身はは必ずポイント加算あり # ポイント入力-計算 point = {i: 0 for i in range(1, N + 1)} pp = 0 xx = 0 for _ in range(Q): pp, xx = (int(x) for x in input().split()) for i in ki_kouzou_dic[pp]: point[i] += xx print(*point.values())
Statement We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).
[{"input": "3 2", "output": "10\n \n\nThe sum can take 10 values, as follows:\n\n * (10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n * (10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n * (10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n * (10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n * (10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n * (10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n * (10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n * (10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n * (10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n * (10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\n* * *"}, {"input": "200000 200001", "output": "1\n \n\nWe must choose all of the integers, so the sum can take just 1 value.\n\n* * *"}, {"input": "141421 35623", "output": "220280457"}]
Print the number of possible values of the sum, modulo (10^9+7). * * *
s249849495
Accepted
p02708
Input is given from Standard Input in the following format: N K
class Combination: def __init__(self, size, mod=10**9 + 7): self.size = size + 2 self.mod = mod self.fact = [1, 1] + [0] * size self.factInv = [1, 1] + [0] * size self.inv = [0, 1] + [0] * size for i in range(2, self.size): self.fact[i] = self.fact[i - 1] * i % self.mod self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod def npr(self, n, r): if n < r or n < 0 or r < 0: return 0 return self.fact[n] * self.factInv[n - r] % self.mod def ncr(self, n, r): if n < r or n < 0 or r < 0: return 0 return ( self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod ) def nhr(self, n, r): # 重複組合せ return self.ncr(n + r - 1, n - 1) def factN(self, n): if n < 0: return 0 return self.fact[n] N, K = map(int, input().split()) MOD = 10**9 + 7 S = N * (N + 1) // 2 ans = 1 for d in range(N + 1): if N - d < K: break mx = S - (d * (d + 1) // 2) mi = max(0, (N - d - 1) * ((N - d - 1) + 1) // 2) ans += (mx - mi + 1) % MOD ans %= MOD print(ans)
Statement We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).
[{"input": "3 2", "output": "10\n \n\nThe sum can take 10 values, as follows:\n\n * (10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n * (10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n * (10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n * (10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n * (10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n * (10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n * (10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n * (10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n * (10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n * (10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\n* * *"}, {"input": "200000 200001", "output": "1\n \n\nWe must choose all of the integers, so the sum can take just 1 value.\n\n* * *"}, {"input": "141421 35623", "output": "220280457"}]
For each input Monday-Saturday number, it should be printed, followed by a colon `:' and the list of its Monday-Saturday prime factors on a single line. Monday-Saturday prime factors should be listed in ascending order and each should be preceded by a space. All the Monday-Saturday prime factors should be printed only once even if they divide the input Monday-Saturday number more than once.
s269677604
Wrong Answer
p00735
The input is a sequence of lines each of which contains a single Monday- Saturday number. Each Monday-Saturday number is greater than 1 and less than 300000 (three hundred thousand). The end of the input is indicated by a line containing a single digit 1.
this_prime_num = [0 for i in range(300001)] for i in range(300001): if i % 7 == 1 or i % 7 == 6: this_prime_num[i] = 1 for i in range(2, 300001): j = i * 2 while this_prime_num[i] == 1 and j < len(this_prime_num): # print(j) this_prime_num[j] = 0 j += i this_primenum_list = [] for i in range(2, len(this_prime_num)): if this_prime_num[i]: this_primenum_list.append(i) print(this_primenum_list[:30]) ans_list = [] while True: n = int(input()) if n == 1: break i = 0 ans = [n] while this_primenum_list[i] <= n: # print(i) if n % this_primenum_list[i] == 0: ans.append(this_primenum_list[i]) i += 1 if i >= len(this_primenum_list): break ans_list.append(ans) for i in ans_list: print(str(i[0]) + ":", end="") for j in i[1:]: print("", end=" ") print(j, end="") print()
B: Monday-Saturday Prime Factors Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A positive integer whose remainder divided by 7 is either 1 or 6 is called a 7** _N_** +{1,6} number. But as it is hard to pronounce, we shall call it a _Monday-Saturday number_. For Monday-Saturday numbers _a_ and _b_ , we say _a_ is a Monday-Saturday divisor of _b_ if there exists a Monday-Saturday number _x_ such that _a_ _x_ = _b_. It is easy to show that for any Monday-Saturday numbers _a_ and _b_ , it holds that _a_ is a Monday-Saturday divisor of _b_ if and only if _a_ is a divisor of _b_ in the usual sense. We call a Monday-Saturday number a _Monday-Saturday prime_ if it is greater than 1 and has no Monday-Saturday divisors other than itself and 1. A Monday- Saturday number which is a prime in the usual sense is a Monday-Saturday prime but the converse does not always hold. For example, 27 is a Monday-Saturday prime although it is not a prime in the usual sense. We call a Monday-Saturday prime which is a Monday-Saturday divisor of a Monday-Saturday number _a_ a _Monday-Saturday prime factor_ of _a_. For example, 27 is one of the Monday- Saturday prime factors of 216, since 27 is a Monday-Saturday prime and 216 = 27 × 8 holds. Any Monday-Saturday number greater than 1 can be expressed as a product of one or more Monday-Saturday primes. The expression is not always unique even if differences in order are ignored. For example, 216 = 6 × 6 × 6 = 8 × 27 holds. Our contestants should write a program that outputs all Monday-Saturday prime factors of each input Monday-Saturday number.
[{"input": "262144\n 262200\n 279936\n 299998\n 1", "output": ": 6 8 13 15 20 22 55 99\n 262144: 8\n 262200: 6 8 15 20 50 57 69 76 92 190 230 475 575 874 2185\n 279936: 6 8 27\n 299998: 299998"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s709514315
Accepted
p03549
Input is given from Standard Input in the following format: N M
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math # from math import gcd import bisect from collections import defaultdict from collections import deque from functools import lru_cache ############# # Constants # ############# MOD = 10**9 + 7 INF = float("inf") ############# # Functions # ############# ######INPUT###### def inputI(): return int(input().strip()) def inputS(): return input().strip() def inputIL(): return list(map(int, input().split())) def inputSL(): return list(map(str, input().split())) def inputILs(n): return list(int(input()) for _ in range(n)) def inputSLs(n): return list(input().strip() for _ in range(n)) def inputILL(n): return [list(map(int, input().split())) for _ in range(n)] def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)] ######OUTPUT###### def Yes(): print("Yes") return def No(): print("No") return #####Inverse##### def inv(n): return pow(n, MOD - 2, MOD) ######Combination###### kaijo_memo = [] def kaijo(n): if len(kaijo_memo) > n: return kaijo_memo[n] if len(kaijo_memo) == 0: kaijo_memo.append(1) while len(kaijo_memo) <= n: kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD) return kaijo_memo[n] gyaku_kaijo_memo = [] def gyaku_kaijo(n): if len(gyaku_kaijo_memo) > n: return gyaku_kaijo_memo[n] if len(gyaku_kaijo_memo) == 0: gyaku_kaijo_memo.append(1) while len(gyaku_kaijo_memo) <= n: gyaku_kaijo_memo.append( gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD ) return gyaku_kaijo_memo[n] def nCr(n, r): if n == r: return 1 if n < r or r < 0: return 0 ret = 1 ret = ret * kaijo(n) % MOD ret = ret * gyaku_kaijo(r) % MOD ret = ret * gyaku_kaijo(n - r) % MOD return ret ######Factorization###### def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr == []: arr.append([n, 1]) return arr #####MakeDivisors###### def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) return divisors #####LCM##### def lcm(a, b): return a * b // gcd(a, b) #####BitCount##### def count_bit(n): count = 0 while n: n &= n - 1 count += 1 return count #####ChangeBase##### def Base_10_to_n(X, n): if int(X / n): return Base_10_to_n(int(X / n), n) + [X % n] return [X % n] ############# # Main Code # ############# N, M = inputIL() print((100 * (N - M) + 1900 * M) * 2**M)
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s982445807
Accepted
p03549
Input is given from Standard Input in the following format: N M
# import math # import copy # import sys # import bisect # input = sys.stdin.readline def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) def lcm(a, b): return (a * b) // gcd(a, b) def div(x): # 約数配列 div = [1] check = 2 while x != 1 and check <= int(x**0.5) + 2: if x % check == 0: div.append(check) while x % check == 0: x = x // check check += 1 if x != 1: div.append(x) return div def div2(x): # 素因数分解配列 div2 = [] check = 2 while x != 1 and check <= int(x**0.5) + 2: while x % check == 0: div2.append(check) x /= check check += 1 if x != 1: div2.append(x) return div2 def main(): # x,y = map(int,input().split()) x=1,y=2 # a = input().split() a=['1','2','3',...,'n'] # a = list(map(int,input().split())) a=[1,2,3,4,5,...,n] # li = input().split('T') FFFTFTTFF => li=['FFF', 'F', '', 'FF'] # 複数行の「1 2 3 4」型の入力を一配列に # x = sorted([list(map(int, input().split())) for _ in range(n)]) # ソート x.sort(key=lambda y:y[1]) # print("Yes") print("No") x=[[0 for _ in range(n)] for _ in range(n)] n, m = map(int, input().split()) time = 1900 * m + 100 * (n - m) print(time * (2**m)) main()
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s800220463
Accepted
p03549
Input is given from Standard Input in the following format: N M
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS(): return list(map(list, sys.stdin.readline().split())) def S(): return list(sys.stdin.readline())[:-1] def IR(n): l = [None for i in range(n)] for i in range(n): l[i] = I() return l def LIR(n): l = [None for i in range(n)] for i in range(n): l[i] = LI() return l def SR(n): l = [None for i in range(n)] for i in range(n): l[i] = S() return l def LSR(n): l = [None for i in range(n)] for i in range(n): l[i] = SR() return l mod = 1000000007 # A def A(): s = LS() t = sorted(s) if s[0] == s[1]: print("=") elif s[0] == t[0]: print("<") else: print(">") # B def B(): x, y, z = LI() k = 0 for i in range(1000000000): k += y + z if k + z > x: print(i) quit() # C def C(): n, m = LI() print((100 * n + 1800 * m) * 2**m) # D def D(): return # E def E(): return # F def F(): return # G def G(): return # H def H(): return # Solve if __name__ == "__main__": C()
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s349456870
Accepted
p03549
Input is given from Standard Input in the following format: N M
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(10000) # Debug output def chkprint(*args): names = {id(v): k for k, v in inspect.currentframe().f_back.f_locals.items()} print(", ".join(names.get(id(arg), "???") + " = " + repr(arg) for arg in args)) # Binary converter def to_bin(x): return bin(x)[2:] # Set 2 dimension list def dim2input(N): li = [] for _ in range(N): li.append(list(map(int, input()))) return li # -------------------------------------------- dp = None def main(): n_case, n_tle = list(map(int, input().split())) t_each_submit = 1900 * n_tle + 100 * (n_case - n_tle) mean_submit_times = 2**n_tle print(t_each_submit * mean_submit_times) main()
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s748739910
Wrong Answer
p03549
Input is given from Standard Input in the following format: N M
a, b = list(map(int, input().split())) print((b * 1900 + (a - b) * 100) * 2**a)
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s572754517
Accepted
p03549
Input is given from Standard Input in the following format: N M
n, m = [int(_) for _ in input().split()] x = 0 a = 1900 * m + 100 * (n - m) for k in range(1, 1000 + 1): x += ((1 - 0.5**m) ** (k - 1)) * (0.5**m) * k * a print(round(x))
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s327235361
Accepted
p03549
Input is given from Standard Input in the following format: N M
from sys import exit N, M = [int(n) for n in input().split()] # N = int(input()) # a = [int(input()) for _ in range(N)] # L = len(S) # T = str(input()) constant = (N - M) * 100 print((2**M) * (1900 * M + constant)) exit()
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s786559218
Accepted
p03549
Input is given from Standard Input in the following format: N M
n, m = map(int, input().split()) left = n - m sum = 0 sum += ((1900 * m) + (left * 100)) * (2**m) print(int(round(sum, 0)))
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s294675023
Runtime Error
p03549
Input is given from Standard Input in the following format: N M
n, m = map(int, input().split()) s100 = 100*(n - m) * 2**m s1900 = m * 1900 * 2**m print(s100 + s1900) \
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s787899439
Runtime Error
p03549
Input is given from Standard Input in the following format: N M
N ,M=map(float,input().split()) print(int((1900*M+100*(N-M)*2**M))
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s262548360
Wrong Answer
p03549
Input is given from Standard Input in the following format: N M
# 解けなかった
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s653920505
Runtime Error
p03549
Input is given from Standard Input in the following format: N M
a, b = map(int, input()) print((1900 * b + (a - b) * 100) * 2**b)
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s803657897
Runtime Error
p03549
Input is given from Standard Input in the following format: N M
N,M=map(int,input().split()) print((1900*M+100*(N-M))*(2**M)
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s658731425
Runtime Error
p03549
Input is given from Standard Input in the following format: N M
N,M=map(int,input()) ans=(1900M+100(N-M))*2^M print(ans)
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s272261662
Runtime Error
p03549
Input is given from Standard Input in the following format: N M
n,m=map(int,input().split()) print(2**m*(100n+1800m))
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s269228567
Runtime Error
p03549
Input is given from Standard Input in the following format: N M
N, M = map(int, input().split()) print((1900*M+100*(N-M))2**M)
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s724776499
Runtime Error
p03549
Input is given from Standard Input in the following format: N M
asdfghjkl
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s218030547
Runtime Error
p03549
Input is given from Standard Input in the following format: N M
N,M=map(int,input()) ans=1900M+100(N-M)*2^M
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s664246048
Runtime Error
p03549
Input is given from Standard Input in the following format: N M
a = input().split() b = input().split() if a[0] == b[2] and a[1]==b[1] and a[2] == b[0]): print("YES") else : print("NO")
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s427442635
Accepted
p03549
Input is given from Standard Input in the following format: N M
N, M = map(int, open(0).read().split()) print(pow(2, M) * ((1900 * M) + (100 * (N - M))))
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s118484384
Wrong Answer
p03549
Input is given from Standard Input in the following format: N M
a = input().split() A = int(a[0]) B = int(a[1]) print(B * 2 * (1900 * B + 100 * (A - B)))
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s620420022
Accepted
p03549
Input is given from Standard Input in the following format: N M
n, m = (int(i) for i in input().split()) prob = 2**m time = 1900 * m + 100 * (n - m) print(time * prob)
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s809667039
Accepted
p03549
Input is given from Standard Input in the following format: N M
N, M = list(map(int, input().split(" "))) kaisu = 2**M time = (N - M) * 100 + M * 1900 print(time * kaisu)
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]
Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. * * *
s529074297
Runtime Error
p03549
Input is given from Standard Input in the following format: N M
n = int(input()) i = 1 while True: if (i**2 + i) // 2 >= n: print(i) break i += 1
Statement Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
[{"input": "1 1", "output": "3800\n \n\nIn this input, there is only one case. Takahashi will repeatedly submit the\ncode that correctly solves this case with 1/2 probability in 1900\nmilliseconds.\n\nThe code will succeed in one attempt with 1/2 probability, in two attempts\nwith 1/4 probability, and in three attempts with 1/8 probability, and so on.\n\nThus, the answer is 1900 \\times 1/2 + (2 \\times 1900) \\times 1/4 + (3 \\times\n1900) \\times 1/8 + ... = 3800.\n\n* * *"}, {"input": "10 2", "output": "18400\n \n\nThe code will take 1900 milliseconds in each of the 2 cases, and 100\nmilliseconds in each of the 10-2=8 cases. The probability of the code\ncorrectly solving all the cases is 1/2 \\times 1/2 = 1/4.\n\n* * *"}, {"input": "100 5", "output": "608000"}]