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 |
|---|---|---|---|---|---|---|---|
If $p$ is in $s$, print Yes in a line, otherwise No. | s654121298 | Runtime Error | p02418 | In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given. | from bisect import bisect_left, bisect_right, insort_left
dict = {}
keytbl = []
q = int(input())
for i in range(q):
a = list(input().split())
ki = a[1]
if a[0] == "0":
if ki not in dict:
dict[ki] = []
insort_left(keytbl, ki)
dict[ki].append(int(a[2]))
elif a[0] == "1":
if ki in dict and dict[ki] != []:
print(*dict[ki], sep="\n")
elif a[0] == "2":
if ki in dict:
dict[ki] = []
else:
L = bisect_left(keytbl, a[1])
R = bisect_right(keytbl, a[2], L)
for j in range(L, R):
for k in dict[keytbl[j]]:
print(keytbl[j], k)
| Ring
Write a program which finds a pattern $p$ in a ring shaped text $s$.
 | [{"input": "vanceknowledgetoad\n advance", "output": "Yes"}, {"input": "vanceknowledgetoad\n advanced", "output": "No"}] |
If $p$ is in $s$, print Yes in a line, otherwise No. | s703341916 | Runtime Error | p02418 | In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given. | s = [input().string()]
print("endswith[a, start][e, end]")
| Ring
Write a program which finds a pattern $p$ in a ring shaped text $s$.
 | [{"input": "vanceknowledgetoad\n advance", "output": "Yes"}, {"input": "vanceknowledgetoad\n advanced", "output": "No"}] |
If $p$ is in $s$, print Yes in a line, otherwise No. | s671885432 | Wrong Answer | p02418 | In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given. | print("Yes" if 2 * input().find(input()) != -1 else "No")
| Ring
Write a program which finds a pattern $p$ in a ring shaped text $s$.
 | [{"input": "vanceknowledgetoad\n advance", "output": "Yes"}, {"input": "vanceknowledgetoad\n advanced", "output": "No"}] |
If $p$ is in $s$, print Yes in a line, otherwise No. | s584878012 | Wrong Answer | p02418 | In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given. | print("Yes") if (input() * 2).find(input()) > -1 else "No"
| Ring
Write a program which finds a pattern $p$ in a ring shaped text $s$.
 | [{"input": "vanceknowledgetoad\n advance", "output": "Yes"}, {"input": "vanceknowledgetoad\n advanced", "output": "No"}] |
If $p$ is in $s$, print Yes in a line, otherwise No. | s165415441 | Wrong Answer | p02418 | In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given. | print("Yes" if 2 * input().find(input()) >= -1 else "No")
| Ring
Write a program which finds a pattern $p$ in a ring shaped text $s$.
 | [{"input": "vanceknowledgetoad\n advance", "output": "Yes"}, {"input": "vanceknowledgetoad\n advanced", "output": "No"}] |
If $p$ is in $s$, print Yes in a line, otherwise No. | s829047768 | Accepted | p02418 | In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given. | text = input()
ptn = input()
print(["No", "Yes"][(text * 2).find(ptn) != -1])
| Ring
Write a program which finds a pattern $p$ in a ring shaped text $s$.
 | [{"input": "vanceknowledgetoad\n advance", "output": "Yes"}, {"input": "vanceknowledgetoad\n advanced", "output": "No"}] |
If $p$ is in $s$, print Yes in a line, otherwise No. | s303112937 | Accepted | p02418 | In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given. | n = str(input())
a = len(n)
N = list(n)
m = str(input())
A = len(m)
x = 0
for i in range(a):
C = []
for i in range(A):
C.append(N[i])
B = "".join(C)
c = N[0]
if B == m:
x = x + 1
N.remove(c)
N.append(c)
if x > 0:
print("Yes")
else:
print("No")
| Ring
Write a program which finds a pattern $p$ in a ring shaped text $s$.
 | [{"input": "vanceknowledgetoad\n advance", "output": "Yes"}, {"input": "vanceknowledgetoad\n advanced", "output": "No"}] |
If $p$ is in $s$, print Yes in a line, otherwise No. | s951843821 | Accepted | p02418 | In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given. | l = [x for x in input()]
l.extend(l)
ch = [x for x in input()]
txt = "No"
for i in range(len(l) - len(ch)):
for j in range(len(ch)):
if l[i + j] != ch[j]:
break
else:
txt = "Yes"
break
print(txt)
| Ring
Write a program which finds a pattern $p$ in a ring shaped text $s$.
 | [{"input": "vanceknowledgetoad\n advance", "output": "Yes"}, {"input": "vanceknowledgetoad\n advanced", "output": "No"}] |
If $p$ is in $s$, print Yes in a line, otherwise No. | s893763596 | Wrong Answer | p02418 | In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given. | # Belongs to : midandfeed aka asilentvoice
s = str(input()) * 2
q = str(input())
print(["NO", "YES"][q in s])
| Ring
Write a program which finds a pattern $p$ in a ring shaped text $s$.
 | [{"input": "vanceknowledgetoad\n advance", "output": "Yes"}, {"input": "vanceknowledgetoad\n advanced", "output": "No"}] |
If $p$ is in $s$, print Yes in a line, otherwise No. | s226491624 | Wrong Answer | p02418 | In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given. | from collections import deque
def main():
S = input()
P = input()
s = deque(S)
n = len(S)
for _ in range(n - 1):
s.append(s.popleft())
if P in "".join(s):
ans = "Yes"
break
else:
ans = "No"
print(ans)
main()
| Ring
Write a program which finds a pattern $p$ in a ring shaped text $s$.
 | [{"input": "vanceknowledgetoad\n advance", "output": "Yes"}, {"input": "vanceknowledgetoad\n advanced", "output": "No"}] |
