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
Among A, B and C, print the integer that is different from the rest. * * *
s389349581
Accepted
p03573
Input is given from Standard Input in the following format: A B C
x = input().split() t = "" if x[0] == x[1]: t = x[0] elif x[1] == x[2]: t = x[1] elif x[0] == x[2]: t = x[0] for i in x: if t != i: print(i)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s814239867
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
N, M = map(int, input().split()) l = [[] for i in range(N)] e = [[int(i) for i in input().split()] for i in range(M)] e0 = e c = 0 def DFS(v): seen.append(v) for v2 in l[v]: if not v2 in seen: DFS(v2) return seen for i in range(M): seen = [] l = [[] for i in range(N)] for j in range(M): if j != i: l[(e[j][0]) - 1].append(e[j][1] - 1) l[(e[j][1]) - 1].append(e[j][0] - 1) S = DFS(0) if len(S) != N: c += 1 print(c)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s173957328
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
import sys as chokudairedcoderatcoderowner A,B,C = map(int,chokudairedcoderatcoderowner.stdin.readline().split()) if A == B: print(C) else if A == C: print(B) else: print(A)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s807202596
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
Python Editor 5.2.0. New Open Save Run Export untitle.py [no ads ?] Snippets print(A) 1 import numpy as np 2 ​ 3 A, B, C = (list(map(int, input().split()))) 4 if(A == B): 5 print(C) 6 elif(A == C): 7 print(B) 8 else: 9 print(A)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s945653107
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
n = list(map(int, input().split())) c = Counter(n) for i in c: if c[i] == 1: res = i print(res)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s503659168
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
#Nはノード数、Mはエッジ数 n,m = map(int, input().split()) ab = [list(map(int, input().split())) for i in range(m)] cnt=0 for x in ab: ls=list(range(n)) for y in ab: if y !=x: for i in range(n) ls=[ls[y[0]-1] if ls[i]==ls[y[1]-1] else ls[i] for i in range(n)] #bの値を根っこ(低い方a)にする if len(set(ls)) !=1: cnt+=1 print(cnt)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s794077860
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c=(int(x) for x in input().split()) if a=b: print(c) elif b=c: print(a) elif c=a: print(b) else: pass
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s562280228
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
A,B,C = map(int,input()split()) if A == B: answer = C elif B == C: answer = A elif A ==C: answer = B print(answer)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s536935476
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
import sys as chokudairedcoderatcoderowner A,B,C = map(int,chokudairedcoderatcoderowner.stdin.readline()) if A == B: print(C) else if A == C: print(B) else: print(A)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s138571727
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
if __name__ = '__main__': A, B, C = map(int, input().split()) if A == B: print(C) elif A == C: print(B) else: print(A)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s132375287
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
H, W = map(int, input().split()) grid = [[0 for w in range(W)] for h in range(H)] sharps = [] for h in range(H): row = [v for v in input()] # print(row) for w, r in enumerate(row): # print(w,r) if r == "#": # grid[h][w] = "#" sharps.append([h, w]) if h >= 1: grid[h - 1][w] += 1 if w >= 1: grid[h - 1][w - 1] += 1 if w <= W - 2: grid[h - 1][w + 1] += 1 if h <= H - 2: grid[h + 1][w] += 1 if w >= 1: grid[h + 1][w - 1] += 1 if w <= W - 2: grid[h + 1][w + 1] += 1 if w >= 1: grid[h][w - 1] += 1 if w <= W - 2: grid[h][w + 1] += 1 # print(sharps) for sharp in sharps: grid[sharp[0]][sharp[1]] = "#" for g in grid: print("".join([str(v) for v in g]))
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s111837556
Accepted
p03573
Input is given from Standard Input in the following format: A B C
a = sorted(list(map(int, input().split()))) i = 0 if a[1] != a[0] else 2 print(a[i])
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s045579807
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c=map(int,input().split()) print(a if b==c else b if a==c else c if a==b)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s039693537
Wrong Answer
p03573
Input is given from Standard Input in the following format: A B C
a, b, t = map(int, input().split()) print(t // a * b)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s533994969
Wrong Answer
p03573
Input is given from Standard Input in the following format: A B C
a = sorted(list(input())) print(a[0] if a[0] != a[1] else a[2])
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s023140966
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
li = set(list(map(int, input().split()))) print(li[0])
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s482567253
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
X = list(map(int, input().split)) X.sort() print(sum(X) - X[1] * 2)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s359716923
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c=sorted(map(int,input().split())) if("c" a==b else "a")
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s529082405
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c=map(int,input().split()) if a==b: print(c) elif b==c print(a) else: print(b)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s062170636
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c = map(int,input().split()) print('a' if b==c else 'b' if a==c else 'c' if a=b)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s647600011
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
if input[0] == input[1]: print(input[2])
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s124442826
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a=list(map(int, input().split())) a = sorted(a) print(a[0] if a[1] == a[2] else a[2])
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s256533515
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
nums = map(int, input().split()) print(sum(nums) - set(nums))
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s723544600
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c = map(int,input().split()) print(a if b==c else b if a==c else c if a==b)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
For each dataset, print "YES" or "NO" in a line.
s772287528
Wrong Answer
p00021
Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$ You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point.
Parallelism There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "YES" and if not prints "NO".
[{"input": "0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0\n 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0", "output": "YES\n NO"}]
For each dataset, print "YES" or "NO" in a line.
s729014578
Wrong Answer
p00021
Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$ You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point.
r = [] for i in range(int(input())): d = [float(i) for i in input().split()] if d[0] - d[2] != 0 and d[4] - d[6] != 0: a = (d[1] - d[3]) / (d[0] - d[2]) b = (d[5] - d[7]) / (d[4] - d[6]) if a == b: r.extend([1]) else: r.extend([0]) elif d[0] == d[2] and d[4] == d[6]: r.extend([1]) else: r.extend([0]) [print("YES") if i else print("NO") for i in r]
Parallelism There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "YES" and if not prints "NO".
[{"input": "0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0\n 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0", "output": "YES\n NO"}]
For each dataset, print "YES" or "NO" in a line.
s416349291
Wrong Answer
p00021
Input consists of several datasets. In the first line, you are given the number of datasets $n$ ($n \leq 100$). There will be $n$ lines where each line correspondgs to each dataset. Each dataset consists of eight real numbers: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_4$ $y_4$ You can assume that $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \leq 100$. Each value is a real number with at most 5 digits after the decimal point.
num = int(input()) for i in range(num): print(input())
Parallelism There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints "YES" and if not prints "NO".
[{"input": "0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0\n 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0", "output": "YES\n NO"}]
Print K lines. The i-th line should contain the i-th smallest Snuke number. * * *
s530403618
Wrong Answer
p03318
Input is given from Standard Input in the following format: K
KK = int(input()) for j in range(KK): K = j + 1 if K % 9 == 0: print(9, end="") else: print(K % 9, end="") for i in range((K - 1) // 9): print(9, end="") print("")
Statement Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(123) = 1 + 2 + 3 = 6. We will call an integer n a **Snuke number** when, for all positive integers m such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds. Given an integer K, list the K smallest Snuke numbers.
[{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}]
Print K lines. The i-th line should contain the i-th smallest Snuke number. * * *
s292101435
Wrong Answer
p03318
Input is given from Standard Input in the following format: K
K = int(input()) count = 1 num = 1 while count <= K: if num <= 9: print(num) count += 1 elif num % 10 == 9: print(num) count += 1 num += 1
Statement Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(123) = 1 + 2 + 3 = 6. We will call an integer n a **Snuke number** when, for all positive integers m such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds. Given an integer K, list the K smallest Snuke numbers.
[{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}]
Print K lines. The i-th line should contain the i-th smallest Snuke number. * * *
s133009534
Wrong Answer
p03318
Input is given from Standard Input in the following format: K
K = int(input()) tmp = 0 i = 1 k = 0 while True: if k == K: break print(i * (10**tmp) + (10**tmp - 1)) k += 1 i += 1 if i == 10: i = 1 tmp += 1
Statement Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(123) = 1 + 2 + 3 = 6. We will call an integer n a **Snuke number** when, for all positive integers m such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds. Given an integer K, list the K smallest Snuke numbers.
[{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}]
Print K lines. The i-th line should contain the i-th smallest Snuke number. * * *
s833329751
Accepted
p03318
Input is given from Standard Input in the following format: K
def s(n): return sum([ord(x) - ord("0") for x in str(n)]) def r(n): return n / s(n) def f(n): d = 10 m = n while d <= n * 10: n //= d n *= d n += d - 1 d *= 10 if r(n) < r(m): m = n return m n = 1 for _ in range(int(input())): print(n) n = f(n + 1)
Statement Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(123) = 1 + 2 + 3 = 6. We will call an integer n a **Snuke number** when, for all positive integers m such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds. Given an integer K, list the K smallest Snuke numbers.
[{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}]
Print K lines. The i-th line should contain the i-th smallest Snuke number. * * *
s173655834
Wrong Answer
p03318
Input is given from Standard Input in the following format: K
L = list() N = int(input()) for i in range(1, N + 1): s = i // 9 t = i % 9 L.append(((t + 1) * pow(10, s)) - 1) for i in range(2, 19): for j in range(1, 10): for s in range(1, min(10, i)): L.append((s * 10 + j) * pow(10, i) - 1) L = sorted(list(set(L))) for i in range(N): print(L[i])
Statement Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(123) = 1 + 2 + 3 = 6. We will call an integer n a **Snuke number** when, for all positive integers m such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds. Given an integer K, list the K smallest Snuke numbers.
[{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}]
Print K lines. The i-th line should contain the i-th smallest Snuke number. * * *
s957230307
Accepted
p03318
Input is given from Standard Input in the following format: K
#!/usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import itertools sys.setrecursionlimit(10**5) stdin = sys.stdin bisect_left = bisect.bisect_left bisect_right = bisect.bisect_right def LI(): return list(map(int, stdin.readline().split())) def LF(): return list(map(float, stdin.readline().split())) def LI_(): return list(map(lambda x: int(x) - 1, stdin.readline().split())) def II(): return int(stdin.readline()) def IF(): return float(stdin.readline()) def LS(): return list(map(list, stdin.readline().split())) def S(): return list(stdin.readline().rstrip()) def IR(n): return [II() for _ in range(n)] def LIR(n): return [LI() for _ in range(n)] def FR(n): return [IF() for _ in range(n)] def LFR(n): return [LI() for _ in range(n)] def LIR_(n): return [LI_() for _ in range(n)] def SR(n): return [S() for _ in range(n)] def LSR(n): return [LS() for _ in range(n)] mod = 1000000007 inf = float("INF") # A def A(): s = S() a = s.count("-") b = s.count("+") print(b - a) return # B def B(): n = S() num = sum(map(int, n)) n = int("".join(n)) print(["Yes", "No"][n % num > 0]) return # C def C(): n, k = LI() LI() print((n - k) // (k - 1) + 1 + bool((n - k) % (k - 1))) return # D # 解説AC # 解説むずくね?これでわかる人いる? # 順に理解していく # 1) 桁数が上がるとx/S(x)が上昇するのは解説を見ればわかる # # 2) 下一桁が9であることを理解する # xの下一桁が9でないとして # x/S(x) - (x+1)/S(x+1) について S(x) =y として # x/y - (x+1)/(y+1) = x/y - x/(y+1) - 1/(y+1) # = x * (1/y - 1/(y+1)) - 1/(y+1) # = x/y/(y+1) - 1/(y+1) # = (x/y - 1)/(y+1) → (1) # 今明らかにx/y >= 1なので (1) > 0 だから # x/y > (x+1)/(y+1) # よって下一桁は大きいほうがいいので9である # # 3)繰上りがない場合変化させる桁は # できるだけ小さいほうがいいということを示す # 元の数をxとしてi桁目とi+1桁目について変化させるとすると # どう考えてもx/S(x)はS(x)は同等の上昇がみられる # 対しi+1桁目のほうがxが上昇するためi桁目の # ほうがよいことがわかる # # 4) 確定させた桁の数が変わらないことを示す # つまり変化させられる桁(そこの桁をi桁目として10**(i-1)をxに足す # と最小値がとりうると考えられる)がi桁目としてi-1桁目より小さな桁 # について変化させる意味がないことを示す # x/S(x) - (x+10^(i-1))/S(x+1) について上と同様にすれば # = (x/y - 10**(i-1)) / y が言えるので # x/y が 10**(i-1) を上回っている場合 # その桁より小さい値を変化させてもx/S(x)が減少しないことがわかる # x/S(x)がx以上の整数でx/S(x)を一番小さくできるのであるから、 # 一度上回った 10**(i-1) をx/S(x)が下回ることはあり得ない # よって、変化させられる桁がi桁目としてi-1桁目より小さな桁 # について変化させる意味がないことがわかった # # 4)このまま毎回x/yの値を計算してそれの桁数から足す10**(i-1) # を計算してもよいが、変化させる桁目をi桁目としてi+1桁目を変化させた # ほうがx/S(x)が小さくなるという状態は # つまりx/yが10**(i-1)を上回ったという # 意味になるためもっと計算量を落とした方法が本解法になる def D(): K = II() ans = 1 i = 0 def Sunuke(a): return a / sum(map(int, str(a))) def Check(a, i): return Sunuke(a + 10**i) > Sunuke(ans + 10 ** (i + 1)) while K: print(ans) K -= 1 i += Check(ans, i) ans += 10**i return # Solve if __name__ == "__main__": D()
Statement Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(123) = 1 + 2 + 3 = 6. We will call an integer n a **Snuke number** when, for all positive integers m such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds. Given an integer K, list the K smallest Snuke numbers.
[{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}]
Print K lines. The i-th line should contain the i-th smallest Snuke number. * * *
s290270431
Accepted
p03318
Input is given from Standard Input in the following format: K
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permutations sys.setrecursionlimit(10000) def read_int(): return int(input()) def read_int_n(): return list(map(int, input().split())) def read_float(): return float(input()) def read_float_n(): return list(map(float, input().split())) def read_str(): return input() def read_str_n(): return list(map(str, input().split())) def error_print(*args): print(*args, file=sys.stderr) def mt(f): import time def wrap(*args, **kwargs): s = time.time() ret = f(*args, **kwargs) e = time.time() error_print(e - s, "sec") return ret return wrap def S(n): s = 0 while n != 0: s += n % 10 n //= 10 return s # @mt def slv(K): ans = [(i, i / S(i)) for i in range(1, 10)] for i in range(16): a = i if a > 4: a = 4 for j in range(1, 10**a): b = (10 ** (i - a + 1)) * j + (10 ** (i - a + 1) - 1) if b < 10 ** (i - 1): continue s = S(b) while ans[-1][1] > b / s or ans[-1][0] == b: (ans.pop()) ans.append((b, b / s)) # print(ans[-1]) # error_print(len(ans)) # for r in ans: # error_print(r) error_print(len(ans)) return "\n".join(map(str, map(lambda x: x[0], ans[:K]))) def main(): K = read_int() print(slv(K)) if __name__ == "__main__": main()
Statement Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(123) = 1 + 2 + 3 = 6. We will call an integer n a **Snuke number** when, for all positive integers m such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds. Given an integer K, list the K smallest Snuke numbers.
[{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}]
Print K lines. The i-th line should contain the i-th smallest Snuke number. * * *
s021488168
Accepted
p03318
Input is given from Standard Input in the following format: K
def sunuke_sum(arg): sum_digit = 0 for char in arg: sum_digit += int(char) return sum_digit input_num = int(input()) sunuke_dict = {} min_sunuke_div = 10**20 for d in reversed(range(1, 16)): for n in reversed(range(10, 1000)): i = n * (10**d) + (10**d - 1) sunuke_div = i / sunuke_sum(str(i)) sunuke_dict[i] = sunuke_div for i in reversed(range(1, 110)): sunuke_div = i / sunuke_sum(str(i)) sunuke_dict[i] = sunuke_div sunuke_sorted = sorted(sunuke_dict.items()) sunuke_list = [] for value, div_value in reversed(sunuke_sorted): if min_sunuke_div >= div_value: sunuke_list.append(value) min_sunuke_div = div_value sunuke_list.reverse() for i in range(0, input_num): print(str(sunuke_list[i]))
Statement Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(123) = 1 + 2 + 3 = 6. We will call an integer n a **Snuke number** when, for all positive integers m such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds. Given an integer K, list the K smallest Snuke numbers.
[{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}]
Print K lines. The i-th line should contain the i-th smallest Snuke number. * * *
s695711799
Wrong Answer
p03318
Input is given from Standard Input in the following format: K
import sys k = int(input()) if k <= 9: for i in range(1, k + 1): print(i) sys.exit() for i in range(1, 9): print(i) count = 8 s = 0 lst = [] for i in range(1, 17): for j in range(1, 1000): if j % 10 == 0: continue a = j * (10**i) - 1 b = list(str(a)) c = 0 for u in b: c += int(u) if (10**i) * c >= a: lst.append(a) count += 1 if count == k: s = 10 break else: break if s == 10: break lst.sort() s = 1 while s < len(lst): if lst[s] == lst[s - 1]: lst.pop(s) else: s += 1 for u in lst: print(u)
Statement Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(123) = 1 + 2 + 3 = 6. We will call an integer n a **Snuke number** when, for all positive integers m such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds. Given an integer K, list the K smallest Snuke numbers.
[{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}]
Print K lines. The i-th line should contain the i-th smallest Snuke number. * * *
s698780523
Wrong Answer
p03318
Input is given from Standard Input in the following format: K
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools from collections import deque sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 DR = [1, -1, 0, 0] DC = [0, 0, 1, -1] def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def I(): return int(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) def S(): return input() def S(n): cnt = 0 for c in str(n): cnt += int(c) return cnt def calc_i_to_change(cand): """ 299999 ^ 543210 012345 return 3 """ l = sum(cand) n = int("".join([str(x) for x in cand])) for i in range(len(cand))[::-1]: power = len(cand) - i k = 10**power if n - k * l <= 0: return len(cand) - 1 - power return -1 def main(): # test = [] # for i in range(1, 3000000): # test.append((i, i/S(i))) # # print('n: ', i, ' n/s(n): ', i/S(i)) # test = sorted(test, key=lambda x:x[1]) # cur_min = 0 # for t in test: # n, res = t # if n < cur_min: # continue # cur_min = n # print(t) K = I() num = 0 n_digit = 1 cand = [1] ans = [] while K > 0: # import pdb # pdb.set_trace() i_to_change = calc_i_to_change(cand) if i_to_change <= 0: ans.append("".join([str(x) for x in cand])) K -= 1 while 0 < i_to_change < n_digit and K > 0: for k in range(10): cand[i_to_change] = k ans.append("".join([str(x) for x in cand])) K -= 1 i_to_change -= 1 # else: # ans.append(''.join([str(x) for x in cand])) # K -= 1 if cand[0] < 9: cand[0] += 1 else: n_digit += 1 cand = [1] + [9] * (n_digit - 1) for a in ans: print(a) main()
Statement Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(123) = 1 + 2 + 3 = 6. We will call an integer n a **Snuke number** when, for all positive integers m such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds. Given an integer K, list the K smallest Snuke numbers.
[{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}]
Print the minimum value of $P$ in a line.
s272258752
Wrong Answer
p02270
In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
Input In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
[{"input": "5 3\n 8\n 1\n 7\n 3\n 9", "output": "10\n \n\nIf the first truck loads two packages of $\\\\{8, 1\\\\}$, the second truck loads\ntwo packages of $\\\\{7, 3\\\\}$ and the third truck loads a package of $\\\\{9\\\\}$,\nthen the minimum value of the maximum load $P$ shall be 10."}, {"input": "4 2\n 1\n 2\n 2\n 6", "output": "6\n \n\nIf the first truck loads three packages of $\\\\{1, 2, 2\\\\}$ and the second\ntruck loads a package of $\\\\{6\\\\}$, then the minimum value of the maximum load\n$P$ shall be 6."}]
Print the minimum value of $P$ in a line.
s608148357
Wrong Answer
p02270
In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
def can_cant(n, k, w_n, p): w_p = [] wp = 0 for w in w_n: if w > p: return False elif wp + w < p: wp += w elif wp + w == p: wp += w w_p.append(wp) wp = 0 elif wp + w > p: w_p.append(wp) wp = w # else: # if wp!=0: # w_p.append(wp) # wp=0 # else:wp=w if wp < p: w_p.append(wp) if len(w_p) <= k: # print("True") return True elif len(w_p) > k: # print("False") return False if __name__ == "__main__": n, k = list( map( int, input( "??????????????°??¨????????°??°?????\?????????:", ).split(), ) ) w_n = [ int( input( "????????????????????\?????????:", ) ) for i in range(n) ] # print(can_cant(n,k,w_n,10)) min_p = sum(w_n) // k max_p = sum(w_n) p = (min_p + max_p) // 2 # print("min_p={},max_p={},p={}".format(min_p, max_p, p)) pre_p = 0 while min_p < p: print(p) result = can_cant(n, k, w_n, p) if result: pre_p = p max_p = p p = (min_p + max_p) // 2 # print("max_p=p={},min_p={}, p={}".format(max_p, min_p, p)) elif not result: pre_p = p min_p = p p = (min_p + max_p) // 2 # print("max_p={},min_p=p={}, p={}".format(max_p, min_p, p)) print(pre_p)
Input In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
[{"input": "5 3\n 8\n 1\n 7\n 3\n 9", "output": "10\n \n\nIf the first truck loads two packages of $\\\\{8, 1\\\\}$, the second truck loads\ntwo packages of $\\\\{7, 3\\\\}$ and the third truck loads a package of $\\\\{9\\\\}$,\nthen the minimum value of the maximum load $P$ shall be 10."}, {"input": "4 2\n 1\n 2\n 2\n 6", "output": "6\n \n\nIf the first truck loads three packages of $\\\\{1, 2, 2\\\\}$ and the second\ntruck loads a package of $\\\\{6\\\\}$, then the minimum value of the maximum load\n$P$ shall be 6."}]
Print the minimum value of $P$ in a line.
s727338188
Runtime Error
p02270
In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
from itertools import combinations def func(w, partition): sum_list = [sum(w[0 : partition[0]])] for i in range(len(partition)): if i < len(partition) - 1: sum_list.append(sum(w[partition[i] : partition[i + 1]])) else: sum_list.append(sum(w[partition[i] :])) return max(sum_list) n, k = [int(x) for x in input().split()] w = [int(input()) for _ in range(n)] w_indices = [i for i in range(1, n)] partition_list = combinations(w_indices, k - 1) p_list = [] for partition in partition_list: p_list.append(func(w, partition)) print(min(p_list))
Input In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
[{"input": "5 3\n 8\n 1\n 7\n 3\n 9", "output": "10\n \n\nIf the first truck loads two packages of $\\\\{8, 1\\\\}$, the second truck loads\ntwo packages of $\\\\{7, 3\\\\}$ and the third truck loads a package of $\\\\{9\\\\}$,\nthen the minimum value of the maximum load $P$ shall be 10."}, {"input": "4 2\n 1\n 2\n 2\n 6", "output": "6\n \n\nIf the first truck loads three packages of $\\\\{1, 2, 2\\\\}$ and the second\ntruck loads a package of $\\\\{6\\\\}$, then the minimum value of the maximum load\n$P$ shall be 6."}]
Print the minimum value of $P$ in a line.
s956116257
Wrong Answer
p02270
In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
import collections w = collections.deque() print(w)
Input In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
[{"input": "5 3\n 8\n 1\n 7\n 3\n 9", "output": "10\n \n\nIf the first truck loads two packages of $\\\\{8, 1\\\\}$, the second truck loads\ntwo packages of $\\\\{7, 3\\\\}$ and the third truck loads a package of $\\\\{9\\\\}$,\nthen the minimum value of the maximum load $P$ shall be 10."}, {"input": "4 2\n 1\n 2\n 2\n 6", "output": "6\n \n\nIf the first truck loads three packages of $\\\\{1, 2, 2\\\\}$ and the second\ntruck loads a package of $\\\\{6\\\\}$, then the minimum value of the maximum load\n$P$ shall be 6."}]
Print the minimum value of $P$ in a line.
s755799359
Accepted
p02270
In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
def judge( loads, truck, truck_weight ): # loadsは荷物のリスト.truckは使えるトラックの台数 truck_num = 1 weight_sum = 0 for load in loads: if weight_sum + load > truck_weight: truck_num += 1 if truck < truck_num: return 0 weight_sum = load else: weight_sum += load return 1 # 与えられた条件で荷物の積み込みが可能なら1、不可能なら0を返す def binal_search( loads, truck, min, max ): # minからmaxの範囲で最小トラック積載量を求める if max == min: return min mid = (min + max) // 2 if judge(loads, truck, mid): return binal_search(loads, truck, min, mid) else: return binal_search(loads, truck, mid + 1, max) n, truck = map(int, input().split()) loads = [] for loop in range(n): loads.append(int(input())) loads_max = sum(loads) loads_min = max(loads) print(binal_search(loads, truck, loads_min, loads_max))
Input In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
[{"input": "5 3\n 8\n 1\n 7\n 3\n 9", "output": "10\n \n\nIf the first truck loads two packages of $\\\\{8, 1\\\\}$, the second truck loads\ntwo packages of $\\\\{7, 3\\\\}$ and the third truck loads a package of $\\\\{9\\\\}$,\nthen the minimum value of the maximum load $P$ shall be 10."}, {"input": "4 2\n 1\n 2\n 2\n 6", "output": "6\n \n\nIf the first truck loads three packages of $\\\\{1, 2, 2\\\\}$ and the second\ntruck loads a package of $\\\\{6\\\\}$, then the minimum value of the maximum load\n$P$ shall be 6."}]
Print the minimum value of $P$ in a line.
s632039219
Wrong Answer
p02270
In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
# encoding: utf-8 import sys import math class Solution: def __init__(self): """ init input array """ self.__input = sys.stdin.readlines() @property def solution(self): product_num = int(self.__input[0].split()[0]) truck_num = int(self.__input[0].split()[1]) weight_list = list(map(int, self.__input[1:])) assert product_num == len(weight_list) # print(product_num, truck_num, weight_list) truck_capacity = max(math.ceil(sum(weight_list) / truck_num), max(weight_list)) return str(truck_capacity) # for each in array_2: # if self.allocation(key=each, array=weight_list, array_length=max(weight_list)): # truck_capacity += 1 # # return str(truck_capacity) # # @staticmethod # def allocation(key, array, array_length): # # print(len(set(array_1).intersection(set(array_2)))) # left, right = max(array), array_length # while left < right: # mid = (left + right) // 2 # if key == array[mid]: # return True # elif key < array[mid]: # right = mid # else: # left = mid + 1 # return False if __name__ == "__main__": case = Solution() print(case.solution)
Input In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
[{"input": "5 3\n 8\n 1\n 7\n 3\n 9", "output": "10\n \n\nIf the first truck loads two packages of $\\\\{8, 1\\\\}$, the second truck loads\ntwo packages of $\\\\{7, 3\\\\}$ and the third truck loads a package of $\\\\{9\\\\}$,\nthen the minimum value of the maximum load $P$ shall be 10."}, {"input": "4 2\n 1\n 2\n 2\n 6", "output": "6\n \n\nIf the first truck loads three packages of $\\\\{1, 2, 2\\\\}$ and the second\ntruck loads a package of $\\\\{6\\\\}$, then the minimum value of the maximum load\n$P$ shall be 6."}]
Print the minimum value of $P$ in a line.
s879411452
Accepted
p02270
In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
# coding:utf-8 n, k = map(int, input().split()) backList = [] for i in range(n): backList.append(int(input())) def capa(p, k): cnt = 0 pcopy = p num = 0 for back in backList: if back > p: break if back <= pcopy: pcopy -= back cnt += 1 continue elif back > pcopy: if num == k - 1: return cnt pcopy = p - back cnt += 1 num += 1 return cnt p_min = 0 p_max = 100000 * 10000 def biSearch(p_min, p_max): p = p_max - p_min if p_max - p_min <= 1: return p_max if p % 2 == 0: c = p_min + int(p / 2) else: c = p_min + int((p + 1) / 2) v = capa(c, k) if v < n: p_min = c else: p_max = c return biSearch(p_min, p_max) p = biSearch(p_min, p_max) n_init = n while n_init <= n: p -= 1 n = capa(p, k) print(p + 1)
Input In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
[{"input": "5 3\n 8\n 1\n 7\n 3\n 9", "output": "10\n \n\nIf the first truck loads two packages of $\\\\{8, 1\\\\}$, the second truck loads\ntwo packages of $\\\\{7, 3\\\\}$ and the third truck loads a package of $\\\\{9\\\\}$,\nthen the minimum value of the maximum load $P$ shall be 10."}, {"input": "4 2\n 1\n 2\n 2\n 6", "output": "6\n \n\nIf the first truck loads three packages of $\\\\{1, 2, 2\\\\}$ and the second\ntruck loads a package of $\\\\{6\\\\}$, then the minimum value of the maximum load\n$P$ shall be 6."}]
Let v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query. Print M integers v_i to Standard Output in the following format: v_1 v_2 \vdots v_M * * *
s243106166
Accepted
p02620
Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries. D c_1 c_2 \cdots c_{26} s_{1,1} s_{1,2} \cdots s_{1,26} \vdots s_{D,1} s_{D,2} \cdots s_{D,26} t_1 t_2 \vdots t_D M d_1 q_1 d_2 q_2 \vdots d_M q_M * The constraints and generation methods for the input part are the same as those for Problem A. * For each d=1,\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\ldots,26}. * The number of queries M is an integer satisfying 1\leq M\leq 10^5. * For each i=1,\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\ldots,D}. * For each i=1,\ldots,26, q_i is an integer satisfying 1\leq q_i\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.
def calcScore(): for d in range(1, D + 1): id = t[d] # この日に開催するコンテスト sinceLast[d][id] = 0 score[d][id] = s[d][id] for i in range(1, 26 + 1): if i == id: continue sinceLast[d][i] = sinceLast[d - 1][i] + 1 score[d][i] = -c[i] * sinceLast[d][i] ans = 0 for d in range(1, D + 1): ans += sum(score[d]) return ans def calcScoreDiff(score, d, before, after): ans = 0 for dd in range(d, D + 1): if dd > d and t[dd] == before: break sinceLast[dd][before] = sinceLast[dd - 1][before] + 1 ans -= score[dd][before] score[dd][before] = -c[before] * sinceLast[dd][before] ans += score[dd][before] ans -= score[d][after] sinceLast[d][after] = 0 score[d][after] = s[d][after] ans += score[d][after] for dd in range(d + 1, D + 1): if t[dd] == after: break sinceLast[dd][after] = sinceLast[dd - 1][after] + 1 ans -= score[dd][after] score[dd][after] = -c[after] * sinceLast[dd][after] ans += score[dd][after] return ans D = int(input()) c = [0] + [int(x) for x in input().split()] s = [[0 for _ in range(26 + 1)]] + [ [0] + [int(x) for x in input().split()] for _ in range(D) ] t = [0] + [int(input()) for _ in range(D)] score = [[0] * (26 + 1) for _ in range(D + 1)] sinceLast = [[0] * (26 + 1) for _ in range(D + 1)] tot = calcScore() M = int(input()) for i in range(M): d, after = [int(x) for x in input().split()] before = t[d] t[d] = after diff = calcScoreDiff(score, d, before, after) tot += diff print(tot)
Statement You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query. * * *
[{"input": "5\n 86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n 19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n 6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n 6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n 8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n 19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n 1\n 17\n 13\n 14\n 13\n 5\n 1 7\n 4 11\n 3 4\n 5 24\n 4 19", "output": "72882\n 56634\n 38425\n 27930\n 42884\n \n\nNote that this example is a small one for checking the problem specification.\nIt does not satisfy the constraint D=365 and is never actually given as a test\ncase."}]
Let v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query. Print M integers v_i to Standard Output in the following format: v_1 v_2 \vdots v_M * * *
s183457025
Runtime Error
p02620
Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries. D c_1 c_2 \cdots c_{26} s_{1,1} s_{1,2} \cdots s_{1,26} \vdots s_{D,1} s_{D,2} \cdots s_{D,26} t_1 t_2 \vdots t_D M d_1 q_1 d_2 q_2 \vdots d_M q_M * The constraints and generation methods for the input part are the same as those for Problem A. * For each d=1,\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\ldots,26}. * The number of queries M is an integer satisfying 1\leq M\leq 10^5. * For each i=1,\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\ldots,D}. * For each i=1,\ldots,26, q_i is an integer satisfying 1\leq q_i\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.
from numba import njit import numpy as np d = int(input()) cs = list(map(int, input().split())) sm = [list(map(int, input().split())) for _ in range(d)] cs = np.array(cs, dtype=np.int64) sm = np.array(sm, dtype=np.int64) @njit("i8(i8[:])", cache=True) def total_satisfaction(ts): ls = np.zeros(26, dtype=np.int64) s = 0 for i in range(d): t = ts[i] t -= 1 s += sm[i][t] ls[t] = i + 1 dv = cs * ((i + 1) - ls) s -= dv.sum() return s @njit("void(i8[:],i8[:,:])", cache=True) def fn(ts, dqs): for di, qi in dqs: ts[di - 1] = qi s = total_satisfaction(ts) print(s) ts = [int(input()) for _ in range(d)] m = int(input()) dqs = [list(map(int, input().split())) for _ in range(m)] ts = np.array(ts, dtype=np.int64) dqs = np.array(dqs, dtype=np.int64) fn(ts, dqs)
Statement You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query. * * *
[{"input": "5\n 86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n 19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n 6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n 6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n 8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n 19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n 1\n 17\n 13\n 14\n 13\n 5\n 1 7\n 4 11\n 3 4\n 5 24\n 4 19", "output": "72882\n 56634\n 38425\n 27930\n 42884\n \n\nNote that this example is a small one for checking the problem specification.\nIt does not satisfy the constraint D=365 and is never actually given as a test\ncase."}]
Let v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query. Print M integers v_i to Standard Output in the following format: v_1 v_2 \vdots v_M * * *
s656659792
Wrong Answer
p02620
Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries. D c_1 c_2 \cdots c_{26} s_{1,1} s_{1,2} \cdots s_{1,26} \vdots s_{D,1} s_{D,2} \cdots s_{D,26} t_1 t_2 \vdots t_D M d_1 q_1 d_2 q_2 \vdots d_M q_M * The constraints and generation methods for the input part are the same as those for Problem A. * For each d=1,\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\ldots,26}. * The number of queries M is an integer satisfying 1\leq M\leq 10^5. * For each i=1,\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\ldots,D}. * For each i=1,\ldots,26, q_i is an integer satisfying 1\leq q_i\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.
import sys sys.setrecursionlimit(300000) from collections import defaultdict def I(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split()) def LMI(): return list(map(int, sys.stdin.readline().split())) def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split())) MOD = 10**9 + 7 INF = float("inf") D = I() C = LMI() S = [LMI() for _ in range(D)] T = [I() - 1 for _ in range(D)] M = I() last = [[i + 1] * 26 for i in range(D)] for d in range(D): i = T[d] j = 0 for dd in range(d, D): # if last[dd][i] == 0: # continue # contrib += last[dd][i] - j last[dd][i] = j j += 1 def eval3(d, q): i = T[d] val = S[d][q] - S[d][i] contrib = 0 if d == 0: j = 1 else: j = last[d - 1][i] + 1 for dd in range(d, D): if dd > d and last[dd][i] == 0: continue contrib += j - last[dd][i] last[dd][i] = j j += 1 val -= contrib * C[i] contrib = 0 j = 0 for dd in range(d, D): if last[dd][q] == 0: continue contrib += last[dd][q] - j last[dd][q] = j j += 1 val += contrib * C[q] T[d] = q return val # def eval2(T): # last = defaultdict(int) # ans = 0 # for d in range(D): # ans += S[d][T[d]] # ans -= Csum * (d + 1) # # ans += passed * C[T[d]] # last[T[d]] = d + 1 # return ans # def score0(T): last = defaultdict(int) ans = 0 for d in range(D): ans += S[d][T[d]] last[T[d]] = d + 1 for i in range(26): ans -= C[i] * (d + 1 - last[i]) return ans score = score0(T) for d, q in [tuple(MI0()) for _ in range(M)]: val = eval3(d, q) score += val print(score)
Statement You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query. * * *
[{"input": "5\n 86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n 19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n 6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n 6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n 8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n 19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n 1\n 17\n 13\n 14\n 13\n 5\n 1 7\n 4 11\n 3 4\n 5 24\n 4 19", "output": "72882\n 56634\n 38425\n 27930\n 42884\n \n\nNote that this example is a small one for checking the problem specification.\nIt does not satisfy the constraint D=365 and is never actually given as a test\ncase."}]
Let v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query. Print M integers v_i to Standard Output in the following format: v_1 v_2 \vdots v_M * * *
s659139249
Runtime Error
p02620
Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries. D c_1 c_2 \cdots c_{26} s_{1,1} s_{1,2} \cdots s_{1,26} \vdots s_{D,1} s_{D,2} \cdots s_{D,26} t_1 t_2 \vdots t_D M d_1 q_1 d_2 q_2 \vdots d_M q_M * The constraints and generation methods for the input part are the same as those for Problem A. * For each d=1,\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\ldots,26}. * The number of queries M is an integer satisfying 1\leq M\leq 10^5. * For each i=1,\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\ldots,D}. * For each i=1,\ldots,26, q_i is an integer satisfying 1\leq q_i\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.
import copy D = int(input()) c = list(map(int, input().split())) s = [list(map(int, input().split())) for i in range(D)] t = [int(input()) for i in range(D)] M = int(input()) d = [list(map(int, input().split())) for i in range(M)] tmp = 0 last = [0] * (26) last_list = [0] * D tmp_list = [0] * (26) day = 0 v = [0] * (D + 1) # 満足度これだけi=日付他のはi-1=日付 v_num = [0] * (D + 1) for day in range(D): for i in range(26): # 今day+1日目 tmp_list[i] = v[day] + s[day][i] for j in range(26): if j != i: tmp_list[i] -= c[j] * (day + 1 - last[j]) v[day + 1] = max(tmp_list) last[tmp_list.index(max(tmp_list))] = day + 1 last_list[day] = copy.deepcopy(last) v_num[day + 1] = tmp_list.index(max(tmp_list)) + 1 # print(last_list) for k in range(M): tmp_v = copy.deepcopy(v) tmp_last_list = copy.deepcopy(last_list) tmp_v_num = copy.deepcopy(v_num) tmp_v_num[d[k][0]] = d[k][1] - 1 day = d[k][0] - 1 # 五日目なら4 last = copy.deepcopy(tmp_last_list[day]) for i in range(day, D): tmp_v[i + 1] = tmp_v[i] + s[i][tmp_v_num[i + 1]] for j in range(26): tmp_v[i + 1] -= c[j] * (i + 1 - last[j]) last[tmp_v_num[i + 1] - 1] = i + 1 last_list[day] = copy.deepcopy(last) if tmp_v[D] > v[D]: v = copy.deepcopy(tmp_v) v_num = copy.deepcopy(tmp_v_num) last_list = copy.deepcopy(tmp_last_list) for i in range(1, D + 1): # print(v_num[i]) print(v[i])
Statement You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query. * * *
[{"input": "5\n 86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n 19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n 6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n 6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n 8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n 19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n 1\n 17\n 13\n 14\n 13\n 5\n 1 7\n 4 11\n 3 4\n 5 24\n 4 19", "output": "72882\n 56634\n 38425\n 27930\n 42884\n \n\nNote that this example is a small one for checking the problem specification.\nIt does not satisfy the constraint D=365 and is never actually given as a test\ncase."}]
Let v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query. Print M integers v_i to Standard Output in the following format: v_1 v_2 \vdots v_M * * *
s299996195
Runtime Error
p02620
Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries. D c_1 c_2 \cdots c_{26} s_{1,1} s_{1,2} \cdots s_{1,26} \vdots s_{D,1} s_{D,2} \cdots s_{D,26} t_1 t_2 \vdots t_D M d_1 q_1 d_2 q_2 \vdots d_M q_M * The constraints and generation methods for the input part are the same as those for Problem A. * For each d=1,\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\ldots,26}. * The number of queries M is an integer satisfying 1\leq M\leq 10^5. * For each i=1,\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\ldots,D}. * For each i=1,\ldots,26, q_i is an integer satisfying 1\leq q_i\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.
import copy def main(): d = int(input()) cList = [int(x) for x in input().split()] sList = [] for idx in range(0, d): tempList = [int(x) for x in input().split()] sList.append(tempList) tList = [] for idx in range(0, d): tList.append(int(input())) m = int(input()) qList = [] for idx in range(0, m): tmpList = [int(x) for x in input().split()] qList.append(tmpList) val = calcVal(sList, tList, cList, d) for qidx in range(0, m): change_date = qList[qidx][0] temp_tlist = copy.deepcopy(tList) temp_tlist[change_date - 1] = qList[qidx][1] # 日付書き換え opp_val = val opp_val += sList[change_date - 1][qList[qidx][1]] opp_val -= sList[change_date - 1][tList[qList[qidx][0] - 1]] counter = 0 tmp_date = change_date - 1 + 1 while tmp_date < d and qList[qidx][1] != tList[tmp_date]: counter += 1 tmp_date += 1 opp_val += cList[qList[qidx][1]] * counter counter = 0 tmp_date = change_date - 1 + 1 while tmp_date < d and tList[qList[qidx][0] - 1] != tList[tmp_date]: counter += 1 tmp_date += 1 opp_val -= cList[tList[qList[qidx][0] - 1]] * counter temp_tlist[qList[qidx][0] - 1] = qList[qidx][1] # 日付書き換え val = calcVal(sList, temp_tlist, cList, d) # if (opposit_val > val): # val = opposit_val tList = temp_tlist print(val) def calcVal(sList, tList, cList, d): count_list = [0] * 26 val = 0 for idx in range(0, d): val += int(sList[idx][tList[idx] - 1]) count_list = list(map(lambda x: x + 1, count_list)) count_list[int(tList[idx]) - 1] = 0 for wkChar in range(0, 26): val -= int(count_list[wkChar]) * int(cList[wkChar]) return val if __name__ == "__main__": main()
Statement You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query. * * *
[{"input": "5\n 86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n 19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n 6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n 6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n 8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n 19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n 1\n 17\n 13\n 14\n 13\n 5\n 1 7\n 4 11\n 3 4\n 5 24\n 4 19", "output": "72882\n 56634\n 38425\n 27930\n 42884\n \n\nNote that this example is a small one for checking the problem specification.\nIt does not satisfy the constraint D=365 and is never actually given as a test\ncase."}]
Let v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query. Print M integers v_i to Standard Output in the following format: v_1 v_2 \vdots v_M * * *
s343958888
Wrong Answer
p02620
Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries. D c_1 c_2 \cdots c_{26} s_{1,1} s_{1,2} \cdots s_{1,26} \vdots s_{D,1} s_{D,2} \cdots s_{D,26} t_1 t_2 \vdots t_D M d_1 q_1 d_2 q_2 \vdots d_M q_M * The constraints and generation methods for the input part are the same as those for Problem A. * For each d=1,\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\ldots,26}. * The number of queries M is an integer satisfying 1\leq M\leq 10^5. * For each i=1,\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\ldots,D}. * For each i=1,\ldots,26, q_i is an integer satisfying 1\leq q_i\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.
# input D = int(input()) c_list = list(map(int, input().split())) s_grid = [] for i in range(D): array = list(map(int, input().strip().split(" "))) s_grid.append(array) t_list = [int(input()) - 1 for i in range(D)] # task_list M = int(input()) d_grid = [] for i in range(M): array = list(map(int, input().strip().split(" "))) d_grid.append(array) def calculate_score(t_list, score_list, last_grid, change_query_number): score_list = score_list[:change_query_number] last_grid = last_grid[:change_query_number] if len(score_list) > 1: score = score_list[-1] last_list = last_grid[-1] else: score = 0 last_list = [0 for i in range(26)] for d in range(change_query_number, D): score += s_grid[d][t_list[d]] last_list = [n + 1 for n in last_list] last_list[t_list[d]] = 0 for i in range(26): score -= c_list[i] * last_list[i] score_list.append(score) last_grid.append(last_list) return score_list, last_grid # first cal. previous_s, previous_l = calculate_score(t_list, [], [[0 for i in range(26)]], 0) for i in range(M): j = d_grid[i][0] - 1 t_list[j] = d_grid[i][1] - 1 score_list, last_grid = calculate_score(t_list, previous_s, previous_l, j) print(score_list[-1]) previous_s = score_list previous_l = last_grid
Statement You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query. * * *
[{"input": "5\n 86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n 19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n 6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n 6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n 8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n 19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n 1\n 17\n 13\n 14\n 13\n 5\n 1 7\n 4 11\n 3 4\n 5 24\n 4 19", "output": "72882\n 56634\n 38425\n 27930\n 42884\n \n\nNote that this example is a small one for checking the problem specification.\nIt does not satisfy the constraint D=365 and is never actually given as a test\ncase."}]
Let v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query. Print M integers v_i to Standard Output in the following format: v_1 v_2 \vdots v_M * * *
s712509863
Wrong Answer
p02620
Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries. D c_1 c_2 \cdots c_{26} s_{1,1} s_{1,2} \cdots s_{1,26} \vdots s_{D,1} s_{D,2} \cdots s_{D,26} t_1 t_2 \vdots t_D M d_1 q_1 d_2 q_2 \vdots d_M q_M * The constraints and generation methods for the input part are the same as those for Problem A. * For each d=1,\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\ldots,26}. * The number of queries M is an integer satisfying 1\leq M\leq 10^5. * For each i=1,\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\ldots,D}. * For each i=1,\ldots,26, q_i is an integer satisfying 1\leq q_i\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.
import time st = time.time() d = int(input()) clist = list(map(int, input().split())) last_c = [0] * 26 select_c = [0] * 26 for i in range(26): select_c[i] = [] slist = [0] * d for i in range(d): slist[i] = list(map(int, input().split())) tlist = [0] * d satisfy = [0] * (d + 1) # 貪欲法 for i in range(0, d): max = 0 max_n = 0 for n in range(26): if i > 0: curr = slist[i][n] + satisfy[i - 1] else: curr = slist[i][n] minus = 0 for j in range(26): if n != j: minus -= clist[j] * (i - last_c[j]) curr += minus if curr > max: max = curr max_n = n satisfy[i] = max last_c[max_n] = i + 1 select_c[max_n].append(i + 1) tlist[i] = max_n + 1 import random import numpy as np sum = 0 total_c = 0 for i in range(d): sum += slist[i][tlist[i] - 1] ct = time.time() for i in range(len(select_c)): start = 1 c_change = 0 if select_c[i] == []: c_change = np.sum(np.arange(d + 1)) else: for j in range(len(select_c[i])): end = select_c[i][j] if end > start: c_change += np.sum(np.arange(end - start + 1)) start = end end = d + 1 c_change += np.sum(np.arange(end - start)) start = end total_c += clist[i] * c_change current_max = sum - total_c try: import bisect while ct - st < 1.9: change_d = random.randint(1, d) change_d_to_c = random.randint(0, len(select_c) - 1) for x in range(len(select_c)): try: ind = select_c[x].index(change_d) change = x s_change = slist[change_d - 1][ind] select_c[x].remove(change_d) break except: None s_change2 = slist[change_d - 1][change_d_to_c] bisect.insort(select_c[change_d_to_c], change_d) # calc sum2 = sum - s_change + s_change2 total_c2 = 0 for i in range(len(select_c)): start = 1 c_change = 0 if select_c[i] == []: c_change = np.sum(np.arange(d + 1)) else: for j in range(len(select_c[i])): end = select_c[i][j] if end > start: c_change += np.sum(np.arange(end - start + 1)) start = end end = d + 1 c_change += np.sum(np.arange(end - start)) start = end total_c2 += clist[i] * c_change percent = random.random() if percent > 0.15 and sum - total_c < sum2 - total_c2: sum = sum2 total_c = total_c2 tlist[change_d - 1] = change_d_to_c + 1 else: bisect.insort(select_c[change], change_d) select_c[change_d_to_c].remove(change_d) ct = time.time() except: None # remove first for i in tlist: print(i)
Statement You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query. * * *
[{"input": "5\n 86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n 19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n 6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n 6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n 8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n 19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n 1\n 17\n 13\n 14\n 13\n 5\n 1 7\n 4 11\n 3 4\n 5 24\n 4 19", "output": "72882\n 56634\n 38425\n 27930\n 42884\n \n\nNote that this example is a small one for checking the problem specification.\nIt does not satisfy the constraint D=365 and is never actually given as a test\ncase."}]
Let v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query. Print M integers v_i to Standard Output in the following format: v_1 v_2 \vdots v_M * * *
s650090293
Wrong Answer
p02620
Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries. D c_1 c_2 \cdots c_{26} s_{1,1} s_{1,2} \cdots s_{1,26} \vdots s_{D,1} s_{D,2} \cdots s_{D,26} t_1 t_2 \vdots t_D M d_1 q_1 d_2 q_2 \vdots d_M q_M * The constraints and generation methods for the input part are the same as those for Problem A. * For each d=1,\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\ldots,26}. * The number of queries M is an integer satisfying 1\leq M\leq 10^5. * For each i=1,\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\ldots,D}. * For each i=1,\ldots,26, q_i is an integer satisfying 1\leq q_i\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.
from time import time start = time() from copy import deepcopy from random import randint d = int(input()) c = list(map(int, input().split())) # scoreを減らす s = [] # scoreを増やす for i in range(d): t = list(map(int, input().split())) s.append(t) last = [0] * 26 # それぞれのコンテストが最後に行われたのは何日目か ans_lst = [] for i in range(1, d): # 364日、1日目ならi=1 temp_best = -100000000 for j in range(26): # それぞれの日において、26個のコンテストを順番にピックアップ temp = s[i - 1][j] for k in range(26): # ピックアップされていないコンテストは、スコアを減らす if j != k: temp -= c[k] * (i - last[k]) temp_last = deepcopy(last) temp_last[j] = i for k in range(26): temp += s[i][k] for l in range(26): if k != l: temp -= c[l] * (i + 1 - temp_last[l]) if temp > temp_best: temp_best = temp rem = j ans_lst.append(rem) last[rem] = i temp_best = -100000000 # 365日目は、次の日のことは考えなくてよい for j in range(26): # 26個のコンテストを順番にピックアップ temp = s[i - 1][j] for k in range(26): # ピックアップされていないコンテストは、スコアを減らす if j != k: temp -= c[k] * (i - last[k]) if temp > temp_best: temp_best = temp rem = j ans_lst.append(rem) # AtCoder運営お疲れ様です score = 0 las = [0] * 26 for i in range(d): for j in range(26): las[j] += 1 score += s[i][ans_lst[i]] las[ans_lst[i]] = 0 for j in range(26): score -= c[j] * las[j] for q in range(1, 25): for p in range(d - q): las = [0] * 26 temp_score = 0 temp_ans_lst = deepcopy(ans_lst) temp_ans_lst[p], temp_ans_lst[p + q] = temp_ans_lst[p + q], temp_ans_lst[p] for i in range(d): for j in range(26): las[j] += 1 temp_score += s[i][temp_ans_lst[i]] las[temp_ans_lst[i]] = 0 for j in range(26): temp_score -= c[j] * las[j] if temp_score > score: score = temp_score ans_lst = temp_ans_lst while time() - start < 1.9: las = [0] * 26 temp_score = 0 temp_ans_lst = deepcopy(ans_lst) a = randint(0, d - 2) b = randint(0, d - 2) temp_ans_lst[a], temp_ans_lst[a + 1] = temp_ans_lst[a + 1], temp_ans_lst[a] temp_ans_lst[b], temp_ans_lst[b + 1] = temp_ans_lst[b + 1], temp_ans_lst[b] for i in range(d): for j in range(26): las[j] += 1 temp_score += s[i][temp_ans_lst[i]] las[temp_ans_lst[i]] = 0 for j in range(26): temp_score -= c[j] * las[j] if temp_score > score: score = temp_score ans_lst = temp_ans_lst for i in ans_lst: print(i + 1)
Statement You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query. * * *
[{"input": "5\n 86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n 19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n 6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n 6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n 8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n 19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n 1\n 17\n 13\n 14\n 13\n 5\n 1 7\n 4 11\n 3 4\n 5 24\n 4 19", "output": "72882\n 56634\n 38425\n 27930\n 42884\n \n\nNote that this example is a small one for checking the problem specification.\nIt does not satisfy the constraint D=365 and is never actually given as a test\ncase."}]
Let v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query. Print M integers v_i to Standard Output in the following format: v_1 v_2 \vdots v_M * * *
s256342410
Accepted
p02620
Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries. D c_1 c_2 \cdots c_{26} s_{1,1} s_{1,2} \cdots s_{1,26} \vdots s_{D,1} s_{D,2} \cdots s_{D,26} t_1 t_2 \vdots t_D M d_1 q_1 d_2 q_2 \vdots d_M q_M * The constraints and generation methods for the input part are the same as those for Problem A. * For each d=1,\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\ldots,26}. * The number of queries M is an integer satisfying 1\leq M\leq 10^5. * For each i=1,\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\ldots,D}. * For each i=1,\ldots,26, q_i is an integer satisfying 1\leq q_i\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.
import sys input = sys.stdin.readline D = int(input()) C = list(map(int, input().split())) S = [list(map(int, input().split())) for i in range(D)] T = [int(input()) for i in range(D)] M = int(input()) DQ = [tuple(map(int, input().split())) for i in range(M)] score = 0 lasts = [[0] for i in range(26)] for i, (s, a) in enumerate(zip(S, T)): score += s[a - 1] lasts[a - 1].append(i + 1) for j in range(26): lasts[j].append(D + 1) for j, (c, ls) in enumerate(zip(C, lasts)): for a, b in zip(ls, ls[1:]): score -= c * (b - a) * (b - a - 1) // 2 from bisect import bisect for d, q in DQ: p = T[d - 1] T[d - 1] = q score += S[d - 1][q - 1] - S[d - 1][p - 1] for a, b in zip(lasts[p - 1], lasts[p - 1][1:]): score += C[p - 1] * (b - a) * (b - a - 1) // 2 for a, b in zip(lasts[q - 1], lasts[q - 1][1:]): score += C[q - 1] * (b - a) * (b - a - 1) // 2 i = lasts[p - 1].index(d) del lasts[p - 1][i] i = bisect(lasts[q - 1], d) lasts[q - 1].insert(i, d) for a, b in zip(lasts[p - 1], lasts[p - 1][1:]): score -= C[p - 1] * (b - a) * (b - a - 1) // 2 for a, b in zip(lasts[q - 1], lasts[q - 1][1:]): score -= C[q - 1] * (b - a) * (b - a - 1) // 2 print(score)
Statement You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query. * * *
[{"input": "5\n 86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n 19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n 6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n 6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n 8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n 19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n 1\n 17\n 13\n 14\n 13\n 5\n 1 7\n 4 11\n 3 4\n 5 24\n 4 19", "output": "72882\n 56634\n 38425\n 27930\n 42884\n \n\nNote that this example is a small one for checking the problem specification.\nIt does not satisfy the constraint D=365 and is never actually given as a test\ncase."}]
Let v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query. Print M integers v_i to Standard Output in the following format: v_1 v_2 \vdots v_M * * *
s495412735
Runtime Error
p02620
Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries. D c_1 c_2 \cdots c_{26} s_{1,1} s_{1,2} \cdots s_{1,26} \vdots s_{D,1} s_{D,2} \cdots s_{D,26} t_1 t_2 \vdots t_D M d_1 q_1 d_2 q_2 \vdots d_M q_M * The constraints and generation methods for the input part are the same as those for Problem A. * For each d=1,\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\ldots,26}. * The number of queries M is an integer satisfying 1\leq M\leq 10^5. * For each i=1,\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\ldots,D}. * For each i=1,\ldots,26, q_i is an integer satisfying 1\leq q_i\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.
D = int(input()) c_list = [int(i) for i in input().split()] s_list = [] t_list = [] for _ in range(D): s = [int(i) for i in input().split()] s_list.append(s) for _ in range(D): t_list.append(int(input())) happy = 0 recent = [0 for _ in range(26)] for i in range(D): happy += s_list[i][t_list[i] - 1] recent[t_list[i] - 1] = i + 1 for j, s in enumerate(s_list[i]): happy -= c_list[j] * (i + 1 - recent[j]) M = int(input()) for i in range(M): d, q = map(int, input().split()) d -= 1 happy += s_list[d][q - 1] - s_list[d][t_list[d] - 1] for dd in range(d, D if recent[q - 1] <= d else recent[q - 1]): happy += c_list[q - 1] - c_list[d - 1] print(happy)
Statement You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query. * * *
[{"input": "5\n 86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n 19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n 6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n 6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n 8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n 19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n 1\n 17\n 13\n 14\n 13\n 5\n 1 7\n 4 11\n 3 4\n 5 24\n 4 19", "output": "72882\n 56634\n 38425\n 27930\n 42884\n \n\nNote that this example is a small one for checking the problem specification.\nIt does not satisfy the constraint D=365 and is never actually given as a test\ncase."}]
Let v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query. Print M integers v_i to Standard Output in the following format: v_1 v_2 \vdots v_M * * *
s390525447
Runtime Error
p02620
Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries. D c_1 c_2 \cdots c_{26} s_{1,1} s_{1,2} \cdots s_{1,26} \vdots s_{D,1} s_{D,2} \cdots s_{D,26} t_1 t_2 \vdots t_D M d_1 q_1 d_2 q_2 \vdots d_M q_M * The constraints and generation methods for the input part are the same as those for Problem A. * For each d=1,\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\ldots,26}. * The number of queries M is an integer satisfying 1\leq M\leq 10^5. * For each i=1,\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\ldots,D}. * For each i=1,\ldots,26, q_i is an integer satisfying 1\leq q_i\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.
def P(s): R,P,*L=[0]*28 for i in range(365):t=I[i+365][0]-1;P+=s-(i+1-L[t])*C[t];R+=I[i][t]-P;L[t]=i+1 return R _,C,*I=[[*map(int,t.split())]for t in open(0)] for d,q in I[701:]:I[d+364][0]=q;print(P(sum(C)))
Statement You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query. * * *
[{"input": "5\n 86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n 19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n 6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n 6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n 8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n 19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n 1\n 17\n 13\n 14\n 13\n 5\n 1 7\n 4 11\n 3 4\n 5 24\n 4 19", "output": "72882\n 56634\n 38425\n 27930\n 42884\n \n\nNote that this example is a small one for checking the problem specification.\nIt does not satisfy the constraint D=365 and is never actually given as a test\ncase."}]
Let v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query. Print M integers v_i to Standard Output in the following format: v_1 v_2 \vdots v_M * * *
s874081580
Wrong Answer
p02620
Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries. D c_1 c_2 \cdots c_{26} s_{1,1} s_{1,2} \cdots s_{1,26} \vdots s_{D,1} s_{D,2} \cdots s_{D,26} t_1 t_2 \vdots t_D M d_1 q_1 d_2 q_2 \vdots d_M q_M * The constraints and generation methods for the input part are the same as those for Problem A. * For each d=1,\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\ldots,26}. * The number of queries M is an integer satisfying 1\leq M\leq 10^5. * For each i=1,\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\ldots,D}. * For each i=1,\ldots,26, q_i is an integer satisfying 1\leq q_i\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.
t = [ 16, 8, 17, 7, 8, 21, 13, 5, 1, 25, 12, 14, 12, 6, 4, 24, 6, 9, 18, 3, 22, 19, 3, 24, 7, 7, 2, 23, 11, 6, 14, 17, 4, 21, 24, 23, 6, 14, 6, 15, 26, 22, 19, 18, 20, 11, 10, 16, 18, 5, 16, 7, 7, 24, 18, 16, 14, 18, 22, 25, 19, 20, 13, 23, 3, 25, 19, 25, 25, 3, 17, 16, 5, 22, 9, 11, 5, 6, 6, 13, 26, 14, 9, 13, 11, 11, 1, 19, 22, 23, 19, 18, 5, 14, 26, 11, 25, 3, 24, 6, 24, 20, 12, 19, 7, 25, 16, 19, 6, 1, 4, 16, 15, 15, 5, 6, 24, 26, 2, 3, 15, 5, 10, 21, 22, 16, 22, 1, 2, 15, 25, 7, 16, 15, 5, 25, 12, 6, 16, 2, 14, 16, 12, 10, 22, 18, 22, 9, 16, 25, 1, 13, 25, 5, 8, 23, 17, 14, 17, 18, 17, 16, 13, 24, 21, 10, 10, 12, 15, 15, 22, 1, 15, 23, 21, 24, 23, 8, 13, 19, 14, 3, 2, 24, 3, 15, 11, 19, 6, 26, 11, 22, 1, 20, 24, 4, 11, 14, 12, 25, 10, 25, 8, 6, 9, 24, 10, 19, 23, 14, 11, 11, 21, 6, 14, 21, 24, 24, 26, 18, 26, 2, 13, 14, 13, 7, 17, 15, 15, 11, 5, 20, 12, 25, 8, 14, 11, 15, 1, 21, 7, 26, 17, 18, 3, 4, 4, 9, 21, 20, 5, 9, 15, 10, 23, 1, 25, 25, 26, 16, 22, 19, 3, 13, 16, 19, 1, 10, 12, 6, 22, 7, 21, 2, 6, 1, 1, 15, 22, 12, 26, 25, 12, 14, 20, 18, 11, 4, 3, 16, 23, 19, 18, 20, 5, 19, 10, 23, 8, 4, 9, 26, 3, 15, 2, 26, 3, 14, 6, 23, 12, 17, 9, 10, 20, 22, 4, 23, 22, 24, 8, 18, 3, 2, 12, 4, 22, 7, 25, 12, 23, 7, 2, 21, 19, 2, 13, 2, 15, 18, 24, 20, 12, 8, 3, 19, 13, 16, 24, 15, 8, 7, 13, 7, 14, 11, 5, 21, 6, 4, 24, 15, 20, 15, 7, ] for i in range(365): print(t[i])
Statement You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query. * * *
[{"input": "5\n 86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n 19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n 6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n 6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n 8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n 19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n 1\n 17\n 13\n 14\n 13\n 5\n 1 7\n 4 11\n 3 4\n 5 24\n 4 19", "output": "72882\n 56634\n 38425\n 27930\n 42884\n \n\nNote that this example is a small one for checking the problem specification.\nIt does not satisfy the constraint D=365 and is never actually given as a test\ncase."}]
Let v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query. Print M integers v_i to Standard Output in the following format: v_1 v_2 \vdots v_M * * *
s757708007
Wrong Answer
p02620
Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries. D c_1 c_2 \cdots c_{26} s_{1,1} s_{1,2} \cdots s_{1,26} \vdots s_{D,1} s_{D,2} \cdots s_{D,26} t_1 t_2 \vdots t_D M d_1 q_1 d_2 q_2 \vdots d_M q_M * The constraints and generation methods for the input part are the same as those for Problem A. * For each d=1,\ldots,D, t_d is an integer generated independently and uniformly at random from {1,2,\ldots,26}. * The number of queries M is an integer satisfying 1\leq M\leq 10^5. * For each i=1,\ldots,M, d_i is an integer generated independently and uniformly at random from {1,2,\ldots,D}. * For each i=1,\ldots,26, q_i is an integer satisfying 1\leq q_i\leq 26 generated uniformly at random from the 25 values that differ from the type of contest on day d_i.
Statement You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query. * * *
[{"input": "5\n 86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n 19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n 6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n 6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n 8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n 19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n 1\n 17\n 13\n 14\n 13\n 5\n 1 7\n 4 11\n 3 4\n 5 24\n 4 19", "output": "72882\n 56634\n 38425\n 27930\n 42884\n \n\nNote that this example is a small one for checking the problem specification.\nIt does not satisfy the constraint D=365 and is never actually given as a test\ncase."}]
If no graph satisfies the condition, print `Impossible`. If there exists a graph that satisfies the condition, print `Possible` in the first line. Then, in the subsequent lines, print the constructed graph in the following format: N M u_1 v_1 c_1 u_2 v_2 c_2 : u_M v_M c_M S T Here, M is the number of the edges, and u_i, v_i, c_i represent edges as follows: there is an edge from Vertex u_i to Vertex v_i whose weight or label is c_i. Also refer to Sample Outputs. * * *
s160216393
Wrong Answer
p03461
Input is given from Standard Input in the following format: A B d_{1,1} d_{1,2} .. d_{1,B} d_{2,1} d_{2,2} .. d_{2,B} : d_{A,1} d_{A,2} .. d_{A,B}
a, b = map(int, input().split()) distances = [list(map(int, input().split())) for _ in range(a)] g = [[] for _ in range(201)] m = 0 for i in range(100): g[i].append((i + 1, "X")) m += 1 for i in range(100): g[i + 100].append((i + 101, "Y")) m += 1 for p in range(0, 101): for q in range(0, 101): r = -10000000 for i in range(a): for j in range(b): r = max(r, distances[i][j] - p * (i + 1) - q * (j + 1)) if r >= 0: g[p].append((200 - q, r)) m += 1 for i in range(a): for j in range(b): d = [float("inf")] * 201 d[0] = 0 s = [0] while s: p = s.pop() for to, dist in g[p]: if dist == "X": dist = i + 1 elif dist == "Y": dist = j + 1 s.append(to) d[to] = min(d[to], d[p] + dist) if d[-1] != distances[i][j]: print("Impossible") exit(0) print(201, m) for i in range(201): for node, dist in g[i]: print(i + 1, node + 1, dist) print(1, 201)
Statement AtCoDeer the deer wants a directed graph that satisfies the following conditions: * The number of vertices, N, is at most 300. * There must not be self-loops or multiple edges. * The vertices are numbered from 1 through N. * Each edge has either an integer weight between 0 and 100 (inclusive), or a label `X` or `Y`. * For every pair of two integers (x,y) such that 1 ≤ x ≤ A, 1 ≤ y ≤ B, the shortest distance from Vertex S to Vertex T in the graph where the edges labeled `X` have the weight x and the edges labeled `Y` have the weight y, is d_{x,y}. Construct such a graph (and a pair of S and T) for him, or report that it does not exist. Refer to Output section for output format.
[{"input": "2 3\n 1 2 2\n 1 2 3", "output": "Possible\n 3 4\n 1 2 X\n 2 3 1\n 3 2 Y\n 1 3 Y\n 1 3\n \n\n* * *"}, {"input": "1 3\n 100 50 1", "output": "Impossible"}]
Print the number of combinations of "on" and "off" states of the switches that light all the bulbs. * * *
s344879170
Accepted
p03031
Input is given from Standard Input in the following format: N M k_1 s_{11} s_{12} ... s_{1k_1} : k_M s_{M1} s_{M2} ... s_{Mk_M} p_1 p_2 ... p_M
def so(l, n, ar): if n < l: so(l, n + 1, ar + [True]) so(l, n + 1, ar + [False]) elif n == l: global switchOnOff switchOnOff.append(ar) switchOnOff = [] n, m = [int(i) for i in input().split()] denkyus = [] for i in range(m): a = [int(j) for j in input().split()] denkyus.append(a[1:]) hikaku = [int(i) for i in input().split()] so(n, 0, []) ret = 0 denkyuCnt = [0] * m for ss in switchOnOff: denkyuCnt = [0] * m for si, s in enumerate(ss): for ji, j in enumerate(denkyus): if s and (si + 1) in j: denkyuCnt[ji] += 1 subcnt = 0 for i, d in enumerate(denkyuCnt): if d % 2 == hikaku[i]: subcnt += 1 if subcnt == m: ret += 1 print(ret)
Statement We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M. Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2. How many combinations of "on" and "off" states of the switches light all the bulbs?
[{"input": "2 2\n 2 1 2\n 1 2\n 0 1", "output": "1\n \n\n * Bulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n * Bulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on,\non), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all\nthe bulbs, so we should print 1.\n\n* * *"}, {"input": "2 3\n 2 1 2\n 1 1\n 1 2\n 0 0 1", "output": "0\n \n\n * Bulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n * Bulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n * Bulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light\nBulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations\nof states of the switches that light all the bulbs, so we should print 0.\n\n* * *"}, {"input": "5 2\n 3 1 2 5\n 2 2 3\n 1 0", "output": "8"}]
Print the number of combinations of "on" and "off" states of the switches that light all the bulbs. * * *
s670908234
Wrong Answer
p03031
Input is given from Standard Input in the following format: N M k_1 s_{11} s_{12} ... s_{1k_1} : k_M s_{M1} s_{M2} ... s_{Mk_M} p_1 p_2 ... p_M
import copy class Lamp: def __init__(self, id, connected_switches): self.id = id self.on_number = 0 self.connected_switches = connected_switches self.connected_number = len(connected_switches) def set_on_number(self, on_number): self.on_number = on_number inp = input() st = inp.split() n = int(st[0]) m = int(st[1]) lamp_dictionary = {} lamp_list = [] for i in range(m): inp = input() st = inp.split() k = int(st[0]) connected_switches = [] for j in range(k): s = int(st[j + 1]) connected_switches.append(s) lamp_list.append(Lamp(i + 1, connected_switches)) # input p inp = input() st = inp.split() for i in range(m): p = int(st[i]) lamp_c = lamp_list[i] lamp_c.set_on_number(p) k = lamp_c.connected_number if k in lamp_dictionary: lamps = lamp_dictionary[k] lamps.append(lamp_c) else: lamp_dictionary[k] = [lamp_c] lamp_sorted_list = sorted(lamp_dictionary.keys()) # つながっているスイッチの少ない順 lamps_list = [] # 小さい順に並べたlampのりすと for connected_number in lamp_sorted_list: lamps = lamp_dictionary[connected_number] for lamp in lamps: lamps_list.append(lamp) # スウイッチを決定していく switch_list = [0 for _ in range(n + 1)] # 0:not decided 1:on 2:off def decide_switch(i): # 可能な数を返す if i == len(lamps_list): return 1 lamp = lamps_list[i] able_decide_switches = [] on_count = 0 for switch in lamp.connected_switches: if switch_list[switch] == 0: able_decide_switches.append(switch) elif switch_list[switch] == 1: on_count += 1 # 少なくとも可能なスイッチのパターが一つあれば次のランプを調べる p = lamp.on_number if not able_decide_switches: if on_count % 2 == p: return decide_switch(i + 1) else: return 0 else: # スイッチを変えられる.変えられる可能性すべてを調べる changing_list = make_list([], 1, len(able_decide_switches)) total_able_change_count = 0 if not changing_list: print("") for chang in changing_list: count = on_count for num in chang: count += num if count % 2 == p: # 次のランプを調べる for inde, num in enumerate(chang): v = num if num == 0: v = 2 switch_list[able_decide_switches[inde]] = v total_able_change_count += decide_switch(i + 1) # すいっちを0にもどす for inde, num in enumerate(chang): switch_list[able_decide_switches[inde]] = 0 return total_able_change_count def make_list(l, i, max_n): ol = copy.deepcopy(l) il = copy.deepcopy(l) ol.append(0) il.append(1) if i == max_n: return [ol, il] ooo = make_list(ol, i + 1, max_n) iii = make_list(il, i + 1, max_n) for ii in iii: ooo.append(ii) return ooo # return make_list(ol, i+1, max_n).extend(make_list(il, i+1, max_n)) ans = decide_switch(0) print(int(ans / 2))
Statement We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M. Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2. How many combinations of "on" and "off" states of the switches light all the bulbs?
[{"input": "2 2\n 2 1 2\n 1 2\n 0 1", "output": "1\n \n\n * Bulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n * Bulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on,\non), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all\nthe bulbs, so we should print 1.\n\n* * *"}, {"input": "2 3\n 2 1 2\n 1 1\n 1 2\n 0 0 1", "output": "0\n \n\n * Bulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n * Bulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n * Bulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light\nBulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations\nof states of the switches that light all the bulbs, so we should print 0.\n\n* * *"}, {"input": "5 2\n 3 1 2 5\n 2 2 3\n 1 0", "output": "8"}]
Print the number of combinations of "on" and "off" states of the switches that light all the bulbs. * * *
s034210102
Wrong Answer
p03031
Input is given from Standard Input in the following format: N M k_1 s_{11} s_{12} ... s_{1k_1} : k_M s_{M1} s_{M2} ... s_{Mk_M} p_1 p_2 ... p_M
n, m = map(int, input().split()) ls = [] for _ in range(m): tmp = list(map(int, input().split()))[1:] lls = [] for i in range(1, n + 1): lls += [int(i in tmp)] ls += [lls] p = list(map(int, input().split())) count = 0 yyy = [0] * n while True: if yyy[-1] == 2: break for mi in range(m): dd = 0 for ni in range(n): c = 0 c += ls[mi][ni] * yyy[ni] d = c % 2 dd += 1 - int(d == p[mi]) if dd == 0: count += 1 yyy[0] += 1 for j in range(0, n - 1): if yyy[j] == 2: yyy[j] = 0 yyy[j + 1] += 1 print(count)
Statement We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M. Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2. How many combinations of "on" and "off" states of the switches light all the bulbs?
[{"input": "2 2\n 2 1 2\n 1 2\n 0 1", "output": "1\n \n\n * Bulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n * Bulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on,\non), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all\nthe bulbs, so we should print 1.\n\n* * *"}, {"input": "2 3\n 2 1 2\n 1 1\n 1 2\n 0 0 1", "output": "0\n \n\n * Bulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n * Bulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n * Bulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light\nBulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations\nof states of the switches that light all the bulbs, so we should print 0.\n\n* * *"}, {"input": "5 2\n 3 1 2 5\n 2 2 3\n 1 0", "output": "8"}]
Print the number of combinations of "on" and "off" states of the switches that light all the bulbs. * * *
s645714120
Accepted
p03031
Input is given from Standard Input in the following format: N M k_1 s_{11} s_{12} ... s_{1k_1} : k_M s_{M1} s_{M2} ... s_{Mk_M} p_1 p_2 ... p_M
count = input().split() switch = int(count[0]) bulb = int(count[1]) condition = [] for i in range(bulb): condition.append(input().split()[1:]) # 全ての可能なスイッチの組み合わせ candidate = [] for j in range(2**switch): num = str(bin(j))[2:] if len(num) < (switch): num = "0" * (switch - len(num)) + num candidate.append(num) wanted = input().split() bad_count = 0 # 条件に合わないものから消していく for i in range(len(candidate)): judge = 0 for j in range(len(condition)): tasumono = [int(k) - 1 for k in condition[j]] sum_switch = 0 for l in tasumono: sum_switch += int(candidate[i][l]) if sum_switch % 2 != int(wanted[j]): judge += 1 if judge != 0: bad_count += 1 print(2**switch - bad_count)
Statement We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M. Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2. How many combinations of "on" and "off" states of the switches light all the bulbs?
[{"input": "2 2\n 2 1 2\n 1 2\n 0 1", "output": "1\n \n\n * Bulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n * Bulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on,\non), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all\nthe bulbs, so we should print 1.\n\n* * *"}, {"input": "2 3\n 2 1 2\n 1 1\n 1 2\n 0 0 1", "output": "0\n \n\n * Bulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n * Bulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n * Bulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light\nBulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations\nof states of the switches that light all the bulbs, so we should print 0.\n\n* * *"}, {"input": "5 2\n 3 1 2 5\n 2 2 3\n 1 0", "output": "8"}]
Print the number of combinations of "on" and "off" states of the switches that light all the bulbs. * * *
s925473390
Wrong Answer
p03031
Input is given from Standard Input in the following format: N M k_1 s_{11} s_{12} ... s_{1k_1} : k_M s_{M1} s_{M2} ... s_{Mk_M} p_1 p_2 ... p_M
N, M = [int(i) for i in input().split()] list = [] list1 = [] list3 = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(M): list += [int(i) for i in input().split()] list1 += [list] list = [] # print(list1) list2 = [int(i) for i in input().split()] # print(list2) for i in range(M): for j in range(list1[i][0]): n = list1[i][j + 1] # print(i,j,n) if list3[n] == -1: list3[n] = list2[i] if list3[n] == -2: continue if list3[n] != list2[i]: list3[n] = -2 # print(list1,list2,list3) print(2 ** (list3.count(0) + list3.count(1)))
Statement We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M. Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2. How many combinations of "on" and "off" states of the switches light all the bulbs?
[{"input": "2 2\n 2 1 2\n 1 2\n 0 1", "output": "1\n \n\n * Bulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n * Bulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on,\non), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all\nthe bulbs, so we should print 1.\n\n* * *"}, {"input": "2 3\n 2 1 2\n 1 1\n 1 2\n 0 0 1", "output": "0\n \n\n * Bulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n * Bulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n * Bulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light\nBulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations\nof states of the switches that light all the bulbs, so we should print 0.\n\n* * *"}, {"input": "5 2\n 3 1 2 5\n 2 2 3\n 1 0", "output": "8"}]
Print the number of combinations of "on" and "off" states of the switches that light all the bulbs. * * *
s807420926
Accepted
p03031
Input is given from Standard Input in the following format: N M k_1 s_{11} s_{12} ... s_{1k_1} : k_M s_{M1} s_{M2} ... s_{Mk_M} p_1 p_2 ... p_M
list = input().split(" ") n = int(list[0]) m = int(list[1]) denkyu = [] for i in range(m): info = input().split(" ") for j in range(len(info)): info[j] = int(info[j]) list = [] for i in range(n): list.append(0) # print(info) for j in range(len(info) - 1): list[info[j + 1] - 1] = 1 denkyu.append(list) # print(denkyu) shogo = [] for x in range(2**n): shinsu = [] for y in range(n): if x % 2 == 1: shinsu.append(1) x = int((x - 1) / 2) else: shinsu.append(0) x = int((x) / 2) shogo.append(shinsu) # print(shogo) plist = input().split(" ") for j in range(len(plist)): plist[j] = int(plist[j]) # print(plist) # print("") kosu = 0 for s in shogo: switch = 1 now = 0 complete = 0 while switch == 1: match = 0 for i in range(n): if s[i] == denkyu[now][i] and s[i] == 1: # print("X", s[i], denkyu[now][i], s, denkyu[now]) match += 1 if match % 2 == plist[now]: now += 1 else: switch = 0 if now == (m): if switch == 1: complete = 1 switch = 0 # print(s) if complete == 1: kosu += 1 # print("y", s) print(kosu)
Statement We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M. Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2. How many combinations of "on" and "off" states of the switches light all the bulbs?
[{"input": "2 2\n 2 1 2\n 1 2\n 0 1", "output": "1\n \n\n * Bulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n * Bulb 2 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nThere are four possible combinations of states of (Switch 1, Switch 2): (on,\non), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all\nthe bulbs, so we should print 1.\n\n* * *"}, {"input": "2 3\n 2 1 2\n 1 1\n 1 2\n 0 0 1", "output": "0\n \n\n * Bulb 1 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1 and 2.\n * Bulb 2 is lighted when there is an even number of switches that are \"on\" among the following: Switch 1.\n * Bulb 3 is lighted when there is an odd number of switches that are \"on\" among the following: Switch 2.\n\nSwitch 1 has to be \"off\" to light Bulb 2 and Switch 2 has to be \"on\" to light\nBulb 3, but then Bulb 1 will not be lighted. Thus, there are no combinations\nof states of the switches that light all the bulbs, so we should print 0.\n\n* * *"}, {"input": "5 2\n 3 1 2 5\n 2 2 3\n 1 0", "output": "8"}]
If the objective is achievable, print `YES`; if it is unachievable, print `NO`. * * *
s420886835
Accepted
p03524
Input is given from Standard Input in the following format: S
s = input().count print("YNEOS"[sum(abs(s(x) - s(y)) < 2 for x, y in ["ab", "bc", "ca"]) < 3 :: 2])
Statement Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.
[{"input": "abac", "output": "YES\n \n\nAs it stands now, S contains a palindrome `aba`, but we can permute the\ncharacters to get `acba`, for example, that does not contain a palindrome of\nlength 2 or more.\n\n* * *"}, {"input": "aba", "output": "NO\n \n\n* * *"}, {"input": "babacccabab", "output": "YES"}]
If the objective is achievable, print `YES`; if it is unachievable, print `NO`. * * *
s741198940
Wrong Answer
p03524
Input is given from Standard Input in the following format: S
s = input() dic = {} for i in range(len(s)): if s[i] in dic: dic[s[i]] += 1 else: dic[s[i]] = 1 if len(dic) == 1: if len(s) == 1: print("YES") else: print("NO") elif len(dic) == 2: print("NO") else: first = "a" second = "b" for k, v in dic.items(): if v > dic[first]: if k != first: second = first first = k elif v > dic[second]: if k != second and k != first: second = k tmp = first + second dic[first] -= 1 dic[second] -= 1 ans = "YES" for i in range(1, len(s) - 1): if tmp[i - 1] == "a": if tmp[i] == "b": if dic["c"] == 0: ans = "NO" break else: dic["c"] -= 1 tmp += "c" if tmp[i] == "c": if dic["b"] == 0: ans = "NO" break else: dic["b"] -= 1 tmp += "b" elif tmp[i - 1] == "b": if tmp[i] == "a": if dic["c"] == 0: ans = "NO" break else: dic["c"] -= 1 tmp += "c" if tmp[i] == "c": if dic["a"] == 0: ans = "NO" break else: dic["a"] -= 1 tmp += "a" elif tmp[i - 1] == "c": if tmp[i] == "a": if dic["b"] == 0: ans = "NO" break else: dic["b"] -= 1 tmp += "b" if tmp[i] == "b": if dic["a"] == 0: ans = "NO" break else: dic["a"] -= 1 tmp += "a" print(ans)
Statement Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.
[{"input": "abac", "output": "YES\n \n\nAs it stands now, S contains a palindrome `aba`, but we can permute the\ncharacters to get `acba`, for example, that does not contain a palindrome of\nlength 2 or more.\n\n* * *"}, {"input": "aba", "output": "NO\n \n\n* * *"}, {"input": "babacccabab", "output": "YES"}]
If the objective is achievable, print `YES`; if it is unachievable, print `NO`. * * *
s659796676
Accepted
p03524
Input is given from Standard Input in the following format: S
# -*- coding: utf-8 -*- """ B - Palindrome-phobia https://atcoder.jp/contests/cf17-final/tasks/cf17_final_b """ import sys from collections import Counter def solve(S): cnt = Counter(S) res = sorted([[v, k] for k, v in cnt.items()], reverse=True) ch = res[0][1] prev = None cnt[ch] -= 1 if cnt[ch] == 0: del cnt[ch] d = {"ab": "c", "ac": "b", "ba": "c", "bc": "a", "ca": "b", "cb": "a"} while cnt: if prev is None: if len(res) < 2: return "NO" else: prev = ch ch = res[1][1] cnt[ch] -= 1 if cnt[ch] == 0: del cnt[ch] else: n_ch = d[prev + ch] if cnt[n_ch] > 0: prev, ch = ch, n_ch cnt[n_ch] -= 1 if cnt[n_ch] == 0: del cnt[n_ch] else: return "NO" return "YES" def main(args): S = input() ans = solve(S) print(ans) if __name__ == "__main__": main(sys.argv[1:])
Statement Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.
[{"input": "abac", "output": "YES\n \n\nAs it stands now, S contains a palindrome `aba`, but we can permute the\ncharacters to get `acba`, for example, that does not contain a palindrome of\nlength 2 or more.\n\n* * *"}, {"input": "aba", "output": "NO\n \n\n* * *"}, {"input": "babacccabab", "output": "YES"}]
If the objective is achievable, print `YES`; if it is unachievable, print `NO`. * * *
s654789229
Accepted
p03524
Input is given from Standard Input in the following format: S
print("YNEOS"[max(L := list(map(input().count, "abc"))) > -~min(L) :: 2])
Statement Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.
[{"input": "abac", "output": "YES\n \n\nAs it stands now, S contains a palindrome `aba`, but we can permute the\ncharacters to get `acba`, for example, that does not contain a palindrome of\nlength 2 or more.\n\n* * *"}, {"input": "aba", "output": "NO\n \n\n* * *"}, {"input": "babacccabab", "output": "YES"}]
If the objective is achievable, print `YES`; if it is unachievable, print `NO`. * * *
s567146678
Runtime Error
p03524
Input is given from Standard Input in the following format: S
s=input() t = set(s) if len(s) ==1: print("YES") exit(0) elif len(s) == 1 && len(t) ==2: print("YES") exit(0) if len(t) != 3: print("NO") else: a = s.count("a") b = s.count("b") c = s.count("c") M = max(a,b,c) m = min(a,b,c) if M - m >1 : print("NO") else: print("YES")
Statement Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.
[{"input": "abac", "output": "YES\n \n\nAs it stands now, S contains a palindrome `aba`, but we can permute the\ncharacters to get `acba`, for example, that does not contain a palindrome of\nlength 2 or more.\n\n* * *"}, {"input": "aba", "output": "NO\n \n\n* * *"}, {"input": "babacccabab", "output": "YES"}]
If the objective is achievable, print `YES`; if it is unachievable, print `NO`. * * *
s423748240
Wrong Answer
p03524
Input is given from Standard Input in the following format: S
print("YES")
Statement Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.
[{"input": "abac", "output": "YES\n \n\nAs it stands now, S contains a palindrome `aba`, but we can permute the\ncharacters to get `acba`, for example, that does not contain a palindrome of\nlength 2 or more.\n\n* * *"}, {"input": "aba", "output": "NO\n \n\n* * *"}, {"input": "babacccabab", "output": "YES"}]
Print the number of ways modulo $10^9+7$ in a line.
s673733768
Accepted
p02335
$n$ $k$ The first line will contain two integers $n$ and $k$.
N, K = map(int, input().split()) MOD = 10**9 + 7 if K < N: print(0) else: p = q = 1 for i in range(N): p = p * (K - i) % MOD q = q * (i + 1) % MOD print(p * pow(q, MOD - 2, MOD) % MOD)
You have $n$ balls and $k$ boxes. You want to put these balls into the boxes. Find the number of ways to put the balls under the following conditions: * Each ball is **not** distinguished from the other. * Each box is distinguished from the other. * Each ball can go into only one box and no one remains outside of the boxes. * Each box can contain at most one ball. Note that you must print this count modulo $10^9+7$.
[{"input": "3 5", "output": "10"}, {"input": "5 10", "output": "252"}, {"input": "100 200", "output": "407336795"}]
Print the number of ways modulo $10^9+7$ in a line.
s624922652
Accepted
p02335
$n$ $k$ The first line will contain two integers $n$ and $k$.
import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print("Yes") def No(): print("No") def YES(): print("YES") def NO(): print("NO") sys.setrecursionlimit(10**9) INF = 10**18 MOD = 10**9 + 7 EPS = 10**-10 class ModTools: """階乗・逆元用のテーブルを構築する""" def __init__(self, MAX, MOD): MAX += 1 self.MAX = MAX self.MOD = MOD factorial = [1] * MAX factorial[0] = factorial[1] = 1 for i in range(2, MAX): factorial[i] = factorial[i - 1] * i % MOD inverse = [1] * MAX inverse[MAX - 1] = pow(factorial[MAX - 1], MOD - 2, MOD) for i in range(MAX - 2, -1, -1): inverse[i] = inverse[i + 1] * (i + 1) % MOD self.fact = factorial self.inv = inverse def nCr(self, n, r): """組み合わせ""" if n < r: return 0 r = min(r, n - r) numerator = self.fact[n] denominator = self.inv[r] * self.inv[n - r] % self.MOD return numerator * denominator % self.MOD def nHr(self, n, r): """重複組み合わせ""" return self.nCr(r + n - 1, r) def nPr(self, n, r): """順列""" if n < r: return 0 return self.fact[n] * self.inv[n - r] % self.MOD def div(self, x, y): """MOD除算""" return x * pow(y, self.MOD - 2, self.MOD) % self.MOD N, K = MAP() mt = ModTools(N + K + 1, MOD) ans = mt.nCr(K, N) print(ans)
You have $n$ balls and $k$ boxes. You want to put these balls into the boxes. Find the number of ways to put the balls under the following conditions: * Each ball is **not** distinguished from the other. * Each box is distinguished from the other. * Each ball can go into only one box and no one remains outside of the boxes. * Each box can contain at most one ball. Note that you must print this count modulo $10^9+7$.
[{"input": "3 5", "output": "10"}, {"input": "5 10", "output": "252"}, {"input": "100 200", "output": "407336795"}]
Print his Inner Rating. * * *
s270783939
Wrong Answer
p02765
Input is given from Standard Input in the following format: N R
l, n = map(int, input().split()) p = 100 * (10 - l) print(p + n)
Statement Takahashi is a member of a programming competition site, _ButCoder_. Each member of ButCoder is assigned two values: **Inner Rating** and **Displayed Rating**. The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \times (10 - K) when the member has participated in K contests. Takahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.
[{"input": "2 2919", "output": "3719\n \n\nTakahashi has participated in 2 contests, which is less than 10, so his\nDisplayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\n* * *"}, {"input": "22 3051", "output": "3051"}]
Print his Inner Rating. * * *
s723234026
Accepted
p02765
Input is given from Standard Input in the following format: N R
# 入力が10**5とかになったときに100ms程度早い import sys read = sys.stdin.readline def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_matrix(H): """ H is number of rows """ return [list(map(int, read().split())) for _ in range(H)] def read_map(H): """ H is number of rows 文字列で与えられた盤面を読み取る用 """ return [read()[:-1] for _ in range(H)] def read_tuple(H): """ H is number of rows """ ret = [] for _ in range(H): ret.append(tuple(map(int, read().split()))) return ret def read_col(H, n_cols): """ H is number of rows n_cols is number of cols A列、B列が与えられるようなとき """ ret = [[] for _ in range(n_cols)] for _ in range(H): tmp = list(map(int, read().split())) for col in range(n_cols): ret[col].append(tmp[col]) return ret N, R = read_ints() if N >= 10: print(R) else: print(R + (100 * (10 - N)))
Statement Takahashi is a member of a programming competition site, _ButCoder_. Each member of ButCoder is assigned two values: **Inner Rating** and **Displayed Rating**. The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \times (10 - K) when the member has participated in K contests. Takahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.
[{"input": "2 2919", "output": "3719\n \n\nTakahashi has participated in 2 contests, which is less than 10, so his\nDisplayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\n* * *"}, {"input": "22 3051", "output": "3051"}]
Print his Inner Rating. * * *
s394241147
Runtime Error
p02765
Input is given from Standard Input in the following format: N R
num_line = input().rstrip().split(" ") num = int(num_line[0]) a = int(num_line[1]) b = int(num_line[2]) allcase = pow(2, num, 1000000007) - 1 # print(allcase) abunshi = 1 for i in range(num - a + 1, num + 1): abunshi *= i # print(abunshi) abumbo = 1 for i in range(1, a + 1): abumbo *= i # print(abumbo) abumbo = pow(abumbo, 1000000005, 1000000007) # print(abumbo) aminus = abunshi * abumbo % 1000000007 # print(aminus) bbunshi = 1 for i in range(num - b + 1, num + 1): bbunshi *= i # print(bbunshi) bbumbo = 1 for i in range(1, b + 1): bbumbo *= i # print(bbumbo) bbumbo = pow(bbumbo, 1000000005, 1000000007) # print(bbumbo) bminus = bbunshi * bbumbo % 1000000007 # print(bminus) print(allcase - aminus - bminus)
Statement Takahashi is a member of a programming competition site, _ButCoder_. Each member of ButCoder is assigned two values: **Inner Rating** and **Displayed Rating**. The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \times (10 - K) when the member has participated in K contests. Takahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.
[{"input": "2 2919", "output": "3719\n \n\nTakahashi has participated in 2 contests, which is less than 10, so his\nDisplayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\n* * *"}, {"input": "22 3051", "output": "3051"}]
Print his Inner Rating. * * *
s304474210
Wrong Answer
p02765
Input is given from Standard Input in the following format: N R
x = list(map(int, input().split())) ans = [] if len(set(x)) == 1: print(0) else: for p in range(min(x), max(x)): meter = 0 for xi in x: meter += pow((xi - p), 2) ans.append(meter) print(min(ans))
Statement Takahashi is a member of a programming competition site, _ButCoder_. Each member of ButCoder is assigned two values: **Inner Rating** and **Displayed Rating**. The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \times (10 - K) when the member has participated in K contests. Takahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.
[{"input": "2 2919", "output": "3719\n \n\nTakahashi has participated in 2 contests, which is less than 10, so his\nDisplayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\n* * *"}, {"input": "22 3051", "output": "3051"}]
Print his Inner Rating. * * *
s454331005
Wrong Answer
p02765
Input is given from Standard Input in the following format: N R
a, b = map(int, input().split(" ")) print([b, b - (100 * (10 - a))][a < 10])
Statement Takahashi is a member of a programming competition site, _ButCoder_. Each member of ButCoder is assigned two values: **Inner Rating** and **Displayed Rating**. The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \times (10 - K) when the member has participated in K contests. Takahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.
[{"input": "2 2919", "output": "3719\n \n\nTakahashi has participated in 2 contests, which is less than 10, so his\nDisplayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\n* * *"}, {"input": "22 3051", "output": "3051"}]
Print his Inner Rating. * * *
s914300827
Runtime Error
p02765
Input is given from Standard Input in the following format: N R
import sys input = sys.stdin.readline from collections import deque N = int(input()) graph = [deque([]) for _ in range(N)] has = [] stack = [] for i in range(N): u, k, *v = [int(x) for x in input().split()] v.sort() for j in v: graph[u - 1].append(j) time = 0 arrive_time = [-1] * N def dfs(x): stack.append(x) # 探索スタート地点を「探索候補スタック」に積む while stack: # stackが空になるまで v = stack.pop() has.append(v) # 探索済みリストに取り出した地点を格納(ここが現在地点) for i in graph[v - 1]: if i in has: continue elif i in stack: continue else: stack.append(i) print(*has) dfs(1)
Statement Takahashi is a member of a programming competition site, _ButCoder_. Each member of ButCoder is assigned two values: **Inner Rating** and **Displayed Rating**. The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \times (10 - K) when the member has participated in K contests. Takahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.
[{"input": "2 2919", "output": "3719\n \n\nTakahashi has participated in 2 contests, which is less than 10, so his\nDisplayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\n* * *"}, {"input": "22 3051", "output": "3051"}]
Print his Inner Rating. * * *
s541287070
Runtime Error
p02765
Input is given from Standard Input in the following format: N R
n = int(input()) x = [] a = 100000 for i in range(0, n): i = int(input()) x.append(i) for i in range(x[0], x[n - 1] + 1): h = 0 for j in range(n): h += (x[j] - i) ** 2 if h < a: a = h print(a)
Statement Takahashi is a member of a programming competition site, _ButCoder_. Each member of ButCoder is assigned two values: **Inner Rating** and **Displayed Rating**. The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \times (10 - K) when the member has participated in K contests. Takahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.
[{"input": "2 2919", "output": "3719\n \n\nTakahashi has participated in 2 contests, which is less than 10, so his\nDisplayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\n* * *"}, {"input": "22 3051", "output": "3051"}]
Print his Inner Rating. * * *
s087918831
Runtime Error
p02765
Input is given from Standard Input in the following format: N R
import math n, a, b = map(int, input().split()) c = 0 for i in range(1, n + 1): c += (math.factorial(n) // (math.factorial(n - i) * math.factorial(i))) % ( pow(10, 9) + 7 ) c = c - (math.factorial(n) // (math.factorial(n - a) * math.factorial(a))) % ( pow(10, 9) + 7 ) c = c - (math.factorial(n) // (math.factorial(n - b) * math.factorial(b))) % ( pow(10, 9) + 7 ) print(c) # TLE
Statement Takahashi is a member of a programming competition site, _ButCoder_. Each member of ButCoder is assigned two values: **Inner Rating** and **Displayed Rating**. The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \times (10 - K) when the member has participated in K contests. Takahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.
[{"input": "2 2919", "output": "3719\n \n\nTakahashi has participated in 2 contests, which is less than 10, so his\nDisplayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\n* * *"}, {"input": "22 3051", "output": "3051"}]
Print his Inner Rating. * * *
s249066874
Accepted
p02765
Input is given from Standard Input in the following format: N R
input = input().split() N = int(input[0]) R = int(input[1]) gap = max(0, 100 * (10 - N)) real = R + gap print(real)
Statement Takahashi is a member of a programming competition site, _ButCoder_. Each member of ButCoder is assigned two values: **Inner Rating** and **Displayed Rating**. The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \times (10 - K) when the member has participated in K contests. Takahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.
[{"input": "2 2919", "output": "3719\n \n\nTakahashi has participated in 2 contests, which is less than 10, so his\nDisplayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\n* * *"}, {"input": "22 3051", "output": "3051"}]
Print his Inner Rating. * * *
s548905428
Accepted
p02765
Input is given from Standard Input in the following format: N R
print( (lambda x: (int(x[1]) + (100 * (10 - (10 if int(x[0]) >= 10 else int(x[0]))))))( input().split() ) )
Statement Takahashi is a member of a programming competition site, _ButCoder_. Each member of ButCoder is assigned two values: **Inner Rating** and **Displayed Rating**. The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \times (10 - K) when the member has participated in K contests. Takahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.
[{"input": "2 2919", "output": "3719\n \n\nTakahashi has participated in 2 contests, which is less than 10, so his\nDisplayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\n* * *"}, {"input": "22 3051", "output": "3051"}]
Print his Inner Rating. * * *
s228871576
Accepted
p02765
Input is given from Standard Input in the following format: N R
n, r = [int(k) for k in input().strip().split(" ")] print(r + max(0, (10 - n) * 100))
Statement Takahashi is a member of a programming competition site, _ButCoder_. Each member of ButCoder is assigned two values: **Inner Rating** and **Displayed Rating**. The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \times (10 - K) when the member has participated in K contests. Takahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.
[{"input": "2 2919", "output": "3719\n \n\nTakahashi has participated in 2 contests, which is less than 10, so his\nDisplayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\n* * *"}, {"input": "22 3051", "output": "3051"}]
Print his Inner Rating. * * *
s089395359
Runtime Error
p02765
Input is given from Standard Input in the following format: N R
s = input() print(100 * max(0, 10 - int(s[:2])) + int(s[2:]))
Statement Takahashi is a member of a programming competition site, _ButCoder_. Each member of ButCoder is assigned two values: **Inner Rating** and **Displayed Rating**. The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \times (10 - K) when the member has participated in K contests. Takahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.
[{"input": "2 2919", "output": "3719\n \n\nTakahashi has participated in 2 contests, which is less than 10, so his\nDisplayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\n* * *"}, {"input": "22 3051", "output": "3051"}]
Print his Inner Rating. * * *
s604034121
Wrong Answer
p02765
Input is given from Standard Input in the following format: N R
print((lambda x: int(x[1]) - max(0, 100 * (10 - int(x[0]))))(input().split()))
Statement Takahashi is a member of a programming competition site, _ButCoder_. Each member of ButCoder is assigned two values: **Inner Rating** and **Displayed Rating**. The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \times (10 - K) when the member has participated in K contests. Takahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.
[{"input": "2 2919", "output": "3719\n \n\nTakahashi has participated in 2 contests, which is less than 10, so his\nDisplayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\n* * *"}, {"input": "22 3051", "output": "3051"}]
Print his Inner Rating. * * *
s697271805
Runtime Error
p02765
Input is given from Standard Input in the following format: N R
N = input() for i in range(N): A = [int(i) for i in input().split()] P = round(sum(A) / N) B = 0 for i in range(N): B = B + (A[i] - P) ** 2 print(B)
Statement Takahashi is a member of a programming competition site, _ButCoder_. Each member of ButCoder is assigned two values: **Inner Rating** and **Displayed Rating**. The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \times (10 - K) when the member has participated in K contests. Takahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.
[{"input": "2 2919", "output": "3719\n \n\nTakahashi has participated in 2 contests, which is less than 10, so his\nDisplayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\n* * *"}, {"input": "22 3051", "output": "3051"}]
Print his Inner Rating. * * *
s989374406
Runtime Error
p02765
Input is given from Standard Input in the following format: N R
n, a, b = map(int, input().split()) mod = pow(10, 9) + 7 def comb(N, x): numerator = 1 for i in range(N - x + 1, N + 1): numerator = numerator * i % mod denominator = 1 for j in range(1, x + 1): denominator = denominator * j % mod d = pow(denominator, mod - 2, mod) return numerator * d a = comb(n, a) b = comb(n, b) print((pow(2, n, mod) - 1 - a - b) % mod)
Statement Takahashi is a member of a programming competition site, _ButCoder_. Each member of ButCoder is assigned two values: **Inner Rating** and **Displayed Rating**. The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus 100 \times (10 - K) when the member has participated in K contests. Takahashi has participated in N contests, and his Displayed Rating is R. Find his Inner Rating.
[{"input": "2 2919", "output": "3719\n \n\nTakahashi has participated in 2 contests, which is less than 10, so his\nDisplayed Rating is his Inner Rating minus 100 \\times (10 - 2) = 800.\n\nThus, Takahashi's Inner Rating is 2919 + 800 = 3719.\n\n* * *"}, {"input": "22 3051", "output": "3051"}]
If there does not exist an valid assignment that is consistent with s, print `-1`. Otherwise, print an string t in the following format. The output is considered correct if the assignment described by t is consistent with s. * t is a string of length N consisting of `S` and `W`. * If t_i is `S`, it indicates that the animal numbered i is a sheep. If t_i is `W`, it indicates that the animal numbered i is a wolf. * * *
s775118322
Wrong Answer
p03800
The input is given from Standard Input in the following format: N s
print(-1)
Statement Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1. There are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies. Snuke cannot tell the difference between these two species, and asked each animal the following question: "Are your neighbors of the same species?" The animal numbered i answered s_i. Here, if s_i is `o`, the animal said that the two neighboring animals are of the same species, and if s_i is `x`, the animal said that the two neighboring animals are of different species. More formally, a sheep answered `o` if the two neighboring animals are both sheep or both wolves, and answered `x` otherwise. Similarly, a wolf answered `x` if the two neighboring animals are both sheep or both wolves, and answered `o` otherwise. Snuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print `-1`.
[{"input": "6\n ooxoox", "output": "SSSWWS\n \n\nFor example, if the animals numbered 1, 2, 3, 4, 5 and 6 are respectively a\nsheep, sheep, sheep, wolf, wolf, and sheep, it is consistent with their\nresponses. Besides, there is another valid assignment of species: a wolf,\nsheep, wolf, sheep, wolf and wolf.\n\nLet us remind you: if the neiboring animals are of the same species, a sheep\nanswers `o` and a wolf answers `x`. If the neiboring animals are of different\nspecies, a sheep answers `x` and a wolf answers `o`.\n\n![b34c052fc21c42d2def9b98d6dccd05c.png](https://atcoder.jp/img/arc069/b34c052fc21c42d2def9b98d6dccd05c.png)\n\n* * *"}, {"input": "3\n oox", "output": "-1\n \n\nPrint `-1` if there is no valid assignment of species.\n\n* * *"}, {"input": "10\n oxooxoxoox", "output": "SSWWSSSWWS"}]
If there does not exist an valid assignment that is consistent with s, print `-1`. Otherwise, print an string t in the following format. The output is considered correct if the assignment described by t is consistent with s. * t is a string of length N consisting of `S` and `W`. * If t_i is `S`, it indicates that the animal numbered i is a sheep. If t_i is `W`, it indicates that the animal numbered i is a wolf. * * *
s529909752
Runtime Error
p03800
The input is given from Standard Input in the following format: N s
import sys n = int(input()) s = input() L = ["SS","SW","WS","WW"] l= len(s) ##0,1に置き換えたりしない ##条件分岐注意する ##ずらす必要はない、Lが固定するのはindexで-2,-1 for t in L:  tmp = t### for i in range(l): if (s[i]=="x") ^ (tmp[-1] == "W"): if tmp[-2]=="S": tmp+= "W" else: tmp += "S" else: tmp += tmp[-2] if tmp[:2]==tmp[-2:]: print(tmp) sys.exit() print(-1)
Statement Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1. There are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies. Snuke cannot tell the difference between these two species, and asked each animal the following question: "Are your neighbors of the same species?" The animal numbered i answered s_i. Here, if s_i is `o`, the animal said that the two neighboring animals are of the same species, and if s_i is `x`, the animal said that the two neighboring animals are of different species. More formally, a sheep answered `o` if the two neighboring animals are both sheep or both wolves, and answered `x` otherwise. Similarly, a wolf answered `x` if the two neighboring animals are both sheep or both wolves, and answered `o` otherwise. Snuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print `-1`.
[{"input": "6\n ooxoox", "output": "SSSWWS\n \n\nFor example, if the animals numbered 1, 2, 3, 4, 5 and 6 are respectively a\nsheep, sheep, sheep, wolf, wolf, and sheep, it is consistent with their\nresponses. Besides, there is another valid assignment of species: a wolf,\nsheep, wolf, sheep, wolf and wolf.\n\nLet us remind you: if the neiboring animals are of the same species, a sheep\nanswers `o` and a wolf answers `x`. If the neiboring animals are of different\nspecies, a sheep answers `x` and a wolf answers `o`.\n\n![b34c052fc21c42d2def9b98d6dccd05c.png](https://atcoder.jp/img/arc069/b34c052fc21c42d2def9b98d6dccd05c.png)\n\n* * *"}, {"input": "3\n oox", "output": "-1\n \n\nPrint `-1` if there is no valid assignment of species.\n\n* * *"}, {"input": "10\n oxooxoxoox", "output": "SSWWSSSWWS"}]
If there does not exist an valid assignment that is consistent with s, print `-1`. Otherwise, print an string t in the following format. The output is considered correct if the assignment described by t is consistent with s. * t is a string of length N consisting of `S` and `W`. * If t_i is `S`, it indicates that the animal numbered i is a sheep. If t_i is `W`, it indicates that the animal numbered i is a wolf. * * *
s754857040
Wrong Answer
p03800
The input is given from Standard Input in the following format: N s
N = int(input()) SS = input() l1 = ["S"] p1 = "S" l2 = ["S"] p2 = "W" l3 = ["W"] p3 = "S" l4 = ["W"] p4 = "W" def when_o_next(p, c): if c == "S": if p == "S": return "S" if p == "W": return "W" if c == "W": if p == "S": return "W" if p == "W": return "S" def when_x_next(p, c): if c == "S": if p == "S": return "W" if p == "W": return "S" if c == "W": if p == "S": return "S" if p == "W": return "W" def next(f, p, c): if f == "o": return when_o_next(p, c) return when_x_next(p, c) for i in range(N): s = SS[i] c1 = l1[i] n1 = next(s, p1, c1) l1.append(n1) p1 = c1 c2 = l2[i] n2 = next(s, p2, c2) l2.append(n2) p2 = c2 c3 = l3[i] n3 = next(s, p3, c3) l3.append(n3) p3 = c3 c4 = l4[i] n4 = next(s, p4, c4) l4.append(n4) p4 = c4 import sys if l1[0] == l1[N]: print("".join(l1[:-1])) sys.exit() if l2[0] == l2[N]: print("".join(l2[:-1])) sys.exit() if l3[0] == l3[N]: print("".join(l3[:-1])) sys.exit() if l4[0] == l4[N]: print("".join(l4[:-1])) sys.exit() print(-1)
Statement Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1. There are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies. Snuke cannot tell the difference between these two species, and asked each animal the following question: "Are your neighbors of the same species?" The animal numbered i answered s_i. Here, if s_i is `o`, the animal said that the two neighboring animals are of the same species, and if s_i is `x`, the animal said that the two neighboring animals are of different species. More formally, a sheep answered `o` if the two neighboring animals are both sheep or both wolves, and answered `x` otherwise. Similarly, a wolf answered `x` if the two neighboring animals are both sheep or both wolves, and answered `o` otherwise. Snuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print `-1`.
[{"input": "6\n ooxoox", "output": "SSSWWS\n \n\nFor example, if the animals numbered 1, 2, 3, 4, 5 and 6 are respectively a\nsheep, sheep, sheep, wolf, wolf, and sheep, it is consistent with their\nresponses. Besides, there is another valid assignment of species: a wolf,\nsheep, wolf, sheep, wolf and wolf.\n\nLet us remind you: if the neiboring animals are of the same species, a sheep\nanswers `o` and a wolf answers `x`. If the neiboring animals are of different\nspecies, a sheep answers `x` and a wolf answers `o`.\n\n![b34c052fc21c42d2def9b98d6dccd05c.png](https://atcoder.jp/img/arc069/b34c052fc21c42d2def9b98d6dccd05c.png)\n\n* * *"}, {"input": "3\n oox", "output": "-1\n \n\nPrint `-1` if there is no valid assignment of species.\n\n* * *"}, {"input": "10\n oxooxoxoox", "output": "SSWWSSSWWS"}]
If there does not exist an valid assignment that is consistent with s, print `-1`. Otherwise, print an string t in the following format. The output is considered correct if the assignment described by t is consistent with s. * t is a string of length N consisting of `S` and `W`. * If t_i is `S`, it indicates that the animal numbered i is a sheep. If t_i is `W`, it indicates that the animal numbered i is a wolf. * * *
s139669789
Wrong Answer
p03800
The input is given from Standard Input in the following format: N s
N = int(input()) s = list(input()) for i in range(2**2): sw = [1, 1] ans = [1] * (N + 1) for j in range(2): if (i >> j) % 2 == 1: sw[j] = 0 ans[j] = 0 for j in range(1, N): if sw[1] == 1: if s[j] == "o": sw[0], sw[1] = sw[1], sw[0] else: sw[0], sw[1] = sw[1], (sw[0]) ^ 1 else: if s[j] == "o": sw[0], sw[1] = sw[1], (sw[0]) ^ 1 else: sw[0], sw[1] = sw[1], sw[0] ans[j + 1] = sw[1] if ans[0] == ans[N]: for i in range(N): if ans[i] == 1: ans[i] = "S" else: ans[i] = "W" print("".join(ans[:N])) exit(0) else: continue print(-1)
Statement Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1. There are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies. Snuke cannot tell the difference between these two species, and asked each animal the following question: "Are your neighbors of the same species?" The animal numbered i answered s_i. Here, if s_i is `o`, the animal said that the two neighboring animals are of the same species, and if s_i is `x`, the animal said that the two neighboring animals are of different species. More formally, a sheep answered `o` if the two neighboring animals are both sheep or both wolves, and answered `x` otherwise. Similarly, a wolf answered `x` if the two neighboring animals are both sheep or both wolves, and answered `o` otherwise. Snuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print `-1`.
[{"input": "6\n ooxoox", "output": "SSSWWS\n \n\nFor example, if the animals numbered 1, 2, 3, 4, 5 and 6 are respectively a\nsheep, sheep, sheep, wolf, wolf, and sheep, it is consistent with their\nresponses. Besides, there is another valid assignment of species: a wolf,\nsheep, wolf, sheep, wolf and wolf.\n\nLet us remind you: if the neiboring animals are of the same species, a sheep\nanswers `o` and a wolf answers `x`. If the neiboring animals are of different\nspecies, a sheep answers `x` and a wolf answers `o`.\n\n![b34c052fc21c42d2def9b98d6dccd05c.png](https://atcoder.jp/img/arc069/b34c052fc21c42d2def9b98d6dccd05c.png)\n\n* * *"}, {"input": "3\n oox", "output": "-1\n \n\nPrint `-1` if there is no valid assignment of species.\n\n* * *"}, {"input": "10\n oxooxoxoox", "output": "SSWWSSSWWS"}]
If there does not exist an valid assignment that is consistent with s, print `-1`. Otherwise, print an string t in the following format. The output is considered correct if the assignment described by t is consistent with s. * t is a string of length N consisting of `S` and `W`. * If t_i is `S`, it indicates that the animal numbered i is a sheep. If t_i is `W`, it indicates that the animal numbered i is a wolf. * * *
s338887373
Accepted
p03800
The input is given from Standard Input in the following format: N s
from sys import stdout printn = lambda x: stdout.write(str(x)) inn = lambda: int(input()) inl = lambda: list(map(int, input().split())) inm = lambda: map(int, input().split()) ins = lambda: input().strip() DBG = True # and False BIG = 999999999 R = 10**9 + 7 def ddprint(x): if DBG: print(x) def right(aim, ai, si): if ai == 0: return aim if si == "o" else (1 - aim) else: return (1 - aim) if si == "o" else aim n = inn() s = ins() for a0 in [0, 1]: for a1 in [0, 1]: a = [-1] * n a[0] = a0 a[1] = a1 for i in range(1, n - 1): a[i + 1] = right(a[i - 1], a[i], s[i]) if ( right(a[n - 2], a[n - 1], s[n - 1]) == a[0] and right(a[n - 1], a[0], s[0]) == a[1] ): for j in range(n): printn("S" if a[j] == 0 else "W") print("") exit() print(-1)
Statement Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1. There are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies. Snuke cannot tell the difference between these two species, and asked each animal the following question: "Are your neighbors of the same species?" The animal numbered i answered s_i. Here, if s_i is `o`, the animal said that the two neighboring animals are of the same species, and if s_i is `x`, the animal said that the two neighboring animals are of different species. More formally, a sheep answered `o` if the two neighboring animals are both sheep or both wolves, and answered `x` otherwise. Similarly, a wolf answered `x` if the two neighboring animals are both sheep or both wolves, and answered `o` otherwise. Snuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print `-1`.
[{"input": "6\n ooxoox", "output": "SSSWWS\n \n\nFor example, if the animals numbered 1, 2, 3, 4, 5 and 6 are respectively a\nsheep, sheep, sheep, wolf, wolf, and sheep, it is consistent with their\nresponses. Besides, there is another valid assignment of species: a wolf,\nsheep, wolf, sheep, wolf and wolf.\n\nLet us remind you: if the neiboring animals are of the same species, a sheep\nanswers `o` and a wolf answers `x`. If the neiboring animals are of different\nspecies, a sheep answers `x` and a wolf answers `o`.\n\n![b34c052fc21c42d2def9b98d6dccd05c.png](https://atcoder.jp/img/arc069/b34c052fc21c42d2def9b98d6dccd05c.png)\n\n* * *"}, {"input": "3\n oox", "output": "-1\n \n\nPrint `-1` if there is no valid assignment of species.\n\n* * *"}, {"input": "10\n oxooxoxoox", "output": "SSWWSSSWWS"}]
Print the sum of all numbers among the first N terms of the FizzBuzz sequence. * * *
s938841969
Accepted
p02712
Input is given from Standard Input in the following format: N
# # Written by NoKnowledgeGG @YlePhan # ('ω') # # import math # mod = 10**9+7 # import itertools # import fractions # import numpy as np # mod = 10**4 + 7 """def kiri(n,m): r_ = n / m if (r_ - (n // m)) > 0: return (n//m) + 1 else: return (n//m)""" """ n! mod m 階乗 mod = 1e9 + 7 N = 10000000 fac = [0] * N def ini(): fac[0] = 1 % mod for i in range(1,N): fac[i] = fac[i-1] * i % mod""" """mod = 1e9+7 N = 10000000 pw = [0] * N def ini(c): pw[0] = 1 % mod for i in range(1,N): pw[i] = pw[i-1] * c % mod""" """ def YEILD(): yield 'one' yield 'two' yield 'three' generator = YEILD() print(next(generator)) print(next(generator)) print(next(generator)) """ """def gcd_(a,b): if b == 0:#結局はc,0の最大公約数はcなのに return a return gcd_(a,a % b) # a = p * b + q""" """def extgcd(a,b,x,y): d = a if b!=0: d = extgcd(b,a%b,y,x) y -= (a//b) * x print(x,y) else: x = 1 y = 0 return d""" # 最大公約数 と 最小公倍数 """def gcd(a,b): if b == 0: return a return gcd(b, a % b) def lcm(a,b): g = gcd(a,b) return (a * b) // g""" # 二分探索 """import bisect # 二分探索 print(A,bisect.bisect_left(A,4)) print(C,n - bisect.bisect_right(C,4)) print(sum(bisect.bisect_left(A,b) * (n-bisect.bisect_right(C,b)) for b in B))""" # 円周率 pi """import math pi_ = math.pi""" # エラトステネスの篩 """def Erato(n): prime = [] is_prime = [True] * (n+1) p = 0 is_prime[0] = False is_prime[1] = False for i in range(2,n+1): if is_prime[i] == True: prime.append(i) p += 1 for j in range(2 * i,n+1,i): is_prime[j] = False return p""" def readInts(): return list(map(int, input().split())) mod = 10**9 + 7 def main(): n = int(input()) Fizz = [0] * n for i in range(1, n + 1): if i % 15 == 0: pass elif i % 3 == 0: pass elif i % 5 == 0: pass else: Fizz[i - 1] = i print(sum(Fizz)) if __name__ == "__main__": main()
Statement Let us define the **FizzBuzz sequence** a_1,a_2,... as follows: * If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}. * If the above does not hold but 3 divides i, a_i=\mbox{Fizz}. * If none of the above holds but 5 divides i, a_i=\mbox{Buzz}. * If none of the above holds, a_i=i. Find the sum of all numbers among the first N terms of the FizzBuzz sequence.
[{"input": "15", "output": "60\n \n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\n* * *"}, {"input": "1000000", "output": "266666333332\n \n\nWatch out for overflow."}]
Print the sum of all numbers among the first N terms of the FizzBuzz sequence. * * *
s986773008
Wrong Answer
p02712
Input is given from Standard Input in the following format: N
given = [int(x) for x in range(1, int(input()) + 1) if x % 3 != 0 or x % 5 != 0] print(sum(given))
Statement Let us define the **FizzBuzz sequence** a_1,a_2,... as follows: * If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}. * If the above does not hold but 3 divides i, a_i=\mbox{Fizz}. * If none of the above holds but 5 divides i, a_i=\mbox{Buzz}. * If none of the above holds, a_i=i. Find the sum of all numbers among the first N terms of the FizzBuzz sequence.
[{"input": "15", "output": "60\n \n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\n* * *"}, {"input": "1000000", "output": "266666333332\n \n\nWatch out for overflow."}]
Print the sum of all numbers among the first N terms of the FizzBuzz sequence. * * *
s315492581
Wrong Answer
p02712
Input is given from Standard Input in the following format: N
print(sum([i * (i % 3 != 0) * (i % 5 != 0) for i in range(int(input()))]))
Statement Let us define the **FizzBuzz sequence** a_1,a_2,... as follows: * If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}. * If the above does not hold but 3 divides i, a_i=\mbox{Fizz}. * If none of the above holds but 5 divides i, a_i=\mbox{Buzz}. * If none of the above holds, a_i=i. Find the sum of all numbers among the first N terms of the FizzBuzz sequence.
[{"input": "15", "output": "60\n \n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\n* * *"}, {"input": "1000000", "output": "266666333332\n \n\nWatch out for overflow."}]
Print the sum of all numbers among the first N terms of the FizzBuzz sequence. * * *
s956668480
Accepted
p02712
Input is given from Standard Input in the following format: N
n = int(input()) x = (1 + n) * n // 2 l = n // 3 x -= 3 * (1 + l) * l // 2 l = n // 5 x -= 5 * (1 + l) * l // 2 l = n // 15 x += 15 * (1 + l) * l // 2 print(x)
Statement Let us define the **FizzBuzz sequence** a_1,a_2,... as follows: * If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}. * If the above does not hold but 3 divides i, a_i=\mbox{Fizz}. * If none of the above holds but 5 divides i, a_i=\mbox{Buzz}. * If none of the above holds, a_i=i. Find the sum of all numbers among the first N terms of the FizzBuzz sequence.
[{"input": "15", "output": "60\n \n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\n* * *"}, {"input": "1000000", "output": "266666333332\n \n\nWatch out for overflow."}]
Print the sum of all numbers among the first N terms of the FizzBuzz sequence. * * *
s294566850
Wrong Answer
p02712
Input is given from Standard Input in the following format: N
N = int(input()) A = N // 3 B = N // 5 AanB = N // 15 Ssum = (1 + N) * N * (1 / 2) Asum = (1 + A) * A * (1 / 2) * 3 Bsum = (1 + B) * B * (1 / 2) * 5 AanBsum = (1 + AanB) * AanB * (1 / 2) * 15 print(Ssum - Asum - Bsum + AanBsum)
Statement Let us define the **FizzBuzz sequence** a_1,a_2,... as follows: * If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}. * If the above does not hold but 3 divides i, a_i=\mbox{Fizz}. * If none of the above holds but 5 divides i, a_i=\mbox{Buzz}. * If none of the above holds, a_i=i. Find the sum of all numbers among the first N terms of the FizzBuzz sequence.
[{"input": "15", "output": "60\n \n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\n* * *"}, {"input": "1000000", "output": "266666333332\n \n\nWatch out for overflow."}]
Print the sum of all numbers among the first N terms of the FizzBuzz sequence. * * *
s022964303
Wrong Answer
p02712
Input is given from Standard Input in the following format: N
N = 1000000 n = N // 15 ans = 60 * (n**2) if N % 15 == 1: ans += 1 + 15 * (n) elif N % 15 == 2 or N % 15 == 3: ans += 3 + 30 * (n) elif N % 15 == 4 or N % 15 == 5 or N % 15 == 6: ans += 7 + 45 * (n) elif N % 15 == 7: ans += 14 + 60 * (n) elif N % 15 == 8 or N % 15 == 9 or N % 15 == 10: ans += 22 + 75 * (n) elif N % 15 == 11 or N % 15 == 12: ans += 33 + 90 * (n) elif N % 15 == 13: ans += 46 + 105 * (n) elif N % 15 == 14: ans += 60 + 120 * (n) print(ans)
Statement Let us define the **FizzBuzz sequence** a_1,a_2,... as follows: * If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}. * If the above does not hold but 3 divides i, a_i=\mbox{Fizz}. * If none of the above holds but 5 divides i, a_i=\mbox{Buzz}. * If none of the above holds, a_i=i. Find the sum of all numbers among the first N terms of the FizzBuzz sequence.
[{"input": "15", "output": "60\n \n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\n* * *"}, {"input": "1000000", "output": "266666333332\n \n\nWatch out for overflow."}]
Print the sum of all numbers among the first N terms of the FizzBuzz sequence. * * *
s997437822
Accepted
p02712
Input is given from Standard Input in the following format: N
s = lambda x: x * (x + 1) // 2 print(s(n := int(input())) - s(n // 3) * 3 - s(n // 5) * 5 + s(n // 15) * 15)
Statement Let us define the **FizzBuzz sequence** a_1,a_2,... as follows: * If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}. * If the above does not hold but 3 divides i, a_i=\mbox{Fizz}. * If none of the above holds but 5 divides i, a_i=\mbox{Buzz}. * If none of the above holds, a_i=i. Find the sum of all numbers among the first N terms of the FizzBuzz sequence.
[{"input": "15", "output": "60\n \n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\n* * *"}, {"input": "1000000", "output": "266666333332\n \n\nWatch out for overflow."}]
Print the sum of all numbers among the first N terms of the FizzBuzz sequence. * * *
s943569468
Accepted
p02712
Input is given from Standard Input in the following format: N
print(sum((i for i in range(int(input()) + 1) if i % 3 and i % 5)))
Statement Let us define the **FizzBuzz sequence** a_1,a_2,... as follows: * If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}. * If the above does not hold but 3 divides i, a_i=\mbox{Fizz}. * If none of the above holds but 5 divides i, a_i=\mbox{Buzz}. * If none of the above holds, a_i=i. Find the sum of all numbers among the first N terms of the FizzBuzz sequence.
[{"input": "15", "output": "60\n \n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\n* * *"}, {"input": "1000000", "output": "266666333332\n \n\nWatch out for overflow."}]