Print the minimum possible value of N when the partition satisfies the
condition.
* * * | s180212823 | Wrong Answer | p03570 | Input is given from Standard Input in the following format:
s | from collections import defaultdict
import sys, heapq, bisect, math, itertools, string, queue, datetime
sys.setrecursionlimit(10**8)
INF = float("inf")
mod = 10**9 + 7
eps = 10**-7
AtoZ = [chr(i) for i in range(65, 65 + 26)]
atoz = [chr(i) for i in range(97, 97 + 26)]
def inpl():
return list(map(int, input().split()))
def inpl_s():
return list(input().split())
S = input()
num = [0] * 26
for s in S:
num[ord(s) - 97] += 1
tmp = 0
for n in num:
if n % 2 == 1:
tmp += 1
print(max(tmp, 1))
| Statement
We have a string s consisting of lowercase English letters. Snuke is
partitioning s into some number of non-empty substrings. Let the subtrings
obtained be s_1, s_2, ..., s_N from left to right. (Here, s = s_1 + s_2 + ...
+ s_N holds.) Snuke wants to satisfy the following condition:
* For each i (1 \leq i \leq N), it is possible to permute the characters in s_i and obtain a palindrome.
Find the minimum possible value of N when the partition satisfies the
condition. | [{"input": "aabxyyzz", "output": "2\n \n\nThe solution is to partition s as `aabxyyzz` = `aab` \\+ `xyyzz`. Here, `aab`\ncan be permuted to form a palindrome `aba`, and `xyyzz` can be permuted to\nform a palindrome `zyxyz`.\n\n* * *"}, {"input": "byebye", "output": "1\n \n\n`byebye` can be permuted to form a palindrome `byeeyb`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz", "output": "26\n \n\n* * *"}, {"input": "abcabcxabcx", "output": "3\n \n\nThe solution is to partition s as `abcabcxabcx` = `a` \\+ `b` \\+ `cabcxabcx`."}] |
Print the minimum possible value of N when the partition satisfies the
condition.
* * * | s806888532 | Runtime Error | p03570 | Input is given from Standard Input in the following format:
s | #! usr/bin/env python3
#D:
def is_kaibun (S):
#戻り値が0:回文,1:回文無理
l = len(S)
S.sort()
i = 0
if l % 2 == 1:
sign = 0
while True:
if i >= l-1:
return 0
elif S[i] == S[i+1]:
i += 2
else:
if sign == 1:
return 1
else:
sign += 1
i += 1
else:
while True:
if i >= l-1:
return 0
elif S[i] == S[i+1]:
i += 2
else:
return 1
def is_kaibun2(S):
if S[0] == S[1]:
return 0
else:
return 1
def is_kaibun3(S):
if (S[0] == S[1]) or (S[0] == S[2]) or (S[1] == S[2]):
return 0
else:
return 1
S = list(input())
devide = 0
def maxkaibun(S,front,last):
global devide
i = len(S)
for length in range(i,0,-1):
for start in range(i-length+1):
if length == 1:
devide += i
return 0
elif length == 2:
if (is_kaibun2(S[start:start+length+1]) == 0):
devide += 1
if (front == start) or ((start+length+1) == last):
return 0
maxkaibun(S[front:start],front,start)
maxkaibun(S[start+length+1:last],start+length+1,last)
return 0
elif length == 3:
if (is_kaibun3(S[start:start+length+1]) == 0):
devide += 1
if (front == start) or ((start+length+1) == last):
return 0
maxkaibun(S[front:start],front,start)
maxkaibun(S[start+length+1:last],start+length+1,last)
return 0
if (is_kaibun(S[start:start+length+1]) == 0):
devide += 1
if (front == start) or ((start+length+1) == last):
return 0
maxkaibun(S[front:start],front,start)
maxkaibun(S[start+length+1:last],start+length+1,last)
return 0
maxkaibun(S,0,len(S))
print(devide) | Statement
We have a string s consisting of lowercase English letters. Snuke is
partitioning s into some number of non-empty substrings. Let the subtrings
obtained be s_1, s_2, ..., s_N from left to right. (Here, s = s_1 + s_2 + ...
+ s_N holds.) Snuke wants to satisfy the following condition:
* For each i (1 \leq i \leq N), it is possible to permute the characters in s_i and obtain a palindrome.
Find the minimum possible value of N when the partition satisfies the
condition. | [{"input": "aabxyyzz", "output": "2\n \n\nThe solution is to partition s as `aabxyyzz` = `aab` \\+ `xyyzz`. Here, `aab`\ncan be permuted to form a palindrome `aba`, and `xyyzz` can be permuted to\nform a palindrome `zyxyz`.\n\n* * *"}, {"input": "byebye", "output": "1\n \n\n`byebye` can be permuted to form a palindrome `byeeyb`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz", "output": "26\n \n\n* * *"}, {"input": "abcabcxabcx", "output": "3\n \n\nThe solution is to partition s as `abcabcxabcx` = `a` \\+ `b` \\+ `cabcxabcx`."}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s703747930 | Wrong Answer | p02731 | Input is given from Standard Input in the following format:
L | n = int(input())
v = [0]
for i in range(1, n):
for j in range(1, n):
k = n - i - j
if k > 0:
v.append(i * j * k)
print(max(v))
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s325559979 | Wrong Answer | p02731 | Input is given from Standard Input in the following format:
L | L = int(input()) / 10
print(L**3 // 0.0027)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s614132213 | Accepted | p02731 | Input is given from Standard Input in the following format:
L | length = int(input()) / 3
print(length**3)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s590185222 | Accepted | p02731 | Input is given from Standard Input in the following format:
L | l = int(input().strip())
edge = l / 3
print(edge**3)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s223926684 | Accepted | p02731 | Input is given from Standard Input in the following format:
L | l = int(input())
ans_max = (l / 3) ** 3
for a in range(l):
min = l - a
max = l
mid = min + (max - min) // 2
for i in range(100):
if ans_max < a * mid * (l - a - mid):
ans_max = a * mid * (l - a - mid)
max = mid
print(ans_max)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s395455931 | Wrong Answer | p02731 | Input is given from Standard Input in the following format:
L | l = int(input())
max = 0
for x in range(l):
for y in range(l):
v = x * y * (l - x - y)
if v > max:
max = v
print(float(max))
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s330899963 | Runtime Error | p02731 | Input is given from Standard Input in the following format:
L | print(int(input() / 3) ** 3)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s499862159 | Runtime Error | p02731 | Input is given from Standard Input in the following format:
L | print(int(input() / 3**3))
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s777714065 | Runtime Error | p02731 | Input is given from Standard Input in the following format:
L | print((int(input()) / 3) ^ 3)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s052682316 | Wrong Answer | p02731 | Input is given from Standard Input in the following format:
L | print(int(input()) ^ 3)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s100600803 | Accepted | p02731 | Input is given from Standard Input in the following format:
L | no = int(input())
print(pow((no / 3), 3))
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s386599189 | Accepted | p02731 | Input is given from Standard Input in the following format:
L | print("{:.10}".format((float(input())) ** 3 / 27))
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s111794183 | Wrong Answer | p02731 | Input is given from Standard Input in the following format:
L | s = int(input())
a = s // 3
b = (s - a) // 2
print(a * b * (s - a - b))
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s241269980 | Wrong Answer | p02731 | Input is given from Standard Input in the following format:
L | q = input()
t = int(q)
print(t)
y = t / 3
u = t / 3
i = t / 3
print(y * u * i)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s557385119 | Accepted | p02731 | Input is given from Standard Input in the following format:
L | # hello
# password
# input
# understandign python
# less errors
# work now please
q = int(input())
w = q / 3
print(w**3)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s436912579 | Accepted | p02731 | Input is given from Standard Input in the following format:
L | print((float(input()) ** 3) / 27)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s328398391 | Accepted | p02731 | Input is given from Standard Input in the following format:
L | print((int(input()) ** 3 / 27))
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s454182546 | Accepted | p02731 | Input is given from Standard Input in the following format:
L | print((int(input())) ** 3 / 27)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s959082398 | Runtime Error | p02731 | Input is given from Standard Input in the following format:
L | print(float((input()) ** 3 / 27))
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s996642807 | Runtime Error | p02731 | Input is given from Standard Input in the following format:
L | print(((input()) / 3) ** 3)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s093275193 | Wrong Answer | p02731 | Input is given from Standard Input in the following format:
L | print(float(input()) / 3**3)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s306321072 | Runtime Error | p02731 | Input is given from Standard Input in the following format:
L | s = input(int())
print(s * s * s / 27)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s231591409 | Wrong Answer | p02731 | Input is given from Standard Input in the following format:
L | print((int(input()) // 3) ** 3)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s540283095 | Wrong Answer | p02731 | Input is given from Standard Input in the following format:
L | 999
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s689715960 | Runtime Error | p02731 | Input is given from Standard Input in the following format:
L | print(((int(input())) / 3) ^ 3)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s758932777 | Wrong Answer | p02731 | Input is given from Standard Input in the following format:
L | print(int(input()) / 3)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s589072868 | Runtime Error | p02731 | Input is given from Standard Input in the following format:
L | print((input() / 3.0) ** 3)
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the maximum possible volume of a rectangular cuboid whose sum of the
dimensions (not necessarily integers) is L. Your output is considered correct
if its absolute or relative error from our answer is at most 10^{-6}.
* * * | s178614375 | Runtime Error | p02731 | Input is given from Standard Input in the following format:
L | f = int(input()) / 3.0
print("{.9f}".format(f * f * f))
| Statement
Given is a positive integer L. Find the maximum possible volume of a
rectangular cuboid whose sum of the dimensions (not necessarily integers) is
L. | [{"input": "3", "output": "1.000000000000\n \n\nFor example, a rectangular cuboid whose dimensions are 0.8, 1, and 1.2 has a\nvolume of 0.96.\n\nOn the other hand, if the dimensions are 1, 1, and 1, the volume of the\nrectangular cuboid is 1, which is greater.\n\n* * *"}, {"input": "999", "output": "36926037.000000000000"}] |
Print the number of the different divisions under the conditions, modulo 10^9
+ 7.
* * * | s714079325 | Wrong Answer | p03823 | The input is given from Standard Input in the following format:
N A B
S_1
:
S_N | import sys
readline = sys.stdin.readline
class Lazysegtree:
# RUQ
def __init__(self, A, intv, initialize=True, segf=min):
# 区間は 1-indexed で管理
self.N = len(A)
self.N0 = 2 ** (self.N - 1).bit_length()
self.intv = intv
self.segf = segf
self.lazy = [None] * (2 * self.N0)
if initialize:
self.data = [intv] * self.N0 + A + [intv] * (self.N0 - self.N)
for i in range(self.N0 - 1, -1, -1):
self.data[i] = self.segf(self.data[2 * i], self.data[2 * i + 1])
else:
self.data = [intv] * (2 * self.N0)
def _ascend(self, k):
k = k >> 1
c = k.bit_length()
for j in range(c):
idx = k >> j
self.data[idx] = self.segf(self.data[2 * idx], self.data[2 * idx + 1])
def _descend(self, k):
k = k >> 1
idx = 1
c = k.bit_length()
for j in range(1, c + 1):
idx = k >> (c - j)
if self.lazy[idx] is None:
continue
self.data[2 * idx] = self.data[2 * idx + 1] = self.lazy[2 * idx] = (
self.lazy[2 * idx + 1]
) = self.lazy[idx]
self.lazy[idx] = None
def query(self, l, r):
L = l + self.N0
R = r + self.N0
self._descend(L // (L & -L))
self._descend(R // (R & -R) - 1)
s = self.intv
while L < R:
if R & 1:
R -= 1
s = self.segf(s, self.data[R])
if L & 1:
s = self.segf(s, self.data[L])
L += 1
L >>= 1
R >>= 1
return s
def update(self, l, r, x):
L = l + self.N0
R = r + self.N0
Li = L // (L & -L)
Ri = R // (R & -R)
self._descend(Li)
self._descend(Ri - 1)
while L < R:
if R & 1:
R -= 1
self.data[R] = x
self.lazy[R] = x
if L & 1:
self.data[L] = x
self.lazy[L] = x
L += 1
L >>= 1
R >>= 1
self._ascend(Li)
self._ascend(Ri - 1)
inf = 10**19
N, A, B = map(int, readline().split())
if A > B:
A, B = B, A
S = [-inf] + [int(readline()) for _ in range(N)]
MOD = 10**9 + 7
dpa = Lazysegtree([1] + [0] * N, 0, initialize=True, segf=lambda x, y: (x + y) % MOD)
dpb = Lazysegtree([1] + [0] * N, 0, initialize=True, segf=lambda x, y: (x + y) % MOD)
for i in range(1, N + 1):
oka = 0
ng = i
while abs(oka - ng) > 1:
med = (oka + ng) // 2
if S[i] - S[med] >= A:
oka = med
else:
ng = med
okb = 0
ng = i
while abs(okb - ng) > 1:
med = (okb + ng) // 2
if S[i] - S[med] >= B:
okb = med
else:
ng = med
dpa.update(i - 1, i, dpb.query(0, oka + 1))
dpb.update(i - 1, i, dpa.query(0, okb + 1))
if S[i] - S[i - 1] < A:
dpa.update(0, i - 1, 0)
if S[i] - S[i - 1] < B:
dpb.update(0, i - 1, 0)
print((dpa.query(0, N + 1) + dpb.query(0, N + 1)) % MOD)
| Statement
There is a set consisting of N distinct integers. The i-th smallest element in
this set is S_i. We want to divide this set into two sets, X and Y, such that:
* The absolute difference of any two distinct elements in X is A or greater.
* The absolute difference of any two distinct elements in Y is B or greater.
How many ways are there to perform such division, modulo 10^9 + 7? Note that
one of X and Y may be empty. | [{"input": "5 3 7\n 1\n 3\n 6\n 9\n 12", "output": "5\n \n\nThere are five ways to perform division:\n\n * X={1,6,9,12}, Y={3}\n * X={1,6,9}, Y={3,12}\n * X={3,6,9,12}, Y={1}\n * X={3,6,9}, Y={1,12}\n * X={3,6,12}, Y={1,9}\n\n* * *"}, {"input": "7 5 3\n 0\n 2\n 4\n 7\n 8\n 11\n 15", "output": "4\n \n\n* * *"}, {"input": "8 2 9\n 3\n 4\n 5\n 13\n 15\n 22\n 26\n 32", "output": "13\n \n\n* * *"}, {"input": "3 3 4\n 5\n 6\n 7", "output": "0"}] |
Print the number of the different divisions under the conditions, modulo 10^9
+ 7.
* * * | s252327852 | Accepted | p03823 | The input is given from Standard Input in the following format:
N A B
S_1
:
S_N | from bisect import bisect_left
N, A, B = map(int, input().split())
inf, mod = float("inf"), 10**9 + 7
S = [int(input()) for i in range(N)]
St_A = [0] * N
St_B = [0] * N
J_A, J_B = [0], [0]
for i in range(N):
St_A[i] = bisect_left(S, S[i] + A) - 1
St_B[i] = bisect_left(S, S[i] + B) - 1
J_A.append(J_A[-1] + int(St_A[i] != i))
J_B.append(J_B[-1] + int(St_B[i] != i))
# print(St_A,St_B)
# print(J_A,J_B)
dp_A = [0] * N
dp_B = [0] * N
dp_A[-1], dp_B[-1] = 1, 1
for i in range(N - 1)[::-1]:
if St_A[i] == i:
dp_A[i] = (dp_A[i + 1] + dp_B[i + 1]) % mod
else:
if J_B[St_A[i]] - J_B[i + 1] == 0:
dp_A[i] = dp_B[St_A[i]]
else:
dp_A[i] = 0
if St_B[i] == i:
dp_B[i] = (dp_A[i + 1] + dp_B[i + 1]) % mod
else:
if J_A[St_B[i]] - J_A[i + 1] == 0:
dp_B[i] = dp_A[St_B[i]]
else:
dp_B[i] = 0
# print(dp_A)
# print(dp_B)
print((dp_A[0] + dp_B[0]) % mod)
| Statement
There is a set consisting of N distinct integers. The i-th smallest element in
this set is S_i. We want to divide this set into two sets, X and Y, such that:
* The absolute difference of any two distinct elements in X is A or greater.
* The absolute difference of any two distinct elements in Y is B or greater.
How many ways are there to perform such division, modulo 10^9 + 7? Note that
one of X and Y may be empty. | [{"input": "5 3 7\n 1\n 3\n 6\n 9\n 12", "output": "5\n \n\nThere are five ways to perform division:\n\n * X={1,6,9,12}, Y={3}\n * X={1,6,9}, Y={3,12}\n * X={3,6,9,12}, Y={1}\n * X={3,6,9}, Y={1,12}\n * X={3,6,12}, Y={1,9}\n\n* * *"}, {"input": "7 5 3\n 0\n 2\n 4\n 7\n 8\n 11\n 15", "output": "4\n \n\n* * *"}, {"input": "8 2 9\n 3\n 4\n 5\n 13\n 15\n 22\n 26\n 32", "output": "13\n \n\n* * *"}, {"input": "3 3 4\n 5\n 6\n 7", "output": "0"}] |
Print the number of the different divisions under the conditions, modulo 10^9
+ 7.
* * * | s190074546 | Wrong Answer | p03823 | The input is given from Standard Input in the following format:
N A B
S_1
:
S_N | def examA():
N = I()
A = [0] * N
B = [0] * N
for i in range(N):
A[i], B[i] = LI()
cum = 0
for i in range(N)[::-1]:
cum += (-(cum + A[i])) % B[i]
# print(cum)
ans = cum
print(ans)
return
def examB():
N = I()
V = [[] for _ in range(N)]
for i in range(1, N):
a = I() - 1
V[a].append(i)
# print(V)
dp = [0] * N
def dfs(n, s):
children = []
for i in V[s]:
child = dfs(n, i)
children.append(child)
rep = 0
children.sort()
for i, c in enumerate(children[::-1], start=1):
rep = max(rep, i + c)
dp[s] = rep
return rep
ans = dfs(N, 0)
print(ans)
return
def examC():
class segment_:
def __init__(self, A, n, segfunc, ide_ele=0):
#####単位元######要設定0or1orinf
self.ide_ele = ide_ele
####################
self.num = 1 << (n - 1).bit_length()
self.seg = [self.ide_ele] * 2 * self.num
self.segfunc = segfunc
# set_val
for i in range(n):
self.seg[i + self.num] = A[i]
# built
for i in range(self.num - 1, 0, -1):
self.seg[i] = self.segfunc(self.seg[2 * i], self.seg[2 * i + 1])
def update(self, k, r):
k += self.num
self.seg[k] = r
while k:
k >>= 1
self.seg[k] = self.segfunc(self.seg[k * 2], self.seg[k * 2 + 1])
# 値xに1加算
def update1(self, k):
k += self.num
self.seg[k] += 1
while k:
k >>= 1
self.seg[k] = self.segfunc(self.seg[k * 2], self.seg[k * 2 + 1])
def updateneg1(self, k):
k += self.num
self.seg[k] -= 1
while k:
k >>= 1
self.seg[k] = self.segfunc(self.seg[k * 2], self.seg[k * 2 + 1])
def query(self, p, q):
# qは含まない
if q < p:
return self.ide_ele
p += self.num
q += self.num
res = self.ide_ele
while p < q:
if p & 1 == 1:
res = self.segfunc(res, self.seg[p])
p += 1
if q & 1 == 1:
q -= 1
res = self.segfunc(res, self.seg[q])
p >>= 1
q >>= 1
return res
N, A, B = LI()
S = [I() for _ in range(N)]
S.insert(0, -inf)
# print(S)
if A > B:
A, B = B, A
for i in range(N - 1):
if S[i + 2] - S[i] < A:
print(0)
return
dp = [0] * (N + 1)
dp[0] = 1
dp[1] = 1
num = N + 1
L = [0] * num
Seg_sum = segment_(L, num, lambda a, b: a + b)
la = 0
lb = -1
Seg_sum.update(0, 1)
Seg_sum.update(1, 1)
for i in range(1, N):
while lb < i and S[i + 1] - S[lb + 1] >= B:
lb += 1
dp[i + 1] = Seg_sum.query(0, lb + 1)
Seg_sum.update(i + 1, dp[i + 1])
# dp[i+1] = sum(dp[:lb+1])
if S[i + 1] - S[i] < A:
for a in range(la, i):
Seg_sum.update(a, 0)
dp[a] = 0
la = i
# print(dp)
# print(dp)
ans = sum(dp)
print(ans)
return
def examD():
ans = 0
print(ans)
return
def examE():
ans = 0
print(ans)
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__":
examC()
"""
"""
| Statement
There is a set consisting of N distinct integers. The i-th smallest element in
this set is S_i. We want to divide this set into two sets, X and Y, such that:
* The absolute difference of any two distinct elements in X is A or greater.
* The absolute difference of any two distinct elements in Y is B or greater.
How many ways are there to perform such division, modulo 10^9 + 7? Note that
one of X and Y may be empty. | [{"input": "5 3 7\n 1\n 3\n 6\n 9\n 12", "output": "5\n \n\nThere are five ways to perform division:\n\n * X={1,6,9,12}, Y={3}\n * X={1,6,9}, Y={3,12}\n * X={3,6,9,12}, Y={1}\n * X={3,6,9}, Y={1,12}\n * X={3,6,12}, Y={1,9}\n\n* * *"}, {"input": "7 5 3\n 0\n 2\n 4\n 7\n 8\n 11\n 15", "output": "4\n \n\n* * *"}, {"input": "8 2 9\n 3\n 4\n 5\n 13\n 15\n 22\n 26\n 32", "output": "13\n \n\n* * *"}, {"input": "3 3 4\n 5\n 6\n 7", "output": "0"}] |
Print the number of the different divisions under the conditions, modulo 10^9
+ 7.
* * * | s375232622 | Wrong Answer | p03823 | The input is given from Standard Input in the following format:
N A B
S_1
:
S_N | # c
n, a, b = [int(i) for i in input().split()]
pos = [-10000000000000] # -inf
for _ in range(n):
pos.append(int(input()))
a_list = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
b_list = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
a_list[0][1] = 1 # numbers. BA...A
b_list[0][1] = 1 # numbers AB...B
for i in range(1, n):
for j in range(0, i):
if pos[i + 1] - pos[i] >= a:
a_list[j][i + 1] += a_list[j][i]
if pos[i + 1] - pos[i] >= b:
b_list[j][i + 1] += b_list[j][i]
if pos[i + 1] - pos[j] >= b:
b_list[i][i + 1] += a_list[j][i]
if pos[i + 1] - pos[j] >= a:
a_list[i][i + 1] += b_list[j][i]
cnt = 0
for j in range(n):
cnt += a_list[j][n]
cnt += b_list[j][n]
print(cnt)
| Statement
There is a set consisting of N distinct integers. The i-th smallest element in
this set is S_i. We want to divide this set into two sets, X and Y, such that:
* The absolute difference of any two distinct elements in X is A or greater.
* The absolute difference of any two distinct elements in Y is B or greater.
How many ways are there to perform such division, modulo 10^9 + 7? Note that
one of X and Y may be empty. | [{"input": "5 3 7\n 1\n 3\n 6\n 9\n 12", "output": "5\n \n\nThere are five ways to perform division:\n\n * X={1,6,9,12}, Y={3}\n * X={1,6,9}, Y={3,12}\n * X={3,6,9,12}, Y={1}\n * X={3,6,9}, Y={1,12}\n * X={3,6,12}, Y={1,9}\n\n* * *"}, {"input": "7 5 3\n 0\n 2\n 4\n 7\n 8\n 11\n 15", "output": "4\n \n\n* * *"}, {"input": "8 2 9\n 3\n 4\n 5\n 13\n 15\n 22\n 26\n 32", "output": "13\n \n\n* * *"}, {"input": "3 3 4\n 5\n 6\n 7", "output": "0"}] |
Print the answer modulo 924844033.
* * * | s390211473 | Wrong Answer | p03989 | The input is given from Standard Input in the following format:
N K | def sort_list(route): # 引数でリストを受け取る。
route_ = route[:]
row = []
box = route_
row.append(box) # リストの0番目(元の値)を格納
for node in range(len(route) - 1): # リストを一回転する。
row.append(box) # リストのnode+1番目の初期化
row[node + 1] = row[node][
:
] # 初期化したものを、前のリストのコピーに置き換える。
row[node + 1].append(row[node][0])
row[node + 1].pop(0)
return row
n, k = input().split()
o = []
lis = sort_list([_n + 1 for _n in range(int(n))])
for li in lis:
flag = False
for i in range(int(n)):
if li[i] - i == int(k):
flag = True
if flag is False:
o.append(li)
print(len(o) % 924844033)
| Statement
Snuke loves permutations. He is making a permutation of length N.
Since he hates the integer K, his permutation will satisfy the following:
* Let the permutation be a_1, a_2, ..., a_N. For each i = 1,2,...,N, |a_i - i| \neq K.
Among the N! permutations of length N, how many satisfies this condition?
Since the answer may be extremely large, find the answer modulo
924844033(prime). | [{"input": "3 1", "output": "2\n \n\n2 permutations (1, 2, 3), (3, 2, 1) satisfy the condition.\n\n* * *"}, {"input": "4 1", "output": "5\n \n\n5 permutations (1, 2, 3, 4), (1, 4, 3, 2), (3, 2, 1, 4), (3, 4, 1, 2), (4, 2,\n3, 1) satisfy the condition.\n\n* * *"}, {"input": "4 2", "output": "9\n \n\n* * *"}, {"input": "4 3", "output": "14\n \n\n* * *"}, {"input": "425 48", "output": "756765083"}] |
Print the costs of SSSP in the following format.
c0
c1
:
c|V|-1
The output consists of |V| lines. Print the cost of the shortest path from the
source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the
source to a vertex, print INF. | s627121099 | Accepted | p02361 | An edge-weighted graph G (V, E) and the source r.
|V| |E| r
s0 t0 d0
s1 t1 d1
:
s|E|-1 t|E|-1 d|E|-1
|V| is the number of vertices and |E| is the number of edges in G. The graph
vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the
source of the graph.
si and ti represent source and target vertices of i-th edge (directed) and di
represents the cost of the i-th edge. | # -*- coding: utf-8 -*-
"""
Created on Sat May 18 23:11:54 2019
@author: maezawa
"""
import collections
import heapq
class Dijkstra:
def __init__(self):
self.e = collections.defaultdict(list)
def add(self, u, v, d, directed=False):
"""
0-indexedでなくてもよいことに注意
u = from, v = to, d = cost
directed = Trueなら、有向グラフである
"""
if directed is False:
self.e[u].append([v, d])
self.e[v].append([u, d])
else:
self.e[u].append([v, d])
def delete(self, u, v):
self.e[u] = [_ for _ in self.e[u] if _[0] != v]
self.e[v] = [_ for _ in self.e[v] if _[0] != u]
def Dijkstra_search(self, s):
"""
0-indexedでなくてもよいことに注意
s = 始点
return: 始点から各点までの最短経路
"""
d = collections.defaultdict(lambda: float("inf"))
d[s] = 0
q = []
heapq.heappush(q, (0, s))
v = collections.defaultdict(bool)
while len(q):
k, u = heapq.heappop(q)
if v[u]:
continue
v[u] = True
for uv, ud in self.e[u]:
if v[uv]:
continue
vd = k + ud
if d[uv] > vd:
d[uv] = vd
heapq.heappush(q, (vd, uv))
return d
v, e, r = list(map(int, input().split()))
graph1 = Dijkstra()
for _ in range(e):
si, ti, di = list(map(int, input().split()))
graph1.add(si, ti, di, directed=True)
res = graph1.Dijkstra_search(r)
for i in range(v):
ans = res[i]
if ans == float("inf"):
print("INF")
else:
print(ans)
| Single Source Shortest Path
For a given weighted graph G(V, E) and a source r, find the source shortest
path to each vertex from the source (SSSP: Single Source Shortest Path). | [{"input": "4 5 0\n 0 1 1\n 0 2 4\n 1 2 2\n 2 3 1\n 1 3 5", "output": "0\n 1\n 3\n 4"}, {"input": "4 6 1\n 0 1 1\n 0 2 4\n 2 0 1\n 1 2 2\n 3 1 1\n 3 2 5", "output": "3\n 0\n 2\n INF"}] |
Print the costs of SSSP in the following format.
c0
c1
:
c|V|-1
The output consists of |V| lines. Print the cost of the shortest path from the
source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the
source to a vertex, print INF. | s692007225 | Accepted | p02361 | An edge-weighted graph G (V, E) and the source r.
|V| |E| r
s0 t0 d0
s1 t1 d1
:
s|E|-1 t|E|-1 d|E|-1
|V| is the number of vertices and |E| is the number of edges in G. The graph
vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the
source of the graph.
si and ti represent source and target vertices of i-th edge (directed) and di
represents the cost of the i-th edge. | inf = 1001001001
nv, ne, r = map(int, input().split())
d = [inf] * nv
d[r] = 0
e = []
for i in range(ne):
e.append(list(map(int, input().split())))
for i in range(nv - 1):
flg = False
for j in e:
if d[j[1]] > d[j[0]] + j[2]:
flg = True
d[j[1]] = min(d[j[1]], d[j[0]] + j[2])
if not (flg):
break
for i in range(nv):
print("INF" if d[i] == inf else d[i])
| Single Source Shortest Path
For a given weighted graph G(V, E) and a source r, find the source shortest
path to each vertex from the source (SSSP: Single Source Shortest Path). | [{"input": "4 5 0\n 0 1 1\n 0 2 4\n 1 2 2\n 2 3 1\n 1 3 5", "output": "0\n 1\n 3\n 4"}, {"input": "4 6 1\n 0 1 1\n 0 2 4\n 2 0 1\n 1 2 2\n 3 1 1\n 3 2 5", "output": "3\n 0\n 2\n INF"}] |
Print the costs of SSSP in the following format.
c0
c1
:
c|V|-1
The output consists of |V| lines. Print the cost of the shortest path from the
source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the
source to a vertex, print INF. | s370875550 | Wrong Answer | p02361 | An edge-weighted graph G (V, E) and the source r.
|V| |E| r
s0 t0 d0
s1 t1 d1
:
s|E|-1 t|E|-1 d|E|-1
|V| is the number of vertices and |E| is the number of edges in G. The graph
vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the
source of the graph.
si and ti represent source and target vertices of i-th edge (directed) and di
represents the cost of the i-th edge. | # Single Source Shortest Path
infty = 99999
[vertex, edge, r] = list(map(int, input("").split()))
D = [[infty for j in range(vertex)] for i in range(vertex)]
for i in range(edge):
data = list(map(int, input("").split()))
D[data[0]][data[1]] = data[2]
"""
def Dijkstra(root, n):
visited_order = 0
label = [0 for i in range(n)]
global D
global infty
d = D[root]
visited_order += 1
label[root] = visited_order
while visited_order < n:
min_cost = infty
for i in range(n):
if label[i] != 0:
continue
if min_cost > d[i]:
min_cost = d[i]
min_node = i
if min_cost == infty:
break
visited_order += 1
label[min_node] = visited_order
for i in range(n):
if label[i] != 0:
continue
if d[i] > d[min_node] + D[min_node][i]:
d[i] = d[min_node] + D[min_node][i]
return d
result = Dijkstra(r, vertex)
for i in range(vertex):
if i == r:
result[i] = 0
if result[i] == infty:
result[i] = "INF"
print(result[i])
"""
| Single Source Shortest Path
For a given weighted graph G(V, E) and a source r, find the source shortest
path to each vertex from the source (SSSP: Single Source Shortest Path). | [{"input": "4 5 0\n 0 1 1\n 0 2 4\n 1 2 2\n 2 3 1\n 1 3 5", "output": "0\n 1\n 3\n 4"}, {"input": "4 6 1\n 0 1 1\n 0 2 4\n 2 0 1\n 1 2 2\n 3 1 1\n 3 2 5", "output": "3\n 0\n 2\n INF"}] |
Print the costs of SSSP in the following format.
c0
c1
:
c|V|-1
The output consists of |V| lines. Print the cost of the shortest path from the
source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the
source to a vertex, print INF. | s755261679 | Runtime Error | p02361 | An edge-weighted graph G (V, E) and the source r.
|V| |E| r
s0 t0 d0
s1 t1 d1
:
s|E|-1 t|E|-1 d|E|-1
|V| is the number of vertices and |E| is the number of edges in G. The graph
vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the
source of the graph.
si and ti represent source and target vertices of i-th edge (directed) and di
represents the cost of the i-th edge. | from collections import defaultdict
import heapq
with open("input.txt", "r") as f:
vertice, edge, source = map(int, input().split(" "))
link = [[] for n in range(vertice)]
weight = defaultdict(dict)
for e in range(edge):
i, j, w = map(int, input().split(" "))
link[i].append(j)
weight[i].update({j: w})
# print(weight,link)
for v in range(vertice):
goal = v
queue = []
heapq.heappush(queue, [0, source])
went = set()
while queue != []:
# print(queue)
now_cost, here = heapq.heappop(queue)
# print(now_cost,here,queue)
if here == goal:
print(now_cost)
break
can_go = link[here]
not_went = set(can_go) - went
# print(v,here,now_cost,not_went,queue)
for nw in not_went:
next_cost = now_cost + weight[here][nw]
heapq.heappush(queue, (next_cost, nw))
went = went | {here}
queue.sort(key=lambda x: x[1], reverse=True)
else:
print("INF")
| Single Source Shortest Path
For a given weighted graph G(V, E) and a source r, find the source shortest
path to each vertex from the source (SSSP: Single Source Shortest Path). | [{"input": "4 5 0\n 0 1 1\n 0 2 4\n 1 2 2\n 2 3 1\n 1 3 5", "output": "0\n 1\n 3\n 4"}, {"input": "4 6 1\n 0 1 1\n 0 2 4\n 2 0 1\n 1 2 2\n 3 1 1\n 3 2 5", "output": "3\n 0\n 2\n INF"}] |
Print the costs of SSSP in the following format.
c0
c1
:
c|V|-1
The output consists of |V| lines. Print the cost of the shortest path from the
source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the
source to a vertex, print INF. | s975753701 | Accepted | p02361 | An edge-weighted graph G (V, E) and the source r.
|V| |E| r
s0 t0 d0
s1 t1 d1
:
s|E|-1 t|E|-1 d|E|-1
|V| is the number of vertices and |E| is the number of edges in G. The graph
vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the
source of the graph.
si and ti represent source and target vertices of i-th edge (directed) and di
represents the cost of the i-th edge. | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
4 6 1
0 1 1
0 2 4
2 0 1
1 2 2
3 1 1
3 2 5
output:
3
0
2
INF
"""
import sys
import heapq as hp
from math import isinf
WHITE, GRAY, BLACK = 0, 1, 2
def generate_adj_table(v_table):
for each in v_table:
source, target, cost = map(int, each)
init_adj_table[source][target] = cost
return init_adj_table
def dijkstra_path_heap():
# path search init
distance[root] = 0
path_heap = []
# heapq: rank by tuple[0], at here it's d[u]
hp.heappush(path_heap, (0, root))
while path_heap:
current = hp.heappop(path_heap)[1]
color[current] = BLACK
for adj, cost in adj_table[current].items():
if color[adj] is not BLACK:
# alt: d[u] + w[u,v]
alt_path = distance[current] + cost
if alt_path < distance[adj]:
# update path_list
distance[adj] = alt_path
# update heap
hp.heappush(path_heap, (alt_path, adj))
color[adj] = GRAY
parents[adj] = current
return distance
if __name__ == "__main__":
_input = sys.stdin.readlines()
vertices, edges, root = map(int, _input[0].split())
v_info = map(lambda x: x.split(), _input[1:])
# assert len(init_vertices_table) == vertices_num
distance = [float("inf")] * vertices
parents = [-1] * vertices
color = [WHITE] * vertices
init_adj_table = tuple(dict() for _ in range(vertices))
adj_table = generate_adj_table(v_info)
ans = dijkstra_path_heap()
# print('\n'.join(('INF' if isinf(ele) else str(ele) for ele in ans)))
for ele in ans:
if isinf(ele):
print("INF")
else:
print(ele)
| Single Source Shortest Path
For a given weighted graph G(V, E) and a source r, find the source shortest
path to each vertex from the source (SSSP: Single Source Shortest Path). | [{"input": "4 5 0\n 0 1 1\n 0 2 4\n 1 2 2\n 2 3 1\n 1 3 5", "output": "0\n 1\n 3\n 4"}, {"input": "4 6 1\n 0 1 1\n 0 2 4\n 2 0 1\n 1 2 2\n 3 1 1\n 3 2 5", "output": "3\n 0\n 2\n INF"}] |
Print the costs of SSSP in the following format.
c0
c1
:
c|V|-1
The output consists of |V| lines. Print the cost of the shortest path from the
source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the
source to a vertex, print INF. | s140920189 | Accepted | p02361 | An edge-weighted graph G (V, E) and the source r.
|V| |E| r
s0 t0 d0
s1 t1 d1
:
s|E|-1 t|E|-1 d|E|-1
|V| is the number of vertices and |E| is the number of edges in G. The graph
vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the
source of the graph.
si and ti represent source and target vertices of i-th edge (directed) and di
represents the cost of the i-th edge. | import sys
from heapq import heappush, heappop
inf = 1 << 30
def solve():
N, M, s = map(int, sys.stdin.readline().split())
Adj = [[] for i in range(N)]
for i in range(M):
ui, vi, ci = map(int, sys.stdin.readline().split())
Adj[ui].append((vi, ci))
d = dijkstra(N, Adj, s)
for di in d:
print(di if di < inf else "INF")
def dijkstra(N, Adj, s):
d = [inf] * N
p = [-1] * N
fixed = [False] * N
d[s] = 0
p[s] = s
pq = [(0, s)]
for i in range(N - 1):
while pq:
di, v = heappop(pq)
if not fixed[v] and di == d[v]:
break
fixed[v] = True
for u, c in Adj[v]:
if d[v] + c < d[u]:
d[u] = d[v] + c
p[u] = v
heappush(pq, (d[u], u))
return d
if __name__ == "__main__":
solve()
| Single Source Shortest Path
For a given weighted graph G(V, E) and a source r, find the source shortest
path to each vertex from the source (SSSP: Single Source Shortest Path). | [{"input": "4 5 0\n 0 1 1\n 0 2 4\n 1 2 2\n 2 3 1\n 1 3 5", "output": "0\n 1\n 3\n 4"}, {"input": "4 6 1\n 0 1 1\n 0 2 4\n 2 0 1\n 1 2 2\n 3 1 1\n 3 2 5", "output": "3\n 0\n 2\n INF"}] |
Print the costs of SSSP in the following format.
c0
c1
:
c|V|-1
The output consists of |V| lines. Print the cost of the shortest path from the
source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the
source to a vertex, print INF. | s490148262 | Accepted | p02361 | An edge-weighted graph G (V, E) and the source r.
|V| |E| r
s0 t0 d0
s1 t1 d1
:
s|E|-1 t|E|-1 d|E|-1
|V| is the number of vertices and |E| is the number of edges in G. The graph
vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the
source of the graph.
si and ti represent source and target vertices of i-th edge (directed) and di
represents the cost of the i-th edge. | import sys
readline = sys.stdin.buffer.readline
def even(n):
return 1 if n % 2 == 0 else 0
n, m, r = map(int, readline().split())
g = [[] for i in range(n)]
for i in range(m):
x, y, w = map(int, readline().split())
g[x].append((w, y))
# g[y].append((w,x))
# 新ダイクストラ
INF = 10**18
import heapq
push = heapq.heappush
pop = heapq.heappop
def dijkstra(s, g): # g:(weight,go)の順の隣接リスト※タプルで有ることに注意
n = len(g)
dist = [INF] * n
dist[s] = 0
used = [0] * n
used[s] = 1
hp = []
for go in g[s]:
push(hp, go)
while hp:
w, fr = pop(hp)
if not used[fr]:
dist[fr] = w
used[fr] = 1
for w, go in g[fr]:
if not used[go]:
push(hp, (w + dist[fr], go))
return dist
for i in dijkstra(r, g):
print(i if i < INF else "INF")
| Single Source Shortest Path
For a given weighted graph G(V, E) and a source r, find the source shortest
path to each vertex from the source (SSSP: Single Source Shortest Path). | [{"input": "4 5 0\n 0 1 1\n 0 2 4\n 1 2 2\n 2 3 1\n 1 3 5", "output": "0\n 1\n 3\n 4"}, {"input": "4 6 1\n 0 1 1\n 0 2 4\n 2 0 1\n 1 2 2\n 3 1 1\n 3 2 5", "output": "3\n 0\n 2\n INF"}] |
Print the costs of SSSP in the following format.
c0
c1
:
c|V|-1
The output consists of |V| lines. Print the cost of the shortest path from the
source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the
source to a vertex, print INF. | s032621206 | Accepted | p02361 | An edge-weighted graph G (V, E) and the source r.
|V| |E| r
s0 t0 d0
s1 t1 d1
:
s|E|-1 t|E|-1 d|E|-1
|V| is the number of vertices and |E| is the number of edges in G. The graph
vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the
source of the graph.
si and ti represent source and target vertices of i-th edge (directed) and di
represents the cost of the i-th edge. | class RadixHeap:
__slots__ = ["data", "last", "siz", "used"]
# (max_key - min_key) <= C
def __init__(self, N, C):
self.data = [[] for i in range(C.bit_length() + 1)]
self.last = self.siz = 0
self.used = [0] * N
def push(self, x, key):
# assert self.last <= x
self.siz += 1
self.data[(x ^ self.last).bit_length()].append((x, key))
def pop(self):
data = self.data
used = self.used
# assert self.siz > 0
if not data[0]:
i = 1
while not data[i]:
i += 1
d = data[i]
new_last, new_key = min(d)
used[new_key] = 1
for val in d:
x, key = val
if used[key]:
self.siz -= 1
continue
data[(x ^ new_last).bit_length()].append(val)
self.last = new_last
data[i] = []
else:
new_last, new_key = data[0].pop()
used[new_key] = 1
self.siz -= 1
return new_last, new_key
def __len__(self):
return self.siz
import sys
readline = sys.stdin.readline
write = sys.stdout.write
N, M, s = map(int, readline().split())
G = [[] for i in range(N)]
for i in range(M):
a, b, c = map(int, readline().split())
G[a].append((b, c))
INF = 10**18
def dijkstra(N, G, s):
que = RadixHeap(N, 10**9 + 1)
dist = [INF] * N
dist[s] = 0
que.push(0, s)
while que:
cost, v = que.pop()
if dist[v] < cost:
continue
for w, c in G[v]:
if cost + c < dist[w]:
dist[w] = r = cost + c
que.push(r, w)
return dist
dist = dijkstra(N, G, s)
for c in dist:
write("INF\n" if c == INF else "%d\n" % c)
| Single Source Shortest Path
For a given weighted graph G(V, E) and a source r, find the source shortest
path to each vertex from the source (SSSP: Single Source Shortest Path). | [{"input": "4 5 0\n 0 1 1\n 0 2 4\n 1 2 2\n 2 3 1\n 1 3 5", "output": "0\n 1\n 3\n 4"}, {"input": "4 6 1\n 0 1 1\n 0 2 4\n 2 0 1\n 1 2 2\n 3 1 1\n 3 2 5", "output": "3\n 0\n 2\n INF"}] |
If ans is the number of configurations with the properties described in the
statement, you should print on Standard Output
ans
If there are more than 1000 such configurations, print -1.
* * * | s482242811 | Wrong Answer | p02674 | The input is given from Standard Input in the format
N | n = int(input())
print(n**2)
| Statement
There are N people (with different names) and K clubs. For each club you know
the list of members (so you have K unordered lists). Each person can be a
member of many clubs (and also 0 clubs) and two different clubs might have
exactly the same members. The value of the number K is the minimum possible
such that the following property can be true for at least one configuration of
clubs. If every person changes her name (maintaining the property that all
names are different) and you know the new K lists of members of the clubs (but
you don't know which list corresponds to which club), you are sure that you
would be able to match the old names with the new ones.
Count the number of such configurations of clubs (or say that there are more
than 1000). Two configurations of clubs that can be obtained one from the
other if the N people change their names are considered equal.
**Formal statement** : A club is a (possibly empty) subset of \\{1,\dots, N\\}
(the subset identifies the members, assuming that the people are indexed by
the numbers 1, 2,\dots, N). A configuration of clubs is an unordered
collection of K clubs (not necessarily distinct). Given a permutation
\sigma(1), \dots, \sigma(N) of \\{1,\dots, N\\} and a configuration of clubs
L=\\{C_1, C_2, \dots, C_K\\}, we denote with \sigma(L) the configuration of
clubs \\{\sigma(C_1), \sigma(C_2), \dots, \sigma(C_K)\\} (if C is a club,
\sigma(C)=\\{\sigma(x):\, x\in C\\}). A configuration of clubs L is name-
preserving if for any pair of distinct permutations \sigma\not=\tau, it holds
\sigma(L)\not=\tau(L).
You have to count the number of name-preserving configurations of clubs with
the minimum possible number of clubs (so K is minimum). Two configurations
L_1, L_2 such that L_2=\sigma(L_1) (for some permutation \sigma) are
considered equal. If there are more than 1000 such configurations, print -1. | [{"input": "2", "output": "1\n \n\nThe value of K is 1 and the unique name-preserving configuration of clubs is\n\\\\{\\\\{1\\\\}\\\\} (the configuration \\\\{\\\\{2\\\\}\\\\} is considered the same).\n\n* * *"}, {"input": "3", "output": "1\n \n\nThe value of K is 2 and the unique (up to permutation) name-preserving\nconfiguration of clubs is \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}\\\\}.\n\n* * *"}, {"input": "4", "output": "7\n \n\nThe value of K is 3 and the name-preserving configurations of clubs with 3\nclubs are:\n\n * \\\\{\\\\{1\\\\}, \\\\{2\\\\}, \\\\{1, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}, \\\\{2, 3\\\\}\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 2\\\\}, \\\\{1, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}, \\\\{1, 2, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{2, 3\\\\}, \\\\{1, 2, 4\\\\}\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 3\\\\}, \\\\{1, 2, 4\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 2, 3\\\\}, \\\\{2, 3, 4\\\\}\\\\}\n\n* * *"}, {"input": "13", "output": "6\n \n\n* * *"}, {"input": "26", "output": "-1\n \n\n* * *"}, {"input": "123456789123456789", "output": "-1"}] |
If ans is the number of configurations with the properties described in the
statement, you should print on Standard Output
ans
If there are more than 1000 such configurations, print -1.
* * * | s117947828 | Wrong Answer | p02674 | The input is given from Standard Input in the format
N | 0
| Statement
There are N people (with different names) and K clubs. For each club you know
the list of members (so you have K unordered lists). Each person can be a
member of many clubs (and also 0 clubs) and two different clubs might have
exactly the same members. The value of the number K is the minimum possible
such that the following property can be true for at least one configuration of
clubs. If every person changes her name (maintaining the property that all
names are different) and you know the new K lists of members of the clubs (but
you don't know which list corresponds to which club), you are sure that you
would be able to match the old names with the new ones.
Count the number of such configurations of clubs (or say that there are more
than 1000). Two configurations of clubs that can be obtained one from the
other if the N people change their names are considered equal.
**Formal statement** : A club is a (possibly empty) subset of \\{1,\dots, N\\}
(the subset identifies the members, assuming that the people are indexed by
the numbers 1, 2,\dots, N). A configuration of clubs is an unordered
collection of K clubs (not necessarily distinct). Given a permutation
\sigma(1), \dots, \sigma(N) of \\{1,\dots, N\\} and a configuration of clubs
L=\\{C_1, C_2, \dots, C_K\\}, we denote with \sigma(L) the configuration of
clubs \\{\sigma(C_1), \sigma(C_2), \dots, \sigma(C_K)\\} (if C is a club,
\sigma(C)=\\{\sigma(x):\, x\in C\\}). A configuration of clubs L is name-
preserving if for any pair of distinct permutations \sigma\not=\tau, it holds
\sigma(L)\not=\tau(L).
You have to count the number of name-preserving configurations of clubs with
the minimum possible number of clubs (so K is minimum). Two configurations
L_1, L_2 such that L_2=\sigma(L_1) (for some permutation \sigma) are
considered equal. If there are more than 1000 such configurations, print -1. | [{"input": "2", "output": "1\n \n\nThe value of K is 1 and the unique name-preserving configuration of clubs is\n\\\\{\\\\{1\\\\}\\\\} (the configuration \\\\{\\\\{2\\\\}\\\\} is considered the same).\n\n* * *"}, {"input": "3", "output": "1\n \n\nThe value of K is 2 and the unique (up to permutation) name-preserving\nconfiguration of clubs is \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}\\\\}.\n\n* * *"}, {"input": "4", "output": "7\n \n\nThe value of K is 3 and the name-preserving configurations of clubs with 3\nclubs are:\n\n * \\\\{\\\\{1\\\\}, \\\\{2\\\\}, \\\\{1, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}, \\\\{2, 3\\\\}\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 2\\\\}, \\\\{1, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}, \\\\{1, 2, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{2, 3\\\\}, \\\\{1, 2, 4\\\\}\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 3\\\\}, \\\\{1, 2, 4\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 2, 3\\\\}, \\\\{2, 3, 4\\\\}\\\\}\n\n* * *"}, {"input": "13", "output": "6\n \n\n* * *"}, {"input": "26", "output": "-1\n \n\n* * *"}, {"input": "123456789123456789", "output": "-1"}] |
If ans is the number of configurations with the properties described in the
statement, you should print on Standard Output
ans
If there are more than 1000 such configurations, print -1.
* * * | s165737117 | Wrong Answer | p02674 | The input is given from Standard Input in the format
N | print(2)
| Statement
There are N people (with different names) and K clubs. For each club you know
the list of members (so you have K unordered lists). Each person can be a
member of many clubs (and also 0 clubs) and two different clubs might have
exactly the same members. The value of the number K is the minimum possible
such that the following property can be true for at least one configuration of
clubs. If every person changes her name (maintaining the property that all
names are different) and you know the new K lists of members of the clubs (but
you don't know which list corresponds to which club), you are sure that you
would be able to match the old names with the new ones.
Count the number of such configurations of clubs (or say that there are more
than 1000). Two configurations of clubs that can be obtained one from the
other if the N people change their names are considered equal.
**Formal statement** : A club is a (possibly empty) subset of \\{1,\dots, N\\}
(the subset identifies the members, assuming that the people are indexed by
the numbers 1, 2,\dots, N). A configuration of clubs is an unordered
collection of K clubs (not necessarily distinct). Given a permutation
\sigma(1), \dots, \sigma(N) of \\{1,\dots, N\\} and a configuration of clubs
L=\\{C_1, C_2, \dots, C_K\\}, we denote with \sigma(L) the configuration of
clubs \\{\sigma(C_1), \sigma(C_2), \dots, \sigma(C_K)\\} (if C is a club,
\sigma(C)=\\{\sigma(x):\, x\in C\\}). A configuration of clubs L is name-
preserving if for any pair of distinct permutations \sigma\not=\tau, it holds
\sigma(L)\not=\tau(L).
You have to count the number of name-preserving configurations of clubs with
the minimum possible number of clubs (so K is minimum). Two configurations
L_1, L_2 such that L_2=\sigma(L_1) (for some permutation \sigma) are
considered equal. If there are more than 1000 such configurations, print -1. | [{"input": "2", "output": "1\n \n\nThe value of K is 1 and the unique name-preserving configuration of clubs is\n\\\\{\\\\{1\\\\}\\\\} (the configuration \\\\{\\\\{2\\\\}\\\\} is considered the same).\n\n* * *"}, {"input": "3", "output": "1\n \n\nThe value of K is 2 and the unique (up to permutation) name-preserving\nconfiguration of clubs is \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}\\\\}.\n\n* * *"}, {"input": "4", "output": "7\n \n\nThe value of K is 3 and the name-preserving configurations of clubs with 3\nclubs are:\n\n * \\\\{\\\\{1\\\\}, \\\\{2\\\\}, \\\\{1, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}, \\\\{2, 3\\\\}\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 2\\\\}, \\\\{1, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}, \\\\{1, 2, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{2, 3\\\\}, \\\\{1, 2, 4\\\\}\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 3\\\\}, \\\\{1, 2, 4\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 2, 3\\\\}, \\\\{2, 3, 4\\\\}\\\\}\n\n* * *"}, {"input": "13", "output": "6\n \n\n* * *"}, {"input": "26", "output": "-1\n \n\n* * *"}, {"input": "123456789123456789", "output": "-1"}] |
If ans is the number of configurations with the properties described in the
statement, you should print on Standard Output
ans
If there are more than 1000 such configurations, print -1.
* * * | s130261155 | Wrong Answer | p02674 | The input is given from Standard Input in the format
N | print(1)
| Statement
There are N people (with different names) and K clubs. For each club you know
the list of members (so you have K unordered lists). Each person can be a
member of many clubs (and also 0 clubs) and two different clubs might have
exactly the same members. The value of the number K is the minimum possible
such that the following property can be true for at least one configuration of
clubs. If every person changes her name (maintaining the property that all
names are different) and you know the new K lists of members of the clubs (but
you don't know which list corresponds to which club), you are sure that you
would be able to match the old names with the new ones.
Count the number of such configurations of clubs (or say that there are more
than 1000). Two configurations of clubs that can be obtained one from the
other if the N people change their names are considered equal.
**Formal statement** : A club is a (possibly empty) subset of \\{1,\dots, N\\}
(the subset identifies the members, assuming that the people are indexed by
the numbers 1, 2,\dots, N). A configuration of clubs is an unordered
collection of K clubs (not necessarily distinct). Given a permutation
\sigma(1), \dots, \sigma(N) of \\{1,\dots, N\\} and a configuration of clubs
L=\\{C_1, C_2, \dots, C_K\\}, we denote with \sigma(L) the configuration of
clubs \\{\sigma(C_1), \sigma(C_2), \dots, \sigma(C_K)\\} (if C is a club,
\sigma(C)=\\{\sigma(x):\, x\in C\\}). A configuration of clubs L is name-
preserving if for any pair of distinct permutations \sigma\not=\tau, it holds
\sigma(L)\not=\tau(L).
You have to count the number of name-preserving configurations of clubs with
the minimum possible number of clubs (so K is minimum). Two configurations
L_1, L_2 such that L_2=\sigma(L_1) (for some permutation \sigma) are
considered equal. If there are more than 1000 such configurations, print -1. | [{"input": "2", "output": "1\n \n\nThe value of K is 1 and the unique name-preserving configuration of clubs is\n\\\\{\\\\{1\\\\}\\\\} (the configuration \\\\{\\\\{2\\\\}\\\\} is considered the same).\n\n* * *"}, {"input": "3", "output": "1\n \n\nThe value of K is 2 and the unique (up to permutation) name-preserving\nconfiguration of clubs is \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}\\\\}.\n\n* * *"}, {"input": "4", "output": "7\n \n\nThe value of K is 3 and the name-preserving configurations of clubs with 3\nclubs are:\n\n * \\\\{\\\\{1\\\\}, \\\\{2\\\\}, \\\\{1, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}, \\\\{2, 3\\\\}\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 2\\\\}, \\\\{1, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}, \\\\{1, 2, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{2, 3\\\\}, \\\\{1, 2, 4\\\\}\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 3\\\\}, \\\\{1, 2, 4\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 2, 3\\\\}, \\\\{2, 3, 4\\\\}\\\\}\n\n* * *"}, {"input": "13", "output": "6\n \n\n* * *"}, {"input": "26", "output": "-1\n \n\n* * *"}, {"input": "123456789123456789", "output": "-1"}] |
If ans is the number of configurations with the properties described in the
statement, you should print on Standard Output
ans
If there are more than 1000 such configurations, print -1.
* * * | s580418559 | Wrong Answer | p02674 | The input is given from Standard Input in the format
N | n = int(input())
if n == 2 or n == 3:
print(1)
else:
print(n**2)
| Statement
There are N people (with different names) and K clubs. For each club you know
the list of members (so you have K unordered lists). Each person can be a
member of many clubs (and also 0 clubs) and two different clubs might have
exactly the same members. The value of the number K is the minimum possible
such that the following property can be true for at least one configuration of
clubs. If every person changes her name (maintaining the property that all
names are different) and you know the new K lists of members of the clubs (but
you don't know which list corresponds to which club), you are sure that you
would be able to match the old names with the new ones.
Count the number of such configurations of clubs (or say that there are more
than 1000). Two configurations of clubs that can be obtained one from the
other if the N people change their names are considered equal.
**Formal statement** : A club is a (possibly empty) subset of \\{1,\dots, N\\}
(the subset identifies the members, assuming that the people are indexed by
the numbers 1, 2,\dots, N). A configuration of clubs is an unordered
collection of K clubs (not necessarily distinct). Given a permutation
\sigma(1), \dots, \sigma(N) of \\{1,\dots, N\\} and a configuration of clubs
L=\\{C_1, C_2, \dots, C_K\\}, we denote with \sigma(L) the configuration of
clubs \\{\sigma(C_1), \sigma(C_2), \dots, \sigma(C_K)\\} (if C is a club,
\sigma(C)=\\{\sigma(x):\, x\in C\\}). A configuration of clubs L is name-
preserving if for any pair of distinct permutations \sigma\not=\tau, it holds
\sigma(L)\not=\tau(L).
You have to count the number of name-preserving configurations of clubs with
the minimum possible number of clubs (so K is minimum). Two configurations
L_1, L_2 such that L_2=\sigma(L_1) (for some permutation \sigma) are
considered equal. If there are more than 1000 such configurations, print -1. | [{"input": "2", "output": "1\n \n\nThe value of K is 1 and the unique name-preserving configuration of clubs is\n\\\\{\\\\{1\\\\}\\\\} (the configuration \\\\{\\\\{2\\\\}\\\\} is considered the same).\n\n* * *"}, {"input": "3", "output": "1\n \n\nThe value of K is 2 and the unique (up to permutation) name-preserving\nconfiguration of clubs is \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}\\\\}.\n\n* * *"}, {"input": "4", "output": "7\n \n\nThe value of K is 3 and the name-preserving configurations of clubs with 3\nclubs are:\n\n * \\\\{\\\\{1\\\\}, \\\\{2\\\\}, \\\\{1, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}, \\\\{2, 3\\\\}\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 2\\\\}, \\\\{1, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}, \\\\{1, 2, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{2, 3\\\\}, \\\\{1, 2, 4\\\\}\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 3\\\\}, \\\\{1, 2, 4\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 2, 3\\\\}, \\\\{2, 3, 4\\\\}\\\\}\n\n* * *"}, {"input": "13", "output": "6\n \n\n* * *"}, {"input": "26", "output": "-1\n \n\n* * *"}, {"input": "123456789123456789", "output": "-1"}] |
If ans is the number of configurations with the properties described in the
statement, you should print on Standard Output
ans
If there are more than 1000 such configurations, print -1.
* * * | s361025252 | Wrong Answer | p02674 | The input is given from Standard Input in the format
N | print("Amethyst")
| Statement
There are N people (with different names) and K clubs. For each club you know
the list of members (so you have K unordered lists). Each person can be a
member of many clubs (and also 0 clubs) and two different clubs might have
exactly the same members. The value of the number K is the minimum possible
such that the following property can be true for at least one configuration of
clubs. If every person changes her name (maintaining the property that all
names are different) and you know the new K lists of members of the clubs (but
you don't know which list corresponds to which club), you are sure that you
would be able to match the old names with the new ones.
Count the number of such configurations of clubs (or say that there are more
than 1000). Two configurations of clubs that can be obtained one from the
other if the N people change their names are considered equal.
**Formal statement** : A club is a (possibly empty) subset of \\{1,\dots, N\\}
(the subset identifies the members, assuming that the people are indexed by
the numbers 1, 2,\dots, N). A configuration of clubs is an unordered
collection of K clubs (not necessarily distinct). Given a permutation
\sigma(1), \dots, \sigma(N) of \\{1,\dots, N\\} and a configuration of clubs
L=\\{C_1, C_2, \dots, C_K\\}, we denote with \sigma(L) the configuration of
clubs \\{\sigma(C_1), \sigma(C_2), \dots, \sigma(C_K)\\} (if C is a club,
\sigma(C)=\\{\sigma(x):\, x\in C\\}). A configuration of clubs L is name-
preserving if for any pair of distinct permutations \sigma\not=\tau, it holds
\sigma(L)\not=\tau(L).
You have to count the number of name-preserving configurations of clubs with
the minimum possible number of clubs (so K is minimum). Two configurations
L_1, L_2 such that L_2=\sigma(L_1) (for some permutation \sigma) are
considered equal. If there are more than 1000 such configurations, print -1. | [{"input": "2", "output": "1\n \n\nThe value of K is 1 and the unique name-preserving configuration of clubs is\n\\\\{\\\\{1\\\\}\\\\} (the configuration \\\\{\\\\{2\\\\}\\\\} is considered the same).\n\n* * *"}, {"input": "3", "output": "1\n \n\nThe value of K is 2 and the unique (up to permutation) name-preserving\nconfiguration of clubs is \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}\\\\}.\n\n* * *"}, {"input": "4", "output": "7\n \n\nThe value of K is 3 and the name-preserving configurations of clubs with 3\nclubs are:\n\n * \\\\{\\\\{1\\\\}, \\\\{2\\\\}, \\\\{1, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}, \\\\{2, 3\\\\}\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 2\\\\}, \\\\{1, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{1, 2\\\\}, \\\\{1, 2, 3\\\\}\\\\}\n * \\\\{\\\\{1\\\\}, \\\\{2, 3\\\\}, \\\\{1, 2, 4\\\\}\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 3\\\\}, \\\\{1, 2, 4\\\\}\n * \\\\{\\\\{1, 2\\\\}, \\\\{1, 2, 3\\\\}, \\\\{2, 3, 4\\\\}\\\\}\n\n* * *"}, {"input": "13", "output": "6\n \n\n* * *"}, {"input": "26", "output": "-1\n \n\n* * *"}, {"input": "123456789123456789", "output": "-1"}] |
Print the minimum possible total number of votes obtained by Takahashi and
Aoki when AtCoDeer checked the report for the N-th time.
* * * | s291282372 | Accepted | p03966 | The input is given from Standard Input in the following format:
N
T_1 A_1
T_2 A_2
:
T_N A_N | a = int(input())
b = [list(map(int, input().split())) for _ in range(a)]
c = []
for i in range(len(b)):
c.append(b[i].copy())
if len(c) != 1:
while True:
if c[i][0] < c[i - 1][0] or c[i][1] < c[i - 1][1]:
c[i][0] = b[i][0] * max(
(c[i - 1][0] + b[i][0] - 1) // b[i][0],
(c[i - 1][1] + b[i][1] - 1) // b[i][1],
)
c[i][1] = b[i][1] * max(
(c[i - 1][0] + b[i][0] - 1) // b[i][0],
(c[i - 1][1] + b[i][1] - 1) // b[i][1],
)
else:
break
print(c[len(c) - 1][0] + c[len(c) - 1][1])
| Statement
AtCoDeer the deer is seeing a quick report of election results on TV. Two
candidates are standing for the election: Takahashi and Aoki. The report shows
the ratio of the current numbers of votes the two candidates have obtained,
but not the actual numbers of votes. AtCoDeer has checked the report N times,
and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is
known that each candidate had at least one vote when he checked the report for
the first time.
Find the minimum possible total number of votes obtained by the two candidates
when he checked the report for the N-th time. It can be assumed that the
number of votes obtained by each candidate never decreases. | [{"input": "3\n 2 3\n 1 1\n 3 2", "output": "10\n \n\nWhen the numbers of votes obtained by the two candidates change as 2,3 \u2192 3,3 \u2192\n6,4, the total number of votes at the end is 10, which is the minimum possible\nnumber.\n\n* * *"}, {"input": "4\n 1 1\n 1 1\n 1 5\n 1 100", "output": "101\n \n\nIt is possible that neither candidate obtained a vote between the moment when\nhe checked the report, and the moment when he checked it for the next time.\n\n* * *"}, {"input": "5\n 3 10\n 48 17\n 31 199\n 231 23\n 3 2", "output": "6930"}] |
Print the minimum possible total number of votes obtained by Takahashi and
Aoki when AtCoDeer checked the report for the N-th time.
* * * | s632341020 | Wrong Answer | p03966 | The input is given from Standard Input in the following format:
N
T_1 A_1
T_2 A_2
:
T_N A_N | from math import *
def up(a, b):
ans = trunc(a / b)
if abs(a) % abs(b) > 0:
ans += 1
return ans
def down(a, b):
ans = trunc(a / b)
if abs(a) % abs(b) > 0:
ans -= 1
return ans
def egcd(a, b):
xx = y = 0
yy = x = 1
while b != 0:
q = trunc(a / b)
t = b
b = a % b
a = t
t = xx
xx = x - q * xx
x = t
t = yy
yy = y - q * yy
y = t
return [a, x, y]
n = int(input())
A = [0 for i in range(n)]
B = [0 for i in range(n)]
for i in range(n):
A[i], B[i] = map(int, input().split())
for i in range(0, n - 1):
a = A[i]
b = B[i]
c = A[i + 1]
d = B[i + 1]
o = egcd(d, c)
g = o[0]
x = o[1]
y = o[2]
v = (c * b - d * a) // g
x = x * v
y = -y * v
k_neg = max(up(x * g, c), up(y * g, d)) + 1
x = x - k_neg * c // g
y = y - k_neg * d // g
k = min(down(x * g, c), down(y * g, d))
x = x - k * c // g
y = y - k * d // g
A[i + 1] = a + x
B[i + 1] = b + y
print(A[n - 1] + B[n - 1])
| Statement
AtCoDeer the deer is seeing a quick report of election results on TV. Two
candidates are standing for the election: Takahashi and Aoki. The report shows
the ratio of the current numbers of votes the two candidates have obtained,
but not the actual numbers of votes. AtCoDeer has checked the report N times,
and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is
known that each candidate had at least one vote when he checked the report for
the first time.
Find the minimum possible total number of votes obtained by the two candidates
when he checked the report for the N-th time. It can be assumed that the
number of votes obtained by each candidate never decreases. | [{"input": "3\n 2 3\n 1 1\n 3 2", "output": "10\n \n\nWhen the numbers of votes obtained by the two candidates change as 2,3 \u2192 3,3 \u2192\n6,4, the total number of votes at the end is 10, which is the minimum possible\nnumber.\n\n* * *"}, {"input": "4\n 1 1\n 1 1\n 1 5\n 1 100", "output": "101\n \n\nIt is possible that neither candidate obtained a vote between the moment when\nhe checked the report, and the moment when he checked it for the next time.\n\n* * *"}, {"input": "5\n 3 10\n 48 17\n 31 199\n 231 23\n 3 2", "output": "6930"}] |
Print the minimum possible total number of votes obtained by Takahashi and
Aoki when AtCoDeer checked the report for the N-th time.
* * * | s443478142 | Wrong Answer | p03966 | The input is given from Standard Input in the following format:
N
T_1 A_1
T_2 A_2
:
T_N A_N | s = input()
l = len(s)
point = 0
for a, b in zip(s[0::2], s[1::2]):
if a == "p":
point -= 1
if b == "g":
point += 1
print(point)
| Statement
AtCoDeer the deer is seeing a quick report of election results on TV. Two
candidates are standing for the election: Takahashi and Aoki. The report shows
the ratio of the current numbers of votes the two candidates have obtained,
but not the actual numbers of votes. AtCoDeer has checked the report N times,
and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is
known that each candidate had at least one vote when he checked the report for
the first time.
Find the minimum possible total number of votes obtained by the two candidates
when he checked the report for the N-th time. It can be assumed that the
number of votes obtained by each candidate never decreases. | [{"input": "3\n 2 3\n 1 1\n 3 2", "output": "10\n \n\nWhen the numbers of votes obtained by the two candidates change as 2,3 \u2192 3,3 \u2192\n6,4, the total number of votes at the end is 10, which is the minimum possible\nnumber.\n\n* * *"}, {"input": "4\n 1 1\n 1 1\n 1 5\n 1 100", "output": "101\n \n\nIt is possible that neither candidate obtained a vote between the moment when\nhe checked the report, and the moment when he checked it for the next time.\n\n* * *"}, {"input": "5\n 3 10\n 48 17\n 31 199\n 231 23\n 3 2", "output": "6930"}] |
Print the minimum possible total number of votes obtained by Takahashi and
Aoki when AtCoDeer checked the report for the N-th time.
* * * | s330394251 | Runtime Error | p03966 | The input is given from Standard Input in the following format:
N
T_1 A_1
T_2 A_2
:
T_N A_N | # -*- coding: utf-8 -*-
import itertools
n = input()
input_lines = list(input())
pairs = [input_line.split(" ") for input_line in input_lines]
t_i = [pair[0] for pair in pairs]
a_i = [pair[1] for pair in pairs]
def satisfy_conditions(total_votes):
votes_t_i = total_votes * a_i[-i]
votes_a_i = total_votes * t_i[-i]
for i in range(1, n + 1):
constraint = (votes_t_i, votes_a_i)
possible_combination = is_possible(constraint, a_i[-i], t_i[-i])
if possible_combination is None:
return False
else:
votes_t_i = possible_combination[0]
votes_a_i = possible_combination[1]
return True
def is_possible(constraint, t_i, a_i):
votes_t_i_plus_1 = constraint[0]
votes_a_i_plus_1 = constraint[1]
combinations = list(
itertools.product(
list(range(1, votes_t_i_plus_1 + 1)), list(range(1, votes_a_i_plus_1 + 1))
)
)
combinations.reverse()
for combination in combinations:
if combination[0] / combination[1] == t_i / a_i:
return (combination[0], combination[1])
return None
max_iter = 1000000
answer = None
unit = t_i[-1] + a_i[-1]
for k in range(1, max_iter):
if satisfy_conditions(unit * k):
answer = unit * k
break
print(answer)
| Statement
AtCoDeer the deer is seeing a quick report of election results on TV. Two
candidates are standing for the election: Takahashi and Aoki. The report shows
the ratio of the current numbers of votes the two candidates have obtained,
but not the actual numbers of votes. AtCoDeer has checked the report N times,
and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is
known that each candidate had at least one vote when he checked the report for
the first time.
Find the minimum possible total number of votes obtained by the two candidates
when he checked the report for the N-th time. It can be assumed that the
number of votes obtained by each candidate never decreases. | [{"input": "3\n 2 3\n 1 1\n 3 2", "output": "10\n \n\nWhen the numbers of votes obtained by the two candidates change as 2,3 \u2192 3,3 \u2192\n6,4, the total number of votes at the end is 10, which is the minimum possible\nnumber.\n\n* * *"}, {"input": "4\n 1 1\n 1 1\n 1 5\n 1 100", "output": "101\n \n\nIt is possible that neither candidate obtained a vote between the moment when\nhe checked the report, and the moment when he checked it for the next time.\n\n* * *"}, {"input": "5\n 3 10\n 48 17\n 31 199\n 231 23\n 3 2", "output": "6930"}] |
Print the minimum possible total number of votes obtained by Takahashi and
Aoki when AtCoDeer checked the report for the N-th time.
* * * | s885441508 | Runtime Error | p03966 | The input is given from Standard Input in the following format:
N
T_1 A_1
T_2 A_2
:
T_N A_N | N=int(input())
X=[]
for i in range(N):
a=input().split()
X.append([int(a[0]),int(a[1])])
a=X[0][0]
b=X[0][1]
for i in range(1,N):
c=X[i][0]
d=X[i][1]
x= (a + (c - 1)) // c
y= (b + (d -1))) // d
a1=1000000000000000000
b1=1000000000000000000
a2=1000000000000000000
b2=1000000000000000000
if d*x-b>=0:
a1=c*x
b1=d*x
if c*y-a>=0:
a2=c*y
b2=d*y
if (a1+b1)<(a2+b2):
a=a1
b=b1
else:
a=a2
b=b2
#print("i = "+str(i)+" a = "+str(a)+" b = "+str(b)+" a1 = "+str(a1)+" b1 = "+str(b1)+" a2 = "+str(a2)+" b2 = "+str(b2)+" c = "+str(c)+" d = "+str(d))
print(a+b) | Statement
AtCoDeer the deer is seeing a quick report of election results on TV. Two
candidates are standing for the election: Takahashi and Aoki. The report shows
the ratio of the current numbers of votes the two candidates have obtained,
but not the actual numbers of votes. AtCoDeer has checked the report N times,
and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is
known that each candidate had at least one vote when he checked the report for
the first time.
Find the minimum possible total number of votes obtained by the two candidates
when he checked the report for the N-th time. It can be assumed that the
number of votes obtained by each candidate never decreases. | [{"input": "3\n 2 3\n 1 1\n 3 2", "output": "10\n \n\nWhen the numbers of votes obtained by the two candidates change as 2,3 \u2192 3,3 \u2192\n6,4, the total number of votes at the end is 10, which is the minimum possible\nnumber.\n\n* * *"}, {"input": "4\n 1 1\n 1 1\n 1 5\n 1 100", "output": "101\n \n\nIt is possible that neither candidate obtained a vote between the moment when\nhe checked the report, and the moment when he checked it for the next time.\n\n* * *"}, {"input": "5\n 3 10\n 48 17\n 31 199\n 231 23\n 3 2", "output": "6930"}] |
Print the minimum possible total number of votes obtained by Takahashi and
Aoki when AtCoDeer checked the report for the N-th time.
* * * | s584861703 | Wrong Answer | p03966 | The input is given from Standard Input in the following format:
N
T_1 A_1
T_2 A_2
:
T_N A_N | s = input()
hmp = 0
ans = 0
for i in s:
if i == "g" and hmp > 0:
hmp -= 1
ans += 1
elif i == "g":
hmp += 1
elif hmp > 0:
hmp -= 1
else:
hmp += 1
ans -= 1
print(ans)
| Statement
AtCoDeer the deer is seeing a quick report of election results on TV. Two
candidates are standing for the election: Takahashi and Aoki. The report shows
the ratio of the current numbers of votes the two candidates have obtained,
but not the actual numbers of votes. AtCoDeer has checked the report N times,
and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is
known that each candidate had at least one vote when he checked the report for
the first time.
Find the minimum possible total number of votes obtained by the two candidates
when he checked the report for the N-th time. It can be assumed that the
number of votes obtained by each candidate never decreases. | [{"input": "3\n 2 3\n 1 1\n 3 2", "output": "10\n \n\nWhen the numbers of votes obtained by the two candidates change as 2,3 \u2192 3,3 \u2192\n6,4, the total number of votes at the end is 10, which is the minimum possible\nnumber.\n\n* * *"}, {"input": "4\n 1 1\n 1 1\n 1 5\n 1 100", "output": "101\n \n\nIt is possible that neither candidate obtained a vote between the moment when\nhe checked the report, and the moment when he checked it for the next time.\n\n* * *"}, {"input": "5\n 3 10\n 48 17\n 31 199\n 231 23\n 3 2", "output": "6930"}] |
Print the minimum possible total number of votes obtained by Takahashi and
Aoki when AtCoDeer checked the report for the N-th time.
* * * | s621300780 | Runtime Error | p03966 | The input is given from Standard Input in the following format:
N
T_1 A_1
T_2 A_2
:
T_N A_N | n = int(input())
t, a = [], []
for i in range(n):
tmp = [int(i) for i in input().split()]
t.append(tmp[0])
a.append(tmp[1])
p, q = 0, 0
for zip(x, y) in t, a:
tmp = max(p // x, q // y)
p = x * tmp
q = y * tmp
print(p + q)
| Statement
AtCoDeer the deer is seeing a quick report of election results on TV. Two
candidates are standing for the election: Takahashi and Aoki. The report shows
the ratio of the current numbers of votes the two candidates have obtained,
but not the actual numbers of votes. AtCoDeer has checked the report N times,
and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is
known that each candidate had at least one vote when he checked the report for
the first time.
Find the minimum possible total number of votes obtained by the two candidates
when he checked the report for the N-th time. It can be assumed that the
number of votes obtained by each candidate never decreases. | [{"input": "3\n 2 3\n 1 1\n 3 2", "output": "10\n \n\nWhen the numbers of votes obtained by the two candidates change as 2,3 \u2192 3,3 \u2192\n6,4, the total number of votes at the end is 10, which is the minimum possible\nnumber.\n\n* * *"}, {"input": "4\n 1 1\n 1 1\n 1 5\n 1 100", "output": "101\n \n\nIt is possible that neither candidate obtained a vote between the moment when\nhe checked the report, and the moment when he checked it for the next time.\n\n* * *"}, {"input": "5\n 3 10\n 48 17\n 31 199\n 231 23\n 3 2", "output": "6930"}] |
Print the minimum possible total number of votes obtained by Takahashi and
Aoki when AtCoDeer checked the report for the N-th time.
* * * | s035893673 | Accepted | p03966 | The input is given from Standard Input in the following format:
N
T_1 A_1
T_2 A_2
:
T_N A_N | N = int(input())
a = list(int(i) for i in input().split())
x = a[0]
y = a[1]
for j in range(N - 1):
a = list(int(i) for i in input().split())
if a[0] > x:
if a[1] > y:
x = a[0]
y = a[1]
else:
q = (y - 1) // a[1] + 1
x = a[0] * q
y = a[1] * q
else:
if a[1] > y:
p = (x - 1) // a[0] + 1
x = a[0] * p
y = a[1] * p
else:
q = (y - 1) // a[1] + 1
p = (x - 1) // a[0] + 1
if p > q:
x = a[0] * p
y = a[1] * p
else:
x = a[0] * q
y = a[1] * q
print(x + y)
| Statement
AtCoDeer the deer is seeing a quick report of election results on TV. Two
candidates are standing for the election: Takahashi and Aoki. The report shows
the ratio of the current numbers of votes the two candidates have obtained,
but not the actual numbers of votes. AtCoDeer has checked the report N times,
and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is
known that each candidate had at least one vote when he checked the report for
the first time.
Find the minimum possible total number of votes obtained by the two candidates
when he checked the report for the N-th time. It can be assumed that the
number of votes obtained by each candidate never decreases. | [{"input": "3\n 2 3\n 1 1\n 3 2", "output": "10\n \n\nWhen the numbers of votes obtained by the two candidates change as 2,3 \u2192 3,3 \u2192\n6,4, the total number of votes at the end is 10, which is the minimum possible\nnumber.\n\n* * *"}, {"input": "4\n 1 1\n 1 1\n 1 5\n 1 100", "output": "101\n \n\nIt is possible that neither candidate obtained a vote between the moment when\nhe checked the report, and the moment when he checked it for the next time.\n\n* * *"}, {"input": "5\n 3 10\n 48 17\n 31 199\n 231 23\n 3 2", "output": "6930"}] |
Print all prime numbers p that divide f(x) for every integer x, in ascending
order.
* * * | s204557363 | Wrong Answer | p03065 | Input is given from Standard Input in the following format:
N
a_N
:
a_0 | def factorization(n):
a = n
p = 2
D = {}
while a != 1:
cnt = 0
while a % p == 0:
cnt += 1
a //= p
if cnt:
D[p] = cnt
p += 1
if a != 1 and p * p > n:
D[a] = 1
break
return D
N = int(input())
A = [0 for _ in range(N + 1)]
for i in range(N + 1):
A[-i - 1] = int(input())
non_zero = 0
while A[non_zero] == 0:
non_zero += 1
num = 0
if A[non_zero] < 0:
num = -A[non_zero]
else:
num = A[non_zero]
F = factorization(num)
PS = sum(A)
NS = 0
for i in range(N + 1):
NS += (i % 2 - (i + 1) % 2) * A[i]
X = []
for i in F:
if PS % i == 0 and NS % i == 0:
X.append(i)
X.sort()
NN = len(X)
for i in range(NN):
print(X[i])
| Statement
You are given a polynomial of degree N with integer coefficients:
f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x)
for every integer x. | [{"input": "2\n 7\n -7\n 14", "output": "2\n 7\n \n\n2 and 7 divide, for example, f(1)=14 and f(2)=28.\n\n* * *"}, {"input": "3\n 1\n 4\n 1\n 5", "output": "There may be no integers that satisfy the condition.\n\n* * *"}, {"input": "0\n 998244353", "output": "998244353"}] |
Print all prime numbers p that divide f(x) for every integer x, in ascending
order.
* * * | s486614584 | Runtime Error | p03065 | Input is given from Standard Input in the following format:
N
a_N
:
a_0 | import math
import copy
def trial_division(n):
factor = []
tmp = int(math.sqrt(n)) + 1
for num in range(2, tmp):
while n % num == 0:
n //= num
factor.append(num)
if not factor:
return set([n])
else:
factor.append(n)
return set(factor)
def solve():
n = int(input())
a = []
for i in range(n + 1):
a.append(int(input()))
primes = trial_division(a[-1])
for e in a[:-1]:
output = copy.deepcopy(primes)
for p in primes:
if p % e != 0:
output.remove(p)
primes = output
for p in primes:
print(p)
if __name__ == "__main__":
solve()
| Statement
You are given a polynomial of degree N with integer coefficients:
f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x)
for every integer x. | [{"input": "2\n 7\n -7\n 14", "output": "2\n 7\n \n\n2 and 7 divide, for example, f(1)=14 and f(2)=28.\n\n* * *"}, {"input": "3\n 1\n 4\n 1\n 5", "output": "There may be no integers that satisfy the condition.\n\n* * *"}, {"input": "0\n 998244353", "output": "998244353"}] |
Print all prime numbers p that divide f(x) for every integer x, in ascending
order.
* * * | s527849467 | Wrong Answer | p03065 | Input is given from Standard Input in the following format:
N
a_N
:
a_0 | s = input()[::-1]
a = []
index = 0
while index < len(s) - 1:
if s[index] == "A" and s[index + 1] == "W":
index += 1
while index != len(s) and s[index] == "W":
a.append("C")
index += 1
a.append("A")
else:
a.append(s[index])
index += 1
print("".join(a[::-1]))
| Statement
You are given a polynomial of degree N with integer coefficients:
f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x)
for every integer x. | [{"input": "2\n 7\n -7\n 14", "output": "2\n 7\n \n\n2 and 7 divide, for example, f(1)=14 and f(2)=28.\n\n* * *"}, {"input": "3\n 1\n 4\n 1\n 5", "output": "There may be no integers that satisfy the condition.\n\n* * *"}, {"input": "0\n 998244353", "output": "998244353"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s774563357 | Accepted | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | L = [list(map(int, input().split())) for _ in range(3)]
T = sum([sum(i) for i in L])
print("Yes" if L[0][0] + L[1][1] + L[2][2] == (T / 3) else "No")
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s475673159 | Runtime Error | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | ll=[list(map(int,input().split())) for i in range(3)]
for i in range(2):
for j in range(i+1,3):
for k in range(3):
if ll[k][i]==ll[k][j]:
if not all(ll[t][i]==ll[t][j] for t in range(3)):
print('No')
exit()
if ll[i][k]==ll[j][k]:
if not all(ll[i][t]==ll[j][t] for t in range(3)):
print('No')
exit()
su=0
for lll in ll:
s=sum(lll)
su+=s
if su%3!=0:
print('No')
else: | Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s372320717 | Accepted | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | with open(0) as f:
C = [list(map(int, line.split())) for line in f.readlines()]
b = [(C[i][1] - C[i][0], C[i][2] - C[i][1]) for i in range(3)]
a = [(C[1][j] - C[0][j], C[2][j] - C[1][j]) for j in range(3)]
print("Yes" if a[0] == a[1] == a[2] and b[0] == b[1] == b[2] else "No")
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s513545800 | Accepted | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | g = [[*map(int, input().split())] for _ in range(3)]
for h in [0, 1]:
for w in [0, 1]:
if g[h][w] + g[h + 1][w + 1] != g[h + 1][w] + g[h][w + 1]:
exit(print("No"))
print("Yes")
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s686400017 | Wrong Answer | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | # わからん記録
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s907567885 | Runtime Error | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | l = [list(map(int, input().split())) for i in range(3)]
x = l[0][0], y = l[0][1], z = l[0][2]
a = 0, b = l[1][0] - x, c = l[2][0] - x
if b + y == l[1][1] and b + z == l[1][2] and c + y == l[2][1] and c + z == l[2][2]:
print("Yes")
else:
print("No")
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s583846883 | Accepted | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | ###############################################################################
from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict
mod = 1
def intin():
input_tuple = input().split()
if len(input_tuple) <= 1:
return int(input_tuple[0])
return tuple(map(int, input_tuple))
def intina():
return [int(i) for i in input().split()]
def intinl(count):
return [intin() for _ in range(count)]
def modadd(x, y):
global mod
return (x + y) % mod
def modmlt(x, y):
global mod
return (x * y) % mod
def lcm(x, y):
while y != 0:
z = x % y
x = y
y = z
return x
def combination(x, y):
assert x >= y
if y > x // 2:
y = x - y
ret = 1
for i in range(0, y):
j = x - i
i = i + 1
ret = ret * j
ret = ret // i
return ret
def get_divisors(x):
retlist = []
for i in range(1, int(x**0.5) + 3):
if x % i == 0:
retlist.append(i)
retlist.append(x // i)
return retlist
def get_factors(x):
retlist = []
for i in range(2, int(x**0.5) + 3):
while x % i == 0:
retlist.append(i)
x = x // i
retlist.append(x)
return retlist
def make_linklist(xylist):
linklist = {}
for a, b in xylist:
linklist.setdefault(a, [])
linklist.setdefault(b, [])
linklist[a].append(b)
linklist[b].append(a)
return linklist
def calc_longest_distance(linklist, v=1):
distance_list = {}
distance_count = 0
distance = 0
vlist_previous = []
vlist = [v]
nodecount = len(linklist)
while distance_count < nodecount:
vlist_next = []
for v in vlist:
distance_list[v] = distance
distance_count += 1
vlist_next.extend(linklist[v])
distance += 1
vlist_to_del = vlist_previous
vlist_previous = vlist
vlist = list(set(vlist_next) - set(vlist_to_del))
max_distance = -1
max_v = None
for v, distance in distance_list.items():
if distance > max_distance:
max_distance = distance
max_v = v
return (max_distance, max_v)
def calc_tree_diameter(linklist, v=1):
_, u = calc_longest_distance(linklist, v)
distance, _ = calc_longest_distance(linklist, u)
return distance
class UnionFind:
def __init__(self, n):
self.parent = [i for i in range(n)]
def root(self, i):
if self.parent[i] == i:
return i
self.parent[i] = self.root(self.parent[i])
return self.parent[i]
def unite(self, i, j):
rooti = self.root(i)
rootj = self.root(j)
if rooti == rootj:
return
if rooti < rootj:
self.parent[rootj] = rooti
else:
self.parent[rooti] = rootj
def same(self, i, j):
return self.root(i) == self.root(j)
###############################################################################
def main():
c = [intina() for _ in range(3)]
if c[0][0] - c[0][1] != c[1][0] - c[1][1]:
print("No")
return
if c[0][0] - c[0][1] != c[2][0] - c[2][1]:
print("No")
return
if c[0][0] - c[0][2] != c[1][0] - c[1][2]:
print("No")
return
if c[0][0] - c[0][2] != c[2][0] - c[2][2]:
print("No")
return
if c[0][0] - c[1][0] != c[0][1] - c[1][1]:
print("No")
return
if c[0][0] - c[1][0] != c[0][2] - c[1][2]:
print("No")
return
if c[0][0] - c[2][0] != c[0][1] - c[2][1]:
print("No")
return
if c[0][0] - c[2][0] != c[0][2] - c[2][2]:
print("No")
return
print("Yes")
if __name__ == "__main__":
main()
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s222460457 | Runtime Error | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | c11,c12,c13=map(int,input().split())
c21,c22,c23=map(int,input().split())
c31,c32,c33=map(int,input().split())
if (c11-c12==c21-c22==c31-c32 and c12-c13==c22-c23==c32-c33 and c13-c11==c23-c21==c33-c31 and c11-c21==c12-c22==c13-c23 and c21-c31==c22-c32==c23-c33 and c31-c11==c32-c12==c33-c13 :
print("Yes")
else:
print("No") | Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s241870633 | Runtime Error | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | c = []
for i in range(3):
c.append(list(int(x) for x in input().split()))
c[1][0] -= c[0][0]
c[2][0] -= c[0][0]
if c[1][1] == c[0][1] + c[1][0] and c[1][2] == c[0][2] + c[1][0] and c[2][1] == c[0][1] + c[2][0] and c[2][2] == c[0][2] + c[2][0]:
print(‘Yes’)
else:
print(‘No’) | Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s758770748 | Wrong Answer | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | def find_numbers(grid):
for a1 in range(0, 101):
for a2 in range(0, 101):
if (grid[0] + grid[1] + grid[2]) - 3 * a1 == (
grid[3] + grid[4] + grid[5]
) - 3 * a2:
for a3 in range(0, 101):
if (grid[0] + grid[1] + grid[2]) - 3 * a1 == (
grid[6] + grid[7] + grid[8]
) - 3 * a3:
return True
return False
grid = []
for _ in range(3):
grid.extend(list(map(int, input().split())))
print("Yes" if find_numbers(grid) else "No")
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s692672123 | Accepted | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | l = [list(map(int, input().split())) for _ in range(3)]
flag = "No"
if l[0][1] - l[0][0] == l[1][1] - l[1][0] == l[2][1] - l[2][0]:
if l[0][2] - l[0][1] == l[1][2] - l[1][1] == l[2][2] - l[2][1]:
flag = "Yes"
print(flag)
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s509186011 | Runtime Error | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | import numpy as np
import numpy.linalg as LA
a=[int(i) for i input().split()]
a=[a,[int(i) for i input().split()]]
a.appedn([int(i) for i input().split()])
a = np.array(a)
if LA.det(a)==0:
print('Yes')
else:
print('No') | Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s953487928 | Wrong Answer | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | T = sum([sum(list(map(int, input().split()))) for _ in range(3)])
print("Yes" if (T / 3).is_integer() else "No")
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s979102629 | Accepted | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | n = []
m = [[0 for i in range(3)] for j in range(2)]
for x in range(3):
n.append(list(map(int, input().split())))
k = max(n)
kaisuu = max(k) + 1
def tansa(m):
iti = 2
for j in range(kaisuu):
for k in range(kaisuu):
if j + k == n[iti][iti]:
m[0][iti] = j
m[1][iti] = k
for a in range(kaisuu):
for b in range(kaisuu):
if (
a + b == n[iti - 1][iti - 1]
and a + m[1][iti] == n[iti - 1][iti]
):
m[0][iti - 1] = a
m[1][iti - 1] = b
for c in range(kaisuu):
for d in range(kaisuu):
if (
c + d == n[iti - 2][iti - 2]
and c + m[1][iti - 1] == n[iti - 2][iti - 1]
and c + m[1][iti] == n[iti - 2][iti]
):
m[0][iti - 2] = c
m[1][iti - 2] = d
if (
m[0][1] + m[1][0] == n[1][0]
and m[0][2] + m[1][0] == n[2][0]
and m[0][2] + m[1][1] == n[2][1]
):
print("Yes")
exit()
tansa(m)
print("No")
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s984482299 | Accepted | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | import random
import numpy
import sys
grid = [[0 for i in range(3)] for j in range(3)]
a = [0 for i in range(3)]
b = [0 for i in range(3)]
testgrid = [[0 for i in range(3)] for j in range(3)]
grid[0] = list(map(int, input().split(" ")))
grid[1] = list(map(int, input().split(" ")))
grid[2] = list(map(int, input().split(" ")))
for a[0] in range(100):
for b[0] in range(100):
if (a[0] + b[0]) == grid[0][0]:
testgrid[0][0] = a[0] + b[0]
b[1] = grid[0][1] - a[0]
b[2] = grid[0][2] - a[0]
testgrid[0][1] = a[0] + b[1]
testgrid[0][2] = a[0] + b[2]
if testgrid[0] == grid[0]:
a[1] = grid[1][0] - b[0]
testgrid[1][0] = a[1] + b[0]
testgrid[1][1] = a[1] + b[1]
testgrid[1][2] = a[1] + b[2]
if testgrid[1] == grid[1]:
a[2] = grid[2][0] - b[0]
testgrid[2][0] = a[2] + b[0]
testgrid[2][1] = a[2] + b[1]
testgrid[2][2] = a[2] + b[2]
if testgrid == grid:
print("Yes")
exit()
print("No")
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s562623148 | Runtime Error | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | # -*- coding: utf-8 -*-
## Library
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
## input
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split())
# P = [list(map(int,input().split())) for _ in range(M)]
H = 3
C = [list(map(int, input().split())) for _ in range(H)]
a1 = 0
b1 = C[0][0]
b2 = C[0][1]
b3 = C[0][2]
if !((C[1][0]-b1) == (C[1][1]-b2) and (C[1][1]-b2) == (C[1][2]-b2)):
print("No")
sys.exit()
if !((C[2][0]-b1) == (C[2][1]-b2) and (C[2][1]-b2) == (C[2][2]-b2)):
print("No")
sys.exit()
print("Yes") | Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s558909834 | Accepted | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | 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
""" input template
S = input()
N = int(input())
L = list(map(int, input().split()))
a, b = list(map(int, input().split()))
SL = list(input())
"""
# --------------------------------------------
dp = None
def main():
C = []
for _ in range(3):
C.append(list(map(int, input().split())))
a1_limit = min(C[0]) + 1
a2_limit = min(C[1]) + 1
a3_limit = min(C[2]) + 1
b1_limit = min(C[0][0], C[1][0], C[2][0]) + 1
b2_limit = min(C[0][1], C[1][1], C[2][1]) + 1
b3_limit = min(C[0][2], C[1][2], C[2][2]) + 1
A1, A2, A3, B1, B2, B3 = [], [], [], [], [], []
for i in range(a1_limit):
A1.append(i)
for i in range(a2_limit):
A2.append(i)
for i in range(a3_limit):
A3.append(i)
for i in range(b1_limit):
B1.append(i)
for i in range(b2_limit):
B2.append(i)
for i in range(b3_limit):
B3.append(i)
for a1, a2, a3 in itertools.product(A1, A2, A3):
b1 = C[0][0] - a1
b2 = C[1][1] - a2
b3 = C[2][2] - a3
if a1 + b1 != C[0][0]:
continue
if a2 + b1 != C[1][0]:
continue
if a3 + b1 != C[2][0]:
continue
if a1 + b2 != C[0][1]:
continue
if a2 + b2 != C[1][1]:
continue
if a3 + b2 != C[2][1]:
continue
if a1 + b3 != C[0][2]:
continue
if a2 + b3 != C[1][2]:
continue
if a3 + b3 != C[2][2]:
continue
print("Yes")
return
print("No")
main()
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s467784806 | Accepted | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | import sys
import math
import collections
import itertools
import array
import inspect
# Set max recursion limit
sys.setrecursionlimit(1000000)
# 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:]
def li_input():
return [int(_) for _ in input().split()]
def gcd(n, m):
if n % m == 0:
return m
else:
return gcd(m, n % m)
def gcd_list(L):
v = L[0]
for i in range(1, len(L)):
v = gcd(v, L[i])
return v
def lcm(n, m):
return (n * m) // gcd(n, m)
def lcm_list(L):
v = L[0]
for i in range(1, len(L)):
v = lcm(v, L[i])
return v
# Width First Search (+ Distance)
def wfs_d(D, N, K):
"""
D: 隣接行列(距離付き)
N: ノード数
K: 始点ノード
"""
dfk = [-1] * (N + 1)
dfk[K] = 0
cps = [(K, 0)]
r = [False] * (N + 1)
r[K] = True
while len(cps) != 0:
n_cps = []
for cp, cd in cps:
for i, dfcp in enumerate(D[cp]):
if dfcp != -1 and not r[i]:
dfk[i] = cd + dfcp
n_cps.append((i, cd + dfcp))
r[i] = True
cps = n_cps[:]
return dfk
# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
"""
v: 現在のノード
pre: 1つ前のノード
dist: 現在の距離
以下は別途用意する
D: 隣接リスト(行列ではない)
D_dfs_d: dfs_d関数で用いる,始点ノードから見た距離リスト
"""
global D
global D_dfs_d
D_dfs_d[v] = dist
for next_v, d in D[v]:
if next_v != pre:
dfs_d(next_v, v, dist + d)
return
def sigma(N):
ans = 0
for i in range(1, N + 1):
ans += i
return ans
def comb(n, r):
if n - r < r:
r = n - r
if r == 0:
return 1
if r == 1:
return n
numerator = [n - r + k + 1 for k in range(r)]
denominator = [k + 1 for k in range(r)]
for p in range(2, r + 1):
pivot = denominator[p - 1]
if pivot > 1:
offset = (n - r) % p
for k in range(p - 1, r, p):
numerator[k - offset] /= pivot
denominator[k] /= pivot
result = 1
for k in range(r):
if numerator[k] > 1:
result *= int(numerator[k])
return result
def bisearch(L, target):
low = 0
high = len(L) - 1
while low <= high:
mid = (low + high) // 2
guess = L[mid]
if guess == target:
return True
elif guess < target:
low = mid + 1
elif guess > target:
high = mid - 1
if guess != target:
return False
# --------------------------------------------
dp = None
def main():
C = []
for _ in range(3):
C.append(li_input())
a1, a2, a3, b1, b2, b3 = 0, 0, 0, 0, 0, 0
b1 = C[0][0]
a2 = C[1][0] - b1
a3 = C[2][0] - b1
b2 = C[1][1] - a2
b3 = C[2][2] - a3
for i, a in enumerate([a1, a2, a3]):
for j, b in enumerate([b1, b2, b3]):
if C[i][j] != a + b:
print("No")
return
print("Yes")
main()
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s724391119 | Accepted | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | # coding: utf-8
import re
import math
from collections import defaultdict
from collections import deque
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
# @lru_cache(maxsize=None)
readline = sys.stdin.readline
sys.setrecursionlimit(2000000)
# import numpy as np
alphabet = "abcdefghijklmnopqrstuvwxyz"
mod = int(10**9 + 7)
inf = int(10**20)
def yn(b):
if b:
print("yes")
else:
print("no")
def Yn(b):
if b:
print("Yes")
else:
print("No")
def YN(b):
if b:
print("YES")
else:
print("NO")
class union_find:
def __init__(self, n):
self.n = n
self.P = [a for a in range(N)]
self.rank = [0] * n
def find(self, x):
if x != self.P[x]:
self.P[x] = self.find(self.P[x])
return self.P[x]
def same(self, x, y):
return self.find(x) == self.find(y)
def link(self, x, y):
if self.rank[x] < self.rank[y]:
self.P[x] = y
elif self.rank[y] < self.rank[x]:
self.P[y] = x
else:
self.P[x] = y
self.rank[y] += 1
def unite(self, x, y):
self.link(self.find(x), self.find(y))
def size(self):
S = set()
for a in range(self.n):
S.add(self.find(a))
return len(S)
def is_pow(a, b): # aはbの累乗数か
now = b
while now < a:
now *= b
if now == a:
return True
else:
return False
def bin_(num, size):
A = [0] * size
for a in range(size):
if (num >> (size - a - 1)) & 1 == 1:
A[a] = 1
else:
A[a] = 0
return A
def get_facs(n, mod_=0):
A = [1] * (n + 1)
for a in range(2, len(A)):
A[a] = A[a - 1] * a
if mod_ > 0:
A[a] %= mod_
return A
def comb(n, r, mod, fac):
if n - r < 0:
return 0
return (fac[n] * pow(fac[n - r], mod - 2, mod) * pow(fac[r], mod - 2, mod)) % mod
def next_comb(num, size):
x = num & (-num)
y = num + x
z = num & (~y)
z //= x
z = z >> 1
num = y | z
if num >= (1 << size):
return False
else:
return num
def get_primes(n, type="int"):
if n == 0:
if type == "int":
return []
else:
return [False]
A = [True] * (n + 1)
A[0] = False
A[1] = False
for a in range(2, n + 1):
if A[a]:
for b in range(a * 2, n + 1, a):
A[b] = False
if type == "bool":
return A
B = []
for a in range(n + 1):
if A[a]:
B.append(a)
return B
def is_prime(num):
if num <= 1:
return False
i = 2
while i * i <= num:
if num % i == 0:
return False
i += 1
return True
def ifelse(a, b, c):
if a:
return b
else:
return c
def join(A, c=""):
n = len(A)
A = list(map(str, A))
s = ""
for a in range(n):
s += A[a]
if a < n - 1:
s += c
return s
def factorize(n, type_="dict"):
b = 2
list_ = []
while b * b <= n:
while n % b == 0:
n //= b
list_.append(b)
b += 1
if n > 1:
list_.append(n)
if type_ == "dict":
dic = {}
for a in list_:
if a in dic:
dic[a] += 1
else:
dic[a] = 1
return dic
elif type_ == "list":
return list_
else:
return None
def floor_(n, x=1):
return x * (n // x)
def ceil_(n, x=1):
return x * ((n + x - 1) // x)
return ret
def seifu(x):
return x // abs(x)
######################################################################################################
def main():
C = [list(map(int, input().split())) for a in range(3)]
A = [0] * 3
B = [C[0][0], C[0][1], C[0][2]] * 3
for a in range(1, 3):
A[a] = C[a][0] - B[0]
f = True
for a in range(3):
for b in range(3):
if A[a] + B[b] != C[a][b]:
f = False
Yn(f)
main()
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s927359368 | Accepted | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | c = [list(map(int, input().split())) for i in range(3)]
result = "No"
if c[2][0] - c[1][0] == c[2][1] - c[1][1] == c[2][2] - c[1][2]:
if c[1][0] - c[0][0] == c[1][1] - c[0][1] == c[1][2] - c[0][2]:
if c[0][2] - c[0][1] == c[1][2] - c[1][1] == c[2][2] - c[2][1]:
if c[0][1] - c[0][0] == c[1][1] - c[1][0] == c[2][1] - c[2][0]:
result = "Yes"
print(result)
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s919538259 | Runtime Error | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
a = c1[0]+c2[1]+c3[2]
b = c1[1]+c2[2]+c3[0]
c = c1[2]+c2[0]+c3[1]
d = c1[0]+c2[1]+c3[2]
e = c1[1]+c2[2]+c3[0]
f = c1[2]+c2[0]+c3[1]
if a=b and b=c and c=d and d=e and e=f and f=a:
print('Yes')
else:
print('No')
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s541948626 | Runtime Error | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | c = []
for i in range(3):
c.append(list(map(int, input()split())))
diff = c[1][2] - c[2][2]
c[1][1] -= diff
c[1][0] -= diff
diff = c[0][2] - c[2][2]
c[0][1] -= diff
c[0][0] -= diff
if c[1][1] == c[2][1] and c[0][1] == c[2][1] and c[1][0] == c[2][0] and c[1][0] == c[0][0]:
print('Yes')
else:
print('No')
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s913868218 | Runtime Error | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
a = c1[0]+c2[1]+c3[2]
b = c1[1]+c2[2]+c3[0]
c = c1[2]+c2[0]+c3[1]
d = c1[0]+c2[2]+c3[1]
e = c1[1]+c2[0]+c3[2]
f = c1[2]+c2[1]+c3[0]
if a=b=c=d=e=f:
print('Yes')
else:
print('No')
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s555136297 | Runtime Error | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
a = c1[0]+c2[1]+c3[2]
b = c1[1]+c2[2]+c3[0]
c = c1[2]+c2[0]+c3[1]
d = c1[0]+c2[1]+c3[2]
e = c1[1]+c2[2]+c3[0]
f = c1[2]+c2[0]+c3[1]
if a=b and b=c and c=d and d=e and e=f:
print('Yes')
else:
print('No')
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s583013944 | Runtime Error | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | c=[list(map(int,input().split())) for i in range(3)]
for i in range(101):
info=True
a1=i
b1=c[0][0]-a1
b2=c[0][1]-a1
b3=c[0][2]-a1
a2=c[1][0]-b1
a3=c[2][0]-b1
if min(a1,a2,a3,b1,b2,b3)<0:
info=False
if c[1][1]!=a2+b2:
info=False
if c[2][1]!=a3+b2:
info=False
if info:
print("Yes")
break
else:
print("No") | Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s025390778 | Runtime Error | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | def checker(ded, da):
for i in range(3):
for j in range(2):
if da[i][j] - ded[j] != da[i][2] - ded[2]:
return False
return True
def ma(da):
for i in range(-100, 101):
for j in range(-100, 101):
for k in range(-100, 101)
if not checher([i, j, k], da):
return False
return True
da = [list(map(int,input().split())) for i in range(3)]
if ma(da):
print('Yes')
else:
print('No')
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s511186609 | Runtime Error | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | def checker(ded, da):
for i in range(3):
for j in range(2):
if da[i][j] - ded[j] != da[i][2] - ded[2]:
return False
return True
def ma(da):
for i in range(-100, 101):
for j in range(-100, 101):
for k in range(-100, 101)
if not checher([i, j, k], da):
return False
return True
da = [list(map(int,input().split())) for i in range(3)]
if ma(da):
print('Yes')
else:
print('No')
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s133991855 | Runtime Error | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | c = []
for _ in range(3):
c.append(list(input().split()))
if c[0][0]+c[1][1]+c[2][2]] == c[0][0]+c[1][2]+c[2][1] and c[0][0]+c[1][2]+c[2][1] == c[0][1]+c[1][0]+c[2][2]:
if c[0][1]+c[1][0]+c[2][2] == c[0][1]+c[1][2]+c[2][0] and c[0][1]+c[1][2]+c[2][0] == c[0][2]+c[1][0]+c[2][1]:
if c[0][2]+c[1][0]+c[2][1] == c[0][2]+c[1][1]+c[2][0]:
print("Yes")
else:
print("No")
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s254901199 | Wrong Answer | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | grid = [list(map(int, input().split())) for _ in range(3)]
total = sum([sum(row) for row in grid])
print("Yes" if total % 3 == 0 else "No")
| Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.
* * * | s776823708 | Runtime Error | p03435 | Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3} | a, b, c, d, e, f, g, h, i = 3.times.flat_map{ gets.split.map(&:to_i) }
puts a - b == d - e && d - e == g - h && b - c == e - f && e - f == h - i ? 'Yes' : 'No' | Statement
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j),
where (i, j) denotes the square at the i-th row from the top and the j-th
column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3
whose values are fixed, and the number written in the square (i, j) is equal
to a_i + b_j.
Determine if he is correct. | [{"input": "1 0 1\n 2 1 2\n 1 0 1", "output": "Yes\n \n\nTakahashi is correct, since there are possible sets of integers such as:\na_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.\n\n* * *"}, {"input": "2 2 2\n 2 1 2\n 2 2 2", "output": "No\n \n\nTakahashi is incorrect in this case.\n\n* * *"}, {"input": "0 8 8\n 0 8 8\n 0 8 8", "output": "Yes\n \n\n* * *"}, {"input": "1 8 6\n 2 9 7\n 0 7 7", "output": "No"}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.