output_description stringlengths 15 956 | submission_id stringlengths 10 10 | status stringclasses 3 values | problem_id stringlengths 6 6 | input_description stringlengths 9 2.55k | attempt stringlengths 1 13.7k | problem_description stringlengths 7 5.24k | samples stringlengths 2 2.72k |
|---|---|---|---|---|---|---|---|
If a is not less than 3200, print s; if a is less than 3200, print `red`.
* * * | s660524231 | Wrong Answer | p02933 | Input is given from Standard Input in the following format:
a
s | def check(t, s):
i = 0
for j in range(len(s)):
if i == len(t):
return (True, j)
if t[i] == s[j]:
i += 1
if i == len(t):
return (True, len(s))
return False, -1
def solve(s, t):
new_s = s
for a in t:
if a not in s:
return -1
l = 1
r = 1005
final = 10**100
while l <= r:
mid = (l + r) // 2
new_s = s * mid
done, ans = check(t, new_s)
if done:
final = min(final, ans)
r = mid - 1
else:
l = mid + 1
return final
s = input()
t = input()
print(solve(s, t))
| Statement
You will be given an integer a and a string s consisting of lowercase English
letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a
is less than 3200. | [{"input": "3200\n pink", "output": "pink\n \n\na = 3200 is not less than 3200, so we print s = `pink`.\n\n* * *"}, {"input": "3199\n pink", "output": "red\n \n\na = 3199 is less than 3200, so we print `red`.\n\n* * *"}, {"input": "4049\n red", "output": "red\n \n\na = 4049 is not less than 3200, so we print s = `red`."}] |
If a is not less than 3200, print s; if a is less than 3200, print `red`.
* * * | s698002130 | Runtime Error | p02933 | Input is given from Standard Input in the following format:
a
s | N, Q = map(int, input().split())
tree = [list(map(int, input().split())) for i in range(N - 1)]
process = [list(map(int, input().split())) for i in range(Q)]
def next_node(node_num):
next_nodes = []
for edge in tree:
if edge[0] == node_num:
next_nodes.append(edge[1])
return next_nodes
def all_nodes(num):
x = []
add_nodes = next_node(num)
while add_nodes != []:
for i in add_nodes:
add_nodes += next_node(i)
x += add_nodes
add_nodes = []
return x
def add(score, procedure):
"procedure = [p, x]"
score[procedure[0] - 1] += procedure[1]
for n in all_nodes(procedure[0]):
score[n - 1] += procedure[1]
return score
score = [0] * N
for procedure in process:
add(score, procedure)
print(score)
| Statement
You will be given an integer a and a string s consisting of lowercase English
letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a
is less than 3200. | [{"input": "3200\n pink", "output": "pink\n \n\na = 3200 is not less than 3200, so we print s = `pink`.\n\n* * *"}, {"input": "3199\n pink", "output": "red\n \n\na = 3199 is less than 3200, so we print `red`.\n\n* * *"}, {"input": "4049\n red", "output": "red\n \n\na = 4049 is not less than 3200, so we print s = `red`."}] |
If a is not less than 3200, print s; if a is less than 3200, print `red`.
* * * | s994835829 | Runtime Error | p02933 | Input is given from Standard Input in the following format:
a
s | repeat = int(input())
numbers = input().rstrip().split(" ")
# print(numbers)
sum = 0
for i in range(repeat):
sum = sum + 1 / int(numbers[i])
# print(sum)
answer = 1 / sum
print(answer)
| Statement
You will be given an integer a and a string s consisting of lowercase English
letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a
is less than 3200. | [{"input": "3200\n pink", "output": "pink\n \n\na = 3200 is not less than 3200, so we print s = `pink`.\n\n* * *"}, {"input": "3199\n pink", "output": "red\n \n\na = 3199 is less than 3200, so we print `red`.\n\n* * *"}, {"input": "4049\n red", "output": "red\n \n\na = 4049 is not less than 3200, so we print s = `red`."}] |
If a is not less than 3200, print s; if a is less than 3200, print `red`.
* * * | s176685147 | Runtime Error | p02933 | Input is given from Standard Input in the following format:
a
s | P, n = map(int, input().split())
struct = [list(map(int, input().split())) for x in range(P - 1)]
act = [list(map(int, input().split())) for y in range(n)]
A = []
def add_val(action):
idx = action[0]
val = action[1]
A[idx][0] += val
if A[idx][1]:
for r in A[idx][1]:
add_val([r, val])
for a in range(P + 1):
A.append(list([0, []]))
for z in struct:
p = z[0]
p_ = z[1]
A[p][1].append(p_)
for _ in act:
add_val(_)
As = []
for _ in range(1, len(A)):
As.append(A[_][0])
print(*As, sep=" ")
| Statement
You will be given an integer a and a string s consisting of lowercase English
letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a
is less than 3200. | [{"input": "3200\n pink", "output": "pink\n \n\na = 3200 is not less than 3200, so we print s = `pink`.\n\n* * *"}, {"input": "3199\n pink", "output": "red\n \n\na = 3199 is less than 3200, so we print `red`.\n\n* * *"}, {"input": "4049\n red", "output": "red\n \n\na = 4049 is not less than 3200, so we print s = `red`."}] |
If a is not less than 3200, print s; if a is less than 3200, print `red`.
* * * | s764178309 | Runtime Error | p02933 | Input is given from Standard Input in the following format:
a
s | N = int(input())
v = sorted(list(map(int, input().split())))
for i in range(N - 1):
a = (v[i] + v[i + 1]) / 2
v[i + 1] = float(a)
a = 0
print(v[-1])
| Statement
You will be given an integer a and a string s consisting of lowercase English
letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a
is less than 3200. | [{"input": "3200\n pink", "output": "pink\n \n\na = 3200 is not less than 3200, so we print s = `pink`.\n\n* * *"}, {"input": "3199\n pink", "output": "red\n \n\na = 3199 is less than 3200, so we print `red`.\n\n* * *"}, {"input": "4049\n red", "output": "red\n \n\na = 4049 is not less than 3200, so we print s = `red`."}] |
If a is not less than 3200, print s; if a is less than 3200, print `red`.
* * * | s840612173 | Runtime Error | p02933 | Input is given from Standard Input in the following format:
a
s | n = int(input())
v = sorted(list(map(int, input().split())), reverse=False)
for i in range(1, n):
v[0] = (v[0] + v[i]) / 2
print(v[0])
| Statement
You will be given an integer a and a string s consisting of lowercase English
letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a
is less than 3200. | [{"input": "3200\n pink", "output": "pink\n \n\na = 3200 is not less than 3200, so we print s = `pink`.\n\n* * *"}, {"input": "3199\n pink", "output": "red\n \n\na = 3199 is less than 3200, so we print `red`.\n\n* * *"}, {"input": "4049\n red", "output": "red\n \n\na = 4049 is not less than 3200, so we print s = `red`."}] |
If a is not less than 3200, print s; if a is less than 3200, print `red`.
* * * | s727684265 | Runtime Error | p02933 | Input is given from Standard Input in the following format:
a
s | N = int(input())
L = list(map(int, input().split()))
m = []
for i in L:
a = 1 / i
m.append(a)
S = sum(m)
print(1 / S)
| Statement
You will be given an integer a and a string s consisting of lowercase English
letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a
is less than 3200. | [{"input": "3200\n pink", "output": "pink\n \n\na = 3200 is not less than 3200, so we print s = `pink`.\n\n* * *"}, {"input": "3199\n pink", "output": "red\n \n\na = 3199 is less than 3200, so we print `red`.\n\n* * *"}, {"input": "4049\n red", "output": "red\n \n\na = 4049 is not less than 3200, so we print s = `red`."}] |
If a is not less than 3200, print s; if a is less than 3200, print `red`.
* * * | s030369208 | Accepted | p02933 | Input is given from Standard Input in the following format:
a
s | print(input() if int(input()) >= 3200 else "red")
| Statement
You will be given an integer a and a string s consisting of lowercase English
letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a
is less than 3200. | [{"input": "3200\n pink", "output": "pink\n \n\na = 3200 is not less than 3200, so we print s = `pink`.\n\n* * *"}, {"input": "3199\n pink", "output": "red\n \n\na = 3199 is less than 3200, so we print `red`.\n\n* * *"}, {"input": "4049\n red", "output": "red\n \n\na = 4049 is not less than 3200, so we print s = `red`."}] |
If a is not less than 3200, print s; if a is less than 3200, print `red`.
* * * | s675095605 | Wrong Answer | p02933 | Input is given from Standard Input in the following format:
a
s | def sol(a, s):
if a >= 3200:
return s
else:
return "red"
| Statement
You will be given an integer a and a string s consisting of lowercase English
letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a
is less than 3200. | [{"input": "3200\n pink", "output": "pink\n \n\na = 3200 is not less than 3200, so we print s = `pink`.\n\n* * *"}, {"input": "3199\n pink", "output": "red\n \n\na = 3199 is less than 3200, so we print `red`.\n\n* * *"}, {"input": "4049\n red", "output": "red\n \n\na = 4049 is not less than 3200, so we print s = `red`."}] |
Print the student numbers of the students in the order the students entered
the classroom.
* * * | s564174701 | Runtime Error | p02899 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_N | N = int(input())
K = list(map(int, input().split()))
M = dict(zip(range(1, N + 1), K))
M = sorted(M.items(), key=lambda x: x[1])
newM = []
for i in M:
newM.append(i[0])
print(+newM)
| Statement
Takahashi is a teacher responsible for a class of N students.
The students are given distinct student numbers from 1 to N.
Today, all the students entered the classroom at different times.
According to Takahashi's record, there were A_i students in the classroom when
student number i entered the classroom (including student number i).
From these records, reconstruct the order in which the students entered the
classroom. | [{"input": "3\n 2 3 1", "output": "3 1 2\n \n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\n* * *"}, {"input": "5\n 1 2 3 4 5", "output": "1 2 3 4 5\n \n\n* * *"}, {"input": "8\n 8 2 7 3 4 5 6 1", "output": "8 2 4 5 6 7 3 1"}] |
Print the student numbers of the students in the order the students entered
the classroom.
* * * | s637564209 | Accepted | p02899 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_N | n = int(input())
p_list = list(map(int, input().split()))
p_dict = {}
for i, p in enumerate(p_list):
p_dict[p] = i
res_list = []
for key in sorted(list(p_dict.keys())):
res_list.append(str(p_dict[key] + 1))
print(" ".join(res_list))
| Statement
Takahashi is a teacher responsible for a class of N students.
The students are given distinct student numbers from 1 to N.
Today, all the students entered the classroom at different times.
According to Takahashi's record, there were A_i students in the classroom when
student number i entered the classroom (including student number i).
From these records, reconstruct the order in which the students entered the
classroom. | [{"input": "3\n 2 3 1", "output": "3 1 2\n \n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\n* * *"}, {"input": "5\n 1 2 3 4 5", "output": "1 2 3 4 5\n \n\n* * *"}, {"input": "8\n 8 2 7 3 4 5 6 1", "output": "8 2 4 5 6 7 3 1"}] |
Print the student numbers of the students in the order the students entered
the classroom.
* * * | s317900806 | Accepted | p02899 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_N | n = int(input())
src = list(map(int, input().split()))
ma = {}
for i, s in enumerate(src):
ma[s - 1] = i + 1
print(*(list(ma.values())))
| Statement
Takahashi is a teacher responsible for a class of N students.
The students are given distinct student numbers from 1 to N.
Today, all the students entered the classroom at different times.
According to Takahashi's record, there were A_i students in the classroom when
student number i entered the classroom (including student number i).
From these records, reconstruct the order in which the students entered the
classroom. | [{"input": "3\n 2 3 1", "output": "3 1 2\n \n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\n* * *"}, {"input": "5\n 1 2 3 4 5", "output": "1 2 3 4 5\n \n\n* * *"}, {"input": "8\n 8 2 7 3 4 5 6 1", "output": "8 2 4 5 6 7 3 1"}] |
Print the student numbers of the students in the order the students entered
the classroom.
* * * | s379656265 | Wrong Answer | p02899 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_N | n = map(int, input())
arr = list(map(int, input().split(" ")))
print(list(map(lambda k: k + 1, sorted(range(len(arr)), key=lambda k: arr[k]))))
| Statement
Takahashi is a teacher responsible for a class of N students.
The students are given distinct student numbers from 1 to N.
Today, all the students entered the classroom at different times.
According to Takahashi's record, there were A_i students in the classroom when
student number i entered the classroom (including student number i).
From these records, reconstruct the order in which the students entered the
classroom. | [{"input": "3\n 2 3 1", "output": "3 1 2\n \n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\n* * *"}, {"input": "5\n 1 2 3 4 5", "output": "1 2 3 4 5\n \n\n* * *"}, {"input": "8\n 8 2 7 3 4 5 6 1", "output": "8 2 4 5 6 7 3 1"}] |
Print the student numbers of the students in the order the students entered
the classroom.
* * * | s383407157 | Accepted | p02899 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_N | # inputs
_N = int(input())
order_list = input().split(" ")
# 出席した順番に並べた生徒番号が入るlist
ordered_id_list = [None for i in range(0, _N)]
for i, v in enumerate(order_list):
_order = i + 1
_id = int(v)
ordered_id_list[(_id - 1)] = str(_order)
# 出力
print(" ".join(ordered_id_list))
| Statement
Takahashi is a teacher responsible for a class of N students.
The students are given distinct student numbers from 1 to N.
Today, all the students entered the classroom at different times.
According to Takahashi's record, there were A_i students in the classroom when
student number i entered the classroom (including student number i).
From these records, reconstruct the order in which the students entered the
classroom. | [{"input": "3\n 2 3 1", "output": "3 1 2\n \n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\n* * *"}, {"input": "5\n 1 2 3 4 5", "output": "1 2 3 4 5\n \n\n* * *"}, {"input": "8\n 8 2 7 3 4 5 6 1", "output": "8 2 4 5 6 7 3 1"}] |
Print the student numbers of the students in the order the students entered
the classroom.
* * * | s955373034 | Wrong Answer | p02899 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_N | n = int(input())
a = map(int, input().split())
h = list(a)
b = range(n)
c = list(b)
for x in c:
c[x] = x + 1
for y in range(n):
if h[y] == y + 1:
None
else:
z = h[y] - 1
c[y] = c[z]
c[z] = y + 1
h[z] = z + 1
for x in range(n):
c[x] = str(c[x])
print(" ".join(c))
| Statement
Takahashi is a teacher responsible for a class of N students.
The students are given distinct student numbers from 1 to N.
Today, all the students entered the classroom at different times.
According to Takahashi's record, there were A_i students in the classroom when
student number i entered the classroom (including student number i).
From these records, reconstruct the order in which the students entered the
classroom. | [{"input": "3\n 2 3 1", "output": "3 1 2\n \n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\n* * *"}, {"input": "5\n 1 2 3 4 5", "output": "1 2 3 4 5\n \n\n* * *"}, {"input": "8\n 8 2 7 3 4 5 6 1", "output": "8 2 4 5 6 7 3 1"}] |
Print the student numbers of the students in the order the students entered
the classroom.
* * * | s792534502 | Accepted | p02899 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_N | n, a = open(0)
a = a.split()
print(*sorted(range(1, int(n) + 1), key=lambda x: int(a[x - 1])))
| Statement
Takahashi is a teacher responsible for a class of N students.
The students are given distinct student numbers from 1 to N.
Today, all the students entered the classroom at different times.
According to Takahashi's record, there were A_i students in the classroom when
student number i entered the classroom (including student number i).
From these records, reconstruct the order in which the students entered the
classroom. | [{"input": "3\n 2 3 1", "output": "3 1 2\n \n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\n* * *"}, {"input": "5\n 1 2 3 4 5", "output": "1 2 3 4 5\n \n\n* * *"}, {"input": "8\n 8 2 7 3 4 5 6 1", "output": "8 2 4 5 6 7 3 1"}] |
Print the student numbers of the students in the order the students entered
the classroom.
* * * | s720938977 | Accepted | p02899 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_N | _, *a = map(int, open(0).read().split())
print(*[i for i, __ in sorted(enumerate(a, 1), key=lambda l: l[1])])
| Statement
Takahashi is a teacher responsible for a class of N students.
The students are given distinct student numbers from 1 to N.
Today, all the students entered the classroom at different times.
According to Takahashi's record, there were A_i students in the classroom when
student number i entered the classroom (including student number i).
From these records, reconstruct the order in which the students entered the
classroom. | [{"input": "3\n 2 3 1", "output": "3 1 2\n \n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\n* * *"}, {"input": "5\n 1 2 3 4 5", "output": "1 2 3 4 5\n \n\n* * *"}, {"input": "8\n 8 2 7 3 4 5 6 1", "output": "8 2 4 5 6 7 3 1"}] |
Print the student numbers of the students in the order the students entered
the classroom.
* * * | s161477967 | Accepted | p02899 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_N | b = int(input())
a = [int(a) for a in input().split()]
aa = []
for ii in range(b):
aa.append(0)
for i in range(b):
az = a[i]
ax = i + 1
aa[az - 1] = ax
print((" ".join(repr(e) for e in aa)))
| Statement
Takahashi is a teacher responsible for a class of N students.
The students are given distinct student numbers from 1 to N.
Today, all the students entered the classroom at different times.
According to Takahashi's record, there were A_i students in the classroom when
student number i entered the classroom (including student number i).
From these records, reconstruct the order in which the students entered the
classroom. | [{"input": "3\n 2 3 1", "output": "3 1 2\n \n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\n* * *"}, {"input": "5\n 1 2 3 4 5", "output": "1 2 3 4 5\n \n\n* * *"}, {"input": "8\n 8 2 7 3 4 5 6 1", "output": "8 2 4 5 6 7 3 1"}] |
Print the student numbers of the students in the order the students entered
the classroom.
* * * | s988336287 | Runtime Error | p02899 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_N | import unittest
class TestC(unittest.TestCase):
def test_1(self):
self.assertEqual(think([2, 3, 1]), [3, 1, 2])
def test_2(self):
self.assertEqual(think([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])
def test_3(self):
self.assertEqual(think([8, 2, 7, 3, 4, 5, 6, 1]), [8, 2, 4, 5, 6, 7, 3, 1])
def solve():
a = read()
result = solve(a)
write(result)
def read():
n = read_int(1)[0]
return read_int(n)
def read_int(n):
return list(map(lambda x: int(x), read_line().split(" ")))[:n]
def read_float(n):
return list(map(lambda x: float(x), read_line().split(" ")))[:n]
def read_line(n=0):
if n == 0:
return input().rstrip()
else:
return input().rstrip()[:n]
def think(a):
list_of_index_and_a = []
for index, e in enumerate(a):
list_of_index_and_a.append((index + 1, e))
list_of_index_and_a.sort(key=lambda x: x[1])
return [x[0] for x in list_of_index_and_a]
def write(result):
print(result)
if __name__ == "__main__":
# unittest.main()
solve()
| Statement
Takahashi is a teacher responsible for a class of N students.
The students are given distinct student numbers from 1 to N.
Today, all the students entered the classroom at different times.
According to Takahashi's record, there were A_i students in the classroom when
student number i entered the classroom (including student number i).
From these records, reconstruct the order in which the students entered the
classroom. | [{"input": "3\n 2 3 1", "output": "3 1 2\n \n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\n* * *"}, {"input": "5\n 1 2 3 4 5", "output": "1 2 3 4 5\n \n\n* * *"}, {"input": "8\n 8 2 7 3 4 5 6 1", "output": "8 2 4 5 6 7 3 1"}] |
Print the student numbers of the students in the order the students entered
the classroom.
* * * | s104026270 | Accepted | p02899 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_N | n = int(input())
numbers = input().rstrip().split(" ")
order = [0 for i in range(n)]
for i, number in enumerate(numbers):
order[int(number) - 1] = i + 1
# print(order)
for num in order:
print(num, end=" ")
| Statement
Takahashi is a teacher responsible for a class of N students.
The students are given distinct student numbers from 1 to N.
Today, all the students entered the classroom at different times.
According to Takahashi's record, there were A_i students in the classroom when
student number i entered the classroom (including student number i).
From these records, reconstruct the order in which the students entered the
classroom. | [{"input": "3\n 2 3 1", "output": "3 1 2\n \n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\n* * *"}, {"input": "5\n 1 2 3 4 5", "output": "1 2 3 4 5\n \n\n* * *"}, {"input": "8\n 8 2 7 3 4 5 6 1", "output": "8 2 4 5 6 7 3 1"}] |
Print the student numbers of the students in the order the students entered
the classroom.
* * * | s483050777 | Wrong Answer | p02899 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_N | stu_num = int(input())
num_list = input().split(" ")
num_tuple_list = []
for i in range(stu_num):
num_tuple_list.append((num_list[i], i + 1))
def tup0(tup):
return tup[0]
num_tuple_list.sort(key=tup0)
ans_list = list(map(lambda x: x[1], num_tuple_list))
for i in range(stu_num):
print(ans_list[i], end="")
if i != stu_num - 1:
print(" ")
| Statement
Takahashi is a teacher responsible for a class of N students.
The students are given distinct student numbers from 1 to N.
Today, all the students entered the classroom at different times.
According to Takahashi's record, there were A_i students in the classroom when
student number i entered the classroom (including student number i).
From these records, reconstruct the order in which the students entered the
classroom. | [{"input": "3\n 2 3 1", "output": "3 1 2\n \n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\n* * *"}, {"input": "5\n 1 2 3 4 5", "output": "1 2 3 4 5\n \n\n* * *"}, {"input": "8\n 8 2 7 3 4 5 6 1", "output": "8 2 4 5 6 7 3 1"}] |
Print the student numbers of the students in the order the students entered
the classroom.
* * * | s880385821 | Wrong Answer | p02899 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_N | N = range(int(input()))
A = {str(n + 1): a for n, a in zip(N, input().split())}
print(" ".join(sorted(A.items(), key=lambda x: x[1])[i][0] for i in N))
| Statement
Takahashi is a teacher responsible for a class of N students.
The students are given distinct student numbers from 1 to N.
Today, all the students entered the classroom at different times.
According to Takahashi's record, there were A_i students in the classroom when
student number i entered the classroom (including student number i).
From these records, reconstruct the order in which the students entered the
classroom. | [{"input": "3\n 2 3 1", "output": "3 1 2\n \n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\n* * *"}, {"input": "5\n 1 2 3 4 5", "output": "1 2 3 4 5\n \n\n* * *"}, {"input": "8\n 8 2 7 3 4 5 6 1", "output": "8 2 4 5 6 7 3 1"}] |
Print the student numbers of the students in the order the students entered
the classroom.
* * * | s342886217 | Wrong Answer | p02899 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_N | ############################
N = int(input())
while 1 > N or 10**5 < N:
N = int(input())
else:
pass
############################
INPUT_2 = list(map(int, input().split()))
ERORR_COUNT_1 = 0
for i in INPUT_2:
if 1 <= i <= N:
pass
else:
ERORR_COUNT_1 += 1
ERORR_COUNT_2 = 0
for i in INPUT_2:
if INPUT_2.count(i) >= 2:
ERORR_COUNT_2 += 1
else:
pass
while len(INPUT_2) != N or ERORR_COUNT_1 > 0 or ERORR_COUNT_2 > 0:
INPUT_2 = list(map(int, input().split()))
ERORR_COUNT_1 = 0
for i in INPUT_2:
if 1 <= i <= N:
pass
else:
ERORR_COUNT_1 += 1
ERORR_COUNT_2 = 0
for i in INPUT_2:
if INPUT_2.count(i) >= 2:
ERORR_COUNT_2 += 1
else:
pass
else:
pass
############################
dic = {}
for i, num in enumerate(INPUT_2):
dic[num - 1] = i + 1
dic2 = sorted(dic.items())
answer = []
for i in range(len(INPUT_2)):
answer.append(dic2[i][1])
print(answer)
| Statement
Takahashi is a teacher responsible for a class of N students.
The students are given distinct student numbers from 1 to N.
Today, all the students entered the classroom at different times.
According to Takahashi's record, there were A_i students in the classroom when
student number i entered the classroom (including student number i).
From these records, reconstruct the order in which the students entered the
classroom. | [{"input": "3\n 2 3 1", "output": "3 1 2\n \n\nFirst, student number 3 entered the classroom.\n\nThen, student number 1 entered the classroom.\n\nFinally, student number 2 entered the classroom.\n\n* * *"}, {"input": "5\n 1 2 3 4 5", "output": "1 2 3 4 5\n \n\n* * *"}, {"input": "8\n 8 2 7 3 4 5 6 1", "output": "8 2 4 5 6 7 3 1"}] |
If the state where p_i=i for every i can be reached by performing the
operation, print `Yes`; otherwise, print `No`.
* * * | s628672096 | Wrong Answer | p03271 | Input is given from Standard Input in the following format:
N
p_1
:
p_N | print("No")
a = 114514
a = 114514
a = 114514
a = 114514
a = 114514
a = 114514
a = 114514
a = 114514
a = 114514
a = 114514
a = 114514
a = 114514
a = 114514
a = 114514
a = 114514
| Statement
You are given a permutation of 1,2,...,N: p_1,p_2,...,p_N. Determine if the
state where p_i=i for every i can be reached by performing the following
operation any number of times:
* Choose three elements p_{i-1},p_{i},p_{i+1} (2\leq i\leq N-1) such that p_{i-1}>p_{i}>p_{i+1} and reverse the order of these three. | [{"input": "5\n 5\n 2\n 1\n 4\n 3", "output": "Yes\n \n\nThe state where p_i=i for every i can be reached as follows:\n\n * Reverse the order of p_1,p_2,p_3. The sequence p becomes 1,2,5,4,3.\n * Reverse the order of p_3,p_4,p_5. The sequence p becomes 1,2,3,4,5.\n\n* * *"}, {"input": "4\n 3\n 2\n 4\n 1", "output": "No\n \n\n* * *"}, {"input": "7\n 3\n 2\n 1\n 6\n 5\n 4\n 7", "output": "Yes\n \n\n* * *"}, {"input": "6\n 5\n 3\n 4\n 1\n 2\n 6", "output": "No"}] |
If the state where p_i=i for every i can be reached by performing the
operation, print `Yes`; otherwise, print `No`.
* * * | s361143023 | Accepted | p03271 | Input is given from Standard Input in the following format:
N
p_1
:
p_N | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
P = [0] + list(map(int, read().split()))
# permutationになっている極小区間に分ける
intervals = []
left = 0
right = -1
for i, p in enumerate(P):
if right < p:
right = p
if i == right:
intervals.append((left, right))
left = i + 1
right = -1
def check(L, R):
if L == R:
return True
to_left = []
fixed = []
to_right = []
for i, p in enumerate(P[L : R + 1], L):
if i > p:
to_left.append(p)
elif i == p:
fixed.append(p)
else:
to_right.append(p)
if fixed != list(range(L + 1, R + 1, 2)):
return False
if any(x > y for x, y in zip(to_left, to_left[1:])):
return False
if any(x > y for x, y in zip(to_right, to_right[1:])):
return False
return True
answer = "Yes" if all(check(L, R) for L, R in intervals) else "No"
print(answer)
| Statement
You are given a permutation of 1,2,...,N: p_1,p_2,...,p_N. Determine if the
state where p_i=i for every i can be reached by performing the following
operation any number of times:
* Choose three elements p_{i-1},p_{i},p_{i+1} (2\leq i\leq N-1) such that p_{i-1}>p_{i}>p_{i+1} and reverse the order of these three. | [{"input": "5\n 5\n 2\n 1\n 4\n 3", "output": "Yes\n \n\nThe state where p_i=i for every i can be reached as follows:\n\n * Reverse the order of p_1,p_2,p_3. The sequence p becomes 1,2,5,4,3.\n * Reverse the order of p_3,p_4,p_5. The sequence p becomes 1,2,3,4,5.\n\n* * *"}, {"input": "4\n 3\n 2\n 4\n 1", "output": "No\n \n\n* * *"}, {"input": "7\n 3\n 2\n 1\n 6\n 5\n 4\n 7", "output": "Yes\n \n\n* * *"}, {"input": "6\n 5\n 3\n 4\n 1\n 2\n 6", "output": "No"}] |
If the state where p_i=i for every i can be reached by performing the
operation, print `Yes`; otherwise, print `No`.
* * * | s307641067 | Runtime Error | p03271 | Input is given from Standard Input in the following format:
N
p_1
:
p_N | #include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main()
{
int n;
cin>>n;
int p[300030];
for(int i=0; i<n; i++){
cin>>p[i];
p[i]--;
}
for(int i=0; i<n; i++){
if((p[i]&1)!=(i&1)){
cout<<"No"<<endl;
return 0;
}
}
set<int> st[2];
for(int i=0; i<n; i++) st[i&1].insert(i);
int x[2]={}, y[2]={};
for(int i=0; i<n; i++){
int a=*st[i&1].begin();
if(p[i]==a){
st[i&1].erase(st[i&1].begin());
continue;
}
if(p[i]<x[i&1]){
cout<<"No"<<endl;
return 0;
}
st[i&1].erase(p[i]);
x[(i&1)^1]=max(x[(i&1)^1], p[i]+3);
x[i&1]=max(x[i&1], p[i]+2);
y[(i&1)^1]=max(y[(i&1)^1], p[i]+1);
}
cout<<"Yes"<<endl;
return 0;
}
| Statement
You are given a permutation of 1,2,...,N: p_1,p_2,...,p_N. Determine if the
state where p_i=i for every i can be reached by performing the following
operation any number of times:
* Choose three elements p_{i-1},p_{i},p_{i+1} (2\leq i\leq N-1) such that p_{i-1}>p_{i}>p_{i+1} and reverse the order of these three. | [{"input": "5\n 5\n 2\n 1\n 4\n 3", "output": "Yes\n \n\nThe state where p_i=i for every i can be reached as follows:\n\n * Reverse the order of p_1,p_2,p_3. The sequence p becomes 1,2,5,4,3.\n * Reverse the order of p_3,p_4,p_5. The sequence p becomes 1,2,3,4,5.\n\n* * *"}, {"input": "4\n 3\n 2\n 4\n 1", "output": "No\n \n\n* * *"}, {"input": "7\n 3\n 2\n 1\n 6\n 5\n 4\n 7", "output": "Yes\n \n\n* * *"}, {"input": "6\n 5\n 3\n 4\n 1\n 2\n 6", "output": "No"}] |
If the state where p_i=i for every i can be reached by performing the
operation, print `Yes`; otherwise, print `No`.
* * * | s856628918 | Runtime Error | p03271 | Input is given from Standard Input in the following format:
N
p_1
:
p_N | N = int(input())
ret = "Yes"
isOdd = 1
for __ in range(N):
if int(input())%2 != isOdd
ret = "No"
isOdd = 1 - isOdd
print(ret) | Statement
You are given a permutation of 1,2,...,N: p_1,p_2,...,p_N. Determine if the
state where p_i=i for every i can be reached by performing the following
operation any number of times:
* Choose three elements p_{i-1},p_{i},p_{i+1} (2\leq i\leq N-1) such that p_{i-1}>p_{i}>p_{i+1} and reverse the order of these three. | [{"input": "5\n 5\n 2\n 1\n 4\n 3", "output": "Yes\n \n\nThe state where p_i=i for every i can be reached as follows:\n\n * Reverse the order of p_1,p_2,p_3. The sequence p becomes 1,2,5,4,3.\n * Reverse the order of p_3,p_4,p_5. The sequence p becomes 1,2,3,4,5.\n\n* * *"}, {"input": "4\n 3\n 2\n 4\n 1", "output": "No\n \n\n* * *"}, {"input": "7\n 3\n 2\n 1\n 6\n 5\n 4\n 7", "output": "Yes\n \n\n* * *"}, {"input": "6\n 5\n 3\n 4\n 1\n 2\n 6", "output": "No"}] |
If the state where p_i=i for every i can be reached by performing the
operation, print `Yes`; otherwise, print `No`.
* * * | s643039101 | Wrong Answer | p03271 | Input is given from Standard Input in the following format:
N
p_1
:
p_N | import sys
N = int(input())
p = [int(input()) for i in range(N)]
s = list(range(1, N + 1))
i = 1
while i < N:
x = p.index(i)
# print(x)
if i == x + 1:
i += 1
continue
elif x < i - 1:
break
if (x - i + 1) % 2 != 0:
break
# print(s,i,x)
for j in range(i - 1, x, 2):
s[j], s[j + 2] = s[j + 2], s[j]
i = x + 2
# print(s,i)
if s == p:
print("Yes")
sys.exit()
# print(s)
s = list(range(1, N + 1))
i = N
while i > 0:
x = p.index(i)
if i == x + 1:
i -= 1
continue
elif x > i - 1:
break
if (x - i - 1) % 2 != 0:
break
# print(s,i,x)
for j in range(i - 1, x, -2):
s[j], s[j - 2] = s[j - 2], s[j]
i = x
# print(s,i)
if s == p:
print("Yes")
sys.exit()
else:
print("No")
| Statement
You are given a permutation of 1,2,...,N: p_1,p_2,...,p_N. Determine if the
state where p_i=i for every i can be reached by performing the following
operation any number of times:
* Choose three elements p_{i-1},p_{i},p_{i+1} (2\leq i\leq N-1) such that p_{i-1}>p_{i}>p_{i+1} and reverse the order of these three. | [{"input": "5\n 5\n 2\n 1\n 4\n 3", "output": "Yes\n \n\nThe state where p_i=i for every i can be reached as follows:\n\n * Reverse the order of p_1,p_2,p_3. The sequence p becomes 1,2,5,4,3.\n * Reverse the order of p_3,p_4,p_5. The sequence p becomes 1,2,3,4,5.\n\n* * *"}, {"input": "4\n 3\n 2\n 4\n 1", "output": "No\n \n\n* * *"}, {"input": "7\n 3\n 2\n 1\n 6\n 5\n 4\n 7", "output": "Yes\n \n\n* * *"}, {"input": "6\n 5\n 3\n 4\n 1\n 2\n 6", "output": "No"}] |
If no permutation satisfies the condition, print `-1`.
Otherwise, print a permutation satisfying the condition, with space in
between. If there are multiple solutions, you can print any of them.
* * * | s198423000 | Runtime Error | p02749 | Input is given from Standard Input in the following format:
N
a_1 b_1
a_2 b_2
\vdots
a_{N-1} b_{N-1} | import sys
input = sys.stdin.readline
n = int(input())
ab = [tuple(map(int, input().split())) for _ in range(n - 1)]
edges = {}
for i in range(1, n + 1):
edges[i] = set()
for tmp in ab:
a, b = tmp
edges[a].add(b)
edges[b].add(a)
group = [[], []]
g_flag = 0
next = {1}
while len(next) > 0:
tmp = list(next)
next = set()
for i in tmp:
group[g_flag].append(i)
for j in edges[i]:
next.add(j)
edges[j].remove(i)
g_flag = 1 - g_flag
even_n = len(group[0])
odd_n = len(group[1])
ans = [0] * (n + 1)
if (even_n > n // 3) & (odd_n > n // 3):
g1 = group[0][: (n + 2) // 3]
g2 = group[1][: (n + 1) // 3]
g0 = group[0][(n + 2) // 3 :] + group[1][(n + 1) // 3 :]
elif even_n <= n // 3:
g0 = group[0].extend(group[1][: n // 3 - even_n])
g1 = group[1][n // 3 - even_n : (n // 3 - even_n) + (n + 2) // 3]
g2 = group[1][(n // 3 - even_n) + (n + 2) // 3 :]
else:
g0 = group[1].extend(group[0][: n // 3 - odd_n])
g1 = group[1][n // 3 - odd_n : (n // 3 - odd_n) + (n + 2) // 3]
g2 = group[1][(n // 3 - odd_n) + (n + 2) // 3 :]
# print(group)
# print(g0)
# print(g1)
# print(g2)
for i in range((n + 2) // 3):
ans[g1[i]] = i * 3 + 1
for i in range((n + 1) // 3):
ans[g2[i]] = i * 3 + 2
for i, val in enumerate(g0):
ans[val] = (i + 1) * 3
print(" ".join(map(str, ans[1:])))
| Statement
We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th
edge connects Vertex a_i and Vertex b_i.
Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots ,
p_N of integers from 1 to N satisfying the following condition:
* For every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.
Here the distance between Vertex i and Vertex j is the number of edges
contained in the shortest path from Vertex i to Vertex j.
Help Takahashi by finding a permutation that satisfies the condition. | [{"input": "5\n 1 2\n 1 3\n 3 4\n 3 5", "output": "1 2 5 4 3 \n \n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\n * p_2 + p_4 = 6\n * p_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition."}] |
If no permutation satisfies the condition, print `-1`.
Otherwise, print a permutation satisfying the condition, with space in
between. If there are multiple solutions, you can print any of them.
* * * | s291355453 | Accepted | p02749 | Input is given from Standard Input in the following format:
N
a_1 b_1
a_2 b_2
\vdots
a_{N-1} b_{N-1} | n, *L = map(int, open(0).read().split())
g = [[] for _ in range(n)]
for a, b in zip(*[iter(L)] * 2):
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
tr = [-1] * n
q = [0]
tr[0] = 0
while q:
cu = q.pop()
for nx in g[cu]:
if tr[nx] < 0:
tr[nx] = 1 - tr[cu]
q.append(nx)
lab = [-1] * n
z, o = map(tr.count, (0, 1))
if z <= n // 3 or o <= n // 3:
f = 0 if z <= n // 3 else 1
onetwo = 1
thr = 3
for i, x in enumerate(tr):
if x == f:
lab[i] = thr
thr += 3
for i, x in enumerate(tr):
if x == 1 - f:
if thr <= n:
lab[i] = thr
thr += 3
else:
lab[i] = onetwo
onetwo += 1 if onetwo % 3 == 1 else 2
else:
one = 1
for i, x in enumerate(tr):
if x == 0:
lab[i] = one
one += 3
if one > n:
break
two = 2
for i, x in enumerate(tr):
if x == 1:
lab[i] = two
two += 3
if two > n:
break
thr = 3
for i in range(n):
if lab[i] < 0:
lab[i] = thr
thr += 3
print(*lab)
| Statement
We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th
edge connects Vertex a_i and Vertex b_i.
Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots ,
p_N of integers from 1 to N satisfying the following condition:
* For every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.
Here the distance between Vertex i and Vertex j is the number of edges
contained in the shortest path from Vertex i to Vertex j.
Help Takahashi by finding a permutation that satisfies the condition. | [{"input": "5\n 1 2\n 1 3\n 3 4\n 3 5", "output": "1 2 5 4 3 \n \n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\n * p_2 + p_4 = 6\n * p_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition."}] |
If no permutation satisfies the condition, print `-1`.
Otherwise, print a permutation satisfying the condition, with space in
between. If there are multiple solutions, you can print any of them.
* * * | s716793896 | Wrong Answer | p02749 | Input is given from Standard Input in the following format:
N
a_1 b_1
a_2 b_2
\vdots
a_{N-1} b_{N-1} | print("1 3 5 4 1")
| Statement
We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th
edge connects Vertex a_i and Vertex b_i.
Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots ,
p_N of integers from 1 to N satisfying the following condition:
* For every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.
Here the distance between Vertex i and Vertex j is the number of edges
contained in the shortest path from Vertex i to Vertex j.
Help Takahashi by finding a permutation that satisfies the condition. | [{"input": "5\n 1 2\n 1 3\n 3 4\n 3 5", "output": "1 2 5 4 3 \n \n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\n * p_2 + p_4 = 6\n * p_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition."}] |
If no permutation satisfies the condition, print `-1`.
Otherwise, print a permutation satisfying the condition, with space in
between. If there are multiple solutions, you can print any of them.
* * * | s897789191 | Wrong Answer | p02749 | Input is given from Standard Input in the following format:
N
a_1 b_1
a_2 b_2
\vdots
a_{N-1} b_{N-1} | print("1 2 5 4 3")
| Statement
We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th
edge connects Vertex a_i and Vertex b_i.
Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots ,
p_N of integers from 1 to N satisfying the following condition:
* For every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.
Here the distance between Vertex i and Vertex j is the number of edges
contained in the shortest path from Vertex i to Vertex j.
Help Takahashi by finding a permutation that satisfies the condition. | [{"input": "5\n 1 2\n 1 3\n 3 4\n 3 5", "output": "1 2 5 4 3 \n \n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\n * p_2 + p_4 = 6\n * p_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition."}] |
If no permutation satisfies the condition, print `-1`.
Otherwise, print a permutation satisfying the condition, with space in
between. If there are multiple solutions, you can print any of them.
* * * | s520403785 | Wrong Answer | p02749 | Input is given from Standard Input in the following format:
N
a_1 b_1
a_2 b_2
\vdots
a_{N-1} b_{N-1} | print(*list(range(1, int(input()) + 1)))
| Statement
We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th
edge connects Vertex a_i and Vertex b_i.
Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots ,
p_N of integers from 1 to N satisfying the following condition:
* For every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.
Here the distance between Vertex i and Vertex j is the number of edges
contained in the shortest path from Vertex i to Vertex j.
Help Takahashi by finding a permutation that satisfies the condition. | [{"input": "5\n 1 2\n 1 3\n 3 4\n 3 5", "output": "1 2 5 4 3 \n \n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\n * p_2 + p_4 = 6\n * p_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition."}] |
If no permutation satisfies the condition, print `-1`.
Otherwise, print a permutation satisfying the condition, with space in
between. If there are multiple solutions, you can print any of them.
* * * | s722360651 | Accepted | p02749 | Input is given from Standard Input in the following format:
N
a_1 b_1
a_2 b_2
\vdots
a_{N-1} b_{N-1} | import sys
def part(s, links):
grp = [set(), set()]
q = [(s, -1, 0)]
while q:
v, p, g = q.pop()
grp[g].add(v)
for u in links[v]:
if u == p:
continue
q.append((u, v, g ^ 1))
return grp
def solve(n, links):
grp = part(0, links)
can = [[], [], []]
for i in range(1, n + 1):
can[i % 3].append(i)
# print(grp)
# print(can)
if len(grp[0]) > len(grp[1]):
grp[0], grp[1] = grp[1], grp[0]
if len(can[1]) > len(can[2]):
can[1], can[2] = can[2], can[1]
ans = [0] * n
if len(grp[0]) <= len(can[0]):
for i, v in enumerate(grp[0]):
ans[v] = can[0].pop()
can = can[0] + can[1] + can[2]
for i, v in enumerate(grp[1]):
ans[v] = can.pop()
return ans
for i, v in enumerate(grp[0]):
if can[1]:
ans[v] = can[1].pop()
else:
ans[v] = can[0].pop()
for i, v in enumerate(grp[1]):
if can[2]:
ans[v] = can[2].pop()
else:
ans[v] = can[0].pop()
return ans
n = int(input())
links = [set() for _ in range(n)]
for line in sys.stdin:
a, b = map(int, line.split())
a -= 1
b -= 1
links[a].add(b)
links[b].add(a)
print(*solve(n, links))
| Statement
We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th
edge connects Vertex a_i and Vertex b_i.
Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots ,
p_N of integers from 1 to N satisfying the following condition:
* For every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.
Here the distance between Vertex i and Vertex j is the number of edges
contained in the shortest path from Vertex i to Vertex j.
Help Takahashi by finding a permutation that satisfies the condition. | [{"input": "5\n 1 2\n 1 3\n 3 4\n 3 5", "output": "1 2 5 4 3 \n \n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\n * p_2 + p_4 = 6\n * p_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition."}] |
If no permutation satisfies the condition, print `-1`.
Otherwise, print a permutation satisfying the condition, with space in
between. If there are multiple solutions, you can print any of them.
* * * | s248733759 | Runtime Error | p02749 | Input is given from Standard Input in the following format:
N
a_1 b_1
a_2 b_2
\vdots
a_{N-1} b_{N-1} | g = {}
n = int(input())
m = [-1] * n
def dfs(graph, node, height):
global m
global zeros
global ones
m[node - 1] = height
if height == 0:
zeros += 1
if height == 1:
ones += 1
for n in graph[node]:
if m[n - 1] == -1:
dfs(graph, n, 1 - height)
zeros = 0
ones = 0
for i in range(n - 1):
a, b = map(int, input().split())
if not a in g:
g[a] = [b]
else:
g[a].append(b)
if not b in g:
g[b] = [a]
else:
g[b].append(a)
dfs(g, 1, 0)
print(1)
| Statement
We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th
edge connects Vertex a_i and Vertex b_i.
Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots ,
p_N of integers from 1 to N satisfying the following condition:
* For every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.
Here the distance between Vertex i and Vertex j is the number of edges
contained in the shortest path from Vertex i to Vertex j.
Help Takahashi by finding a permutation that satisfies the condition. | [{"input": "5\n 1 2\n 1 3\n 3 4\n 3 5", "output": "1 2 5 4 3 \n \n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\n * p_2 + p_4 = 6\n * p_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition."}] |
If no permutation satisfies the condition, print `-1`.
Otherwise, print a permutation satisfying the condition, with space in
between. If there are multiple solutions, you can print any of them.
* * * | s711711680 | Wrong Answer | p02749 | Input is given from Standard Input in the following format:
N
a_1 b_1
a_2 b_2
\vdots
a_{N-1} b_{N-1} | import sys, collections as cl, bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9 + 7
Max = sys.maxsize
def l(): # intのlist
return list(map(int, input().split()))
def m(): # 複数文字
return map(int, input().split())
def onem(): # Nとかの取得
return int(input())
def s(x): # 圧縮
a = []
aa = x[0]
su = 1
for i in range(len(x) - 1):
if aa != x[i + 1]:
a.append([aa, su])
aa = x[i + 1]
su = 1
else:
su += 1
a.append([aa, su])
return a
def jo(x): # listをスペースごとに分ける
return " ".join(map(str, x))
def max2(x): # 他のときもどうように作成可能
return max(map(max, x))
def In(x, a): # aがリスト(sorted)
k = bs.bisect_left(a, x)
if k != len(a) and a[k] == x:
return True
else:
return False
"""
def nibu(x,n,r):
ll = 0
rr = r
while True:
mid = (ll+rr)//2
if rr == mid:
return ll
if (ここに評価入れる):
rr = mid
else:
ll = mid+1
"""
import collections
import itertools
import operator
class UnionFind:
def __init__(self, x):
class KeyDict(dict):
def __missing__(self, key):
self[key] = key
return key
self.parent = KeyDict()
self.rank = collections.defaultdict(int)
self.size = collections.defaultdict(lambda: 1)
if x is not None:
for elem in range(x + 1):
_, _, _ = self.parent[elem], self.rank[elem], self.size[elem]
def find(self, x):
if self.parent[x] == x:
return x
else:
self.parent[x] = self.find(self.parent[x])
return self.parent[x]
def unite(self, x, y):
x = self.find(x)
y = self.find(y)
if not self.are_same(x, y):
xx = self.size[x]
yy = self.size[y]
if self.rank[x] < self.rank[y]:
self.parent[x] = y
self.size[y] += xx
else:
self.parent[y] = x
self.size[x] += yy
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
def Size(self, x):
return self.size[self.find(x)]
def are_same(self, x, y):
"""print(x,y,self.find(x),self.find(y),self.find(x) == self.find(y))"""
return self.find(x) == self.find(y)
def grouper(self):
roots = [(x, self.find(x_par)) for x, x_par in self.parent.items()]
root = operator.itemgetter(1)
for _, group in itertools.groupby(sorted(roots, key=root), root):
yield [x for x, _ in group]
n = onem()
tr = [[] for i in range(n)]
po = [[] for i in range(n)]
for i in range(n - 1):
a, b = m()
tr[a - 1].append(b - 1)
tr[b - 1].append(a - 1)
de = cl.deque([[0, -1, -1]])
while de:
data = de.popleft()
for i in range(len(tr[data[0]])):
if tr[data[0]][i] != data[1]:
de.append([tr[data[0]][i], data[0], data[1]])
if data[1] != -1:
for j in range(len(tr[data[1]])):
if tr[data[1]][j] != data[0]:
po[tr[data[0]][i]].append(tr[data[1]][j])
po[tr[data[1]][j]].append(tr[data[0]][i])
if data[2] != -1:
po[data[2]].append(tr[data[0]][i])
po[tr[data[0]][i]].append(data[2])
co = [[len(po[i]), i] for i in range(n)]
co.sort(reverse=True)
p0 = 0
p1 = 0
p2 = 0
num = [0 for i in range(n)]
for i in range(n):
ppp = co[i][1]
if (p0 + 1) * 3 < n:
num[ppp] = (p0 + 1) * 3
p0 += 1
else:
break
co = 1
for i in range(n):
if num[i] == 0:
num[i] = co
co += 1
if co % 3 == 0 and (p0 + 1) * 3 == co:
continue
elif co % 3 == 0:
co += 1
print(jo(num))
| Statement
We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th
edge connects Vertex a_i and Vertex b_i.
Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots ,
p_N of integers from 1 to N satisfying the following condition:
* For every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.
Here the distance between Vertex i and Vertex j is the number of edges
contained in the shortest path from Vertex i to Vertex j.
Help Takahashi by finding a permutation that satisfies the condition. | [{"input": "5\n 1 2\n 1 3\n 3 4\n 3 5", "output": "1 2 5 4 3 \n \n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\n * p_2 + p_4 = 6\n * p_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition."}] |
If no permutation satisfies the condition, print `-1`.
Otherwise, print a permutation satisfying the condition, with space in
between. If there are multiple solutions, you can print any of them.
* * * | s151130326 | Wrong Answer | p02749 | Input is given from Standard Input in the following format:
N
a_1 b_1
a_2 b_2
\vdots
a_{N-1} b_{N-1} | from collections import deque
import sys
import copy
sys.setrecursionlimit(10**6)
def dfs(tree, cursor, parent):
rtn = deque()
for child in tree[cursor]:
notme = copy.copy(tree[cursor])
notme.remove(child)
for mago in tree[child]:
if parent != 0:
rtn.append((parent, mago))
rtn += deque([(c2, mago) for c2 in notme])
rtn += dfs(tree, child, cursor)
return rtn
N = int(input())
T = [deque() for _ in range(N + 1)]
seen = [False] * (N + 1)
a, b = map(int, input().split())
a, b = min(a, b), max(a, b)
T[a].append(b)
seen[a] = True
seen[b] = True
for _ in range(N - 2):
a, b = map(int, input().split())
a, b = min(a, b), max(a, b)
if not seen[a]:
T[b].append(a)
else:
T[a].append(b)
seen[a] = True
seen[b] = True
dist3s = dfs(T, 1, 0)
print(dist3s)
| Statement
We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th
edge connects Vertex a_i and Vertex b_i.
Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots ,
p_N of integers from 1 to N satisfying the following condition:
* For every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.
Here the distance between Vertex i and Vertex j is the number of edges
contained in the shortest path from Vertex i to Vertex j.
Help Takahashi by finding a permutation that satisfies the condition. | [{"input": "5\n 1 2\n 1 3\n 3 4\n 3 5", "output": "1 2 5 4 3 \n \n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\n * p_2 + p_4 = 6\n * p_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition."}] |
If no permutation satisfies the condition, print `-1`.
Otherwise, print a permutation satisfying the condition, with space in
between. If there are multiple solutions, you can print any of them.
* * * | s567682469 | Runtime Error | p02749 | Input is given from Standard Input in the following format:
N
a_1 b_1
a_2 b_2
\vdots
a_{N-1} b_{N-1} | N = int(input())
a = [None] * N
b = [None] * N
ps = {}
cs = {}
for i in range(N - 1):
a[i], b[i] = [int(n) for n in input().split()]
if a[i] < b[i]:
ps[b[i]] = a[i]
if a[i] not in cs:
cs[a[i]] = []
cs[a[i]].append(b[i])
else:
ps[a[i]] = b[i]
if b[i] not in cs:
cs[b[i]] = []
cs[b[i]].append(a[i])
dd = {}
def d(i, j):
if i < j:
p = i
c = j
elif i == j:
return 0
else:
p = j
c = i
if (p, c) in dd:
return dd[(p, c)]
dd[(p, c)] = 1 + d(ps[c], p)
return dd[(p, c)]
p = list(range(1, N + 1))
for i in range(N - 1):
for j in range(i + 1, N):
if d(i + 1, j + 1) == 3:
if (p[i] + p[j]) % 3 != 0 and (p[i] * p[j]) % 3 != 0:
e = p[i]
p[i] = p[i + 1]
p[i + 1] = e
p = map(lambda a: str(a), p)
print(" ".join(p))
| Statement
We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th
edge connects Vertex a_i and Vertex b_i.
Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots ,
p_N of integers from 1 to N satisfying the following condition:
* For every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.
Here the distance between Vertex i and Vertex j is the number of edges
contained in the shortest path from Vertex i to Vertex j.
Help Takahashi by finding a permutation that satisfies the condition. | [{"input": "5\n 1 2\n 1 3\n 3 4\n 3 5", "output": "1 2 5 4 3 \n \n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\n * p_2 + p_4 = 6\n * p_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition."}] |
If no permutation satisfies the condition, print `-1`.
Otherwise, print a permutation satisfying the condition, with space in
between. If there are multiple solutions, you can print any of them.
* * * | s669792358 | Wrong Answer | p02749 | Input is given from Standard Input in the following format:
N
a_1 b_1
a_2 b_2
\vdots
a_{N-1} b_{N-1} | from sys import exit
import sys
sys.setrecursionlimit(1000000000)
N = int(input())
class Node:
def __init__(self, index):
self.index = index
self.paths = []
self.num = -1
nodes = [Node(i) for i in range(N)]
one = [i for i in range(1, N + 1, 3)]
two = [i for i in range(2, N + 1, 3)]
three = [i for i in range(3, N + 1, 3)]
for _ in range(N - 1):
a, b = map(int, input().split())
nodes[a - 1].paths.append(b - 1)
nodes[b - 1].paths.append(a - 1)
def rec(node, key, passed):
passed.add(node.index)
if key == 1:
if len(one) > 0:
node.num = one.pop()
elif len(three) > 0:
node.num = three.pop()
else:
print(-1)
exit()
else: # key == -1
if len(two) > 0:
node.num = two.pop()
elif len(three) > 0:
node.num = three.pop()
else:
print(-1)
exit()
for path in node.paths:
if path in passed:
continue
passed = rec(nodes[path], key * (-1), passed)
return passed
_ = rec(nodes[0], 1, set())
ans = [node.num for node in nodes]
print(*ans)
| Statement
We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th
edge connects Vertex a_i and Vertex b_i.
Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots ,
p_N of integers from 1 to N satisfying the following condition:
* For every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.
Here the distance between Vertex i and Vertex j is the number of edges
contained in the shortest path from Vertex i to Vertex j.
Help Takahashi by finding a permutation that satisfies the condition. | [{"input": "5\n 1 2\n 1 3\n 3 4\n 3 5", "output": "1 2 5 4 3 \n \n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\n * p_2 + p_4 = 6\n * p_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition."}] |
If no permutation satisfies the condition, print `-1`.
Otherwise, print a permutation satisfying the condition, with space in
between. If there are multiple solutions, you can print any of them.
* * * | s587323979 | Wrong Answer | p02749 | Input is given from Standard Input in the following format:
N
a_1 b_1
a_2 b_2
\vdots
a_{N-1} b_{N-1} | def dijkstra(s, n, w, cost):
# 始点sから各頂点への最短距離
# n:頂点数, w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
d = [float("inf")] * n
used = [False] * n
d[s] = 0
while True:
v = -1
# まだ使われてない頂点の中から最小の距離のものを探す
for i in range(n):
if (not used[i]) and (v == -1):
v = i
elif (not used[i]) and d[i] < d[v]:
v = i
if v == -1:
break
used[v] = True
for j in range(n):
d[j] = min(d[j], d[v] + cost[v][j])
return d
################################
# n, w = map(int, input().split()) # n:頂点数 w:辺の数
n = int(input()) # n:頂点数 w:辺の数
w = n - 1
cost = [[float("inf") for i in range(n)] for i in range(n)]
# cost[u][v] : 辺uvのコスト(存在しないときはinf この場合は10**10)
z = 1
for i in range(w):
# x, y, z = map(int, input().split())
x, y = map(int, input().split())
cost[x - 1][y - 1] = z
cost[y - 1][x - 1] = z
# print(dijkstra(1, n, w, cost))
li1 = []
for i in range(n):
for j in range(n):
k = dijkstra(i, n, w, cost)
if k[j] == 3:
li1.append([i, j])
ans = [1] * n
for i in li1:
ans[i[0]] = 3
ans[i[1]] = 3
if li1 == []:
print("-1")
else:
print(ans)
| Statement
We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th
edge connects Vertex a_i and Vertex b_i.
Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots ,
p_N of integers from 1 to N satisfying the following condition:
* For every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.
Here the distance between Vertex i and Vertex j is the number of edges
contained in the shortest path from Vertex i to Vertex j.
Help Takahashi by finding a permutation that satisfies the condition. | [{"input": "5\n 1 2\n 1 3\n 3 4\n 3 5", "output": "1 2 5 4 3 \n \n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\n * p_2 + p_4 = 6\n * p_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition."}] |
If no permutation satisfies the condition, print `-1`.
Otherwise, print a permutation satisfying the condition, with space in
between. If there are multiple solutions, you can print any of them.
* * * | s791701031 | Wrong Answer | p02749 | Input is given from Standard Input in the following format:
N
a_1 b_1
a_2 b_2
\vdots
a_{N-1} b_{N-1} | N = int(input())
edges = []
three = []
result = ""
for i in range(N - 1):
edges.append(list(map(int, input().split())))
edges[i].append(1)
# print(edges)
def BFS(K, w, edges, N):
roots = [[] for i in range(N)]
for a, b, c in edges:
roots[a - 1] += [(b - 1, c)]
roots[b - 1] += [(a - 1, c)]
dist = [-1] * N
stack = []
stack.append(K)
dist[K] = 0
while stack:
label = stack.pop(-1)
for i, c in roots[label]:
if dist[i] == -1:
dist[i] = dist[label] + c
stack += [i]
if i == w:
return dist[w]
for i in range(1, N + 1):
for j in range(1, N + 1):
# print(i,j)
if i == j:
break
distance = BFS(i - 1, j - 1, edges, N)
# print(distance,":",i,",",j)
if distance == 3:
three.append([i, j])
# print(three)
vertex = []
for i in range(1, N + 1):
vertex.append(i)
def chk(a, b):
# 掛けたら3の倍数か
if (a * b) % 3 == 0:
return True
# 足したら3の倍数か
if (a + b) % 3 == 0:
return True
# 距離3に含まれているか
for th in three:
if (th[0] == a and th[1] == b) or (th[0] == b and th[1] == a):
return True
return False
import itertools
itert = itertools.permutations(vertex)
for i in itert:
# print(i)
for j in range(N - 1):
if chk(i[j], i[j + 1]):
flg = True
for k in range(N):
if flg:
result += str(i[k])
else:
result += " " + str(i[k])
print(result)
exit()
print(-1)
"""
7
2 3
5 3
3 4
3 1
4 6
4 7
"""
| Statement
We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th
edge connects Vertex a_i and Vertex b_i.
Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots ,
p_N of integers from 1 to N satisfying the following condition:
* For every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.
Here the distance between Vertex i and Vertex j is the number of edges
contained in the shortest path from Vertex i to Vertex j.
Help Takahashi by finding a permutation that satisfies the condition. | [{"input": "5\n 1 2\n 1 3\n 3 4\n 3 5", "output": "1 2 5 4 3 \n \n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\n * p_2 + p_4 = 6\n * p_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition."}] |
If no permutation satisfies the condition, print `-1`.
Otherwise, print a permutation satisfying the condition, with space in
between. If there are multiple solutions, you can print any of them.
* * * | s003573431 | Wrong Answer | p02749 | Input is given from Standard Input in the following format:
N
a_1 b_1
a_2 b_2
\vdots
a_{N-1} b_{N-1} | #!/usr/bin/python3
# -*- coding: utf-8 -*-
node_dict = {}
ans_dict = {}
ans_count = {}
def check(i, old_no, deep, start):
deep += 1
if deep == 3:
if i in ans_dict:
ans_dict[i].append(start)
ans_count[i] += 1
else:
ans_dict[i] = [start]
ans_count[i] = 1
if start in ans_dict:
ans_dict[start].append(i)
ans_count[start] += 1
else:
ans_dict[start] = [i]
ans_count[start] = 1
return 0
for key in node_dict[i]:
if key == old_no:
continue
check(key, i, deep, start)
return 0
n = int(input())
ans_list = [0] * n
for i in range(1, n):
a, b = map(int, input().split())
if a in node_dict:
node_dict[a].append(b)
else:
node_dict[a] = [b]
if b in node_dict:
node_dict[b].append(a)
else:
node_dict[b] = [a]
for i in range(1, n):
for key in node_dict[i]:
check(key, i, 0, i)
count = 0
count_12 = 0
count_3 = 0
for key, v in sorted(ans_count.items(), key=lambda x: -x[1]):
if count == n:
break
if ans_list[key - 1] == 0:
if (count_3 + 1) * 3 <= n:
count += 1
count_3 += 1
ans_list[key - 1] = 3 * count_3
for key1 in ans_dict[key]:
if ans_list[key1 - 1] == 0:
count_12 += 1
if count_12 % 3 == 0:
count_12 += 1
ans_list[key1 - 1] = count_12
else:
count_12 += 1
if count_12 % 3 == 0:
count_12 += 1
ans_list[key - 1] = count_12
for i in range(0, n):
if ans_list[i] == 0:
count_12 += 1
if count_12 % 3 == 0:
count_12 += 1
ans_list[key - 1] = count_12
print(str(ans_list[i]), end="")
print(" ", end="")
| Statement
We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th
edge connects Vertex a_i and Vertex b_i.
Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots ,
p_N of integers from 1 to N satisfying the following condition:
* For every pair of vertices (i, j), if the distance between Vertex i and Vertex j is 3, the sum or product of p_i and p_j is a multiple of 3.
Here the distance between Vertex i and Vertex j is the number of edges
contained in the shortest path from Vertex i to Vertex j.
Help Takahashi by finding a permutation that satisfies the condition. | [{"input": "5\n 1 2\n 1 3\n 3 4\n 3 5", "output": "1 2 5 4 3 \n \n\nThe distance between two vertices is 3 for the two pairs (2, 4) and (2, 5).\n\n * p_2 + p_4 = 6\n * p_2\\times p_5 = 6\n\nThus, this permutation satisfies the condition."}] |
Print the maximum total values of the items in a line. | s697639981 | Wrong Answer | p02319 | N W
v1 w1
v2 w2
:
vN wN
The first line consists of the integers N and W. In the following N lines, the
value and weight of the i-th item are given. | n, w = list(map(int, input().split(" ")))
items = [list(map(int, input().split(" "))) for i in range(n)]
interim_ans = [0 for i in range(w + 1)] # i個目までのアイテムを使う場合の暫定解
best_ans = 0
def branch_and_bound(
i, putted, cr_val, cr_weight
): # branch and bound: i番目の要素のありなし
if i >= n:
return
global interim_ans, best_ans
new_val, new_weight = cr_val, cr_weight
if putted:
new_val += items[i][0]
new_weight += items[i][1]
if new_weight > w:
return
if interim_ans[new_weight] > new_val:
return
if best_ans < new_val:
best_ans = new_val
if interim_ans[new_weight] < new_val:
interim_ans[new_weight] = new_val
branch_and_bound(i + 1, True, new_val, new_weight)
branch_and_bound(i + 1, False, new_val, new_weight)
branch_and_bound(0, True, 0, 0)
branch_and_bound(0, False, 0, 0)
print(best_ans)
| 0-1 Knapsack Problem II
You have N items that you want to put them into a knapsack. Item i has value
vi and weight wi.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most W, that is capacity of the knapsack.
Find the maximum total value of items in the knapsack. | [{"input": "4 5\n 4 2\n 5 2\n 2 1\n 8 3", "output": "13"}, {"input": "2 20\n 5 9\n 4 10", "output": "9"}] |
Print Q lines. The i-th line (1 \leq i \leq Q) should contain the answer for x
= X_i.
* * * | s793653782 | Wrong Answer | p03158 | Input is given from Standard Input in the following format:
N Q
A_1 A_2 ... A_N
X_1
X_2
:
X_Q | def examA():
N = I()
ans = 0
print(ans)
return
def examB():
ans = 0
print(ans)
return
def examC():
ans = 0
print(ans)
return
def examD():
N, Q = LI()
A = LI()
X = [I() for _ in range(Q)]
S = [0] * (N + 1)
S_odd = [0] * (N + 1)
S_even = [0] * (N + 1)
for i in range(N):
S[i + 1] = S[i] + A[i]
S_odd[i + 1] = S_odd[i] + A[i] * (i % 2 == 0)
S_even[i + 1] = S_even[i] + A[i] * (i % 2 == 1)
ans = [0] * Q
L = [inf] * N
for i in range(N - 1):
if i == 0:
L0 = -inf
else:
L0 = A[i - 1]
R0 = i + (N - i) // 2
L[i] = L0 + R0 - 1
# print(L)
# print(S)
# print(S_odd)
# print(S_even)
def calc_score(l, r):
rep = S[N] - S[r]
if (N - r - 1) > r - l:
if l % 2 == 1:
rep += S_odd[l - 1]
else:
rep += S_even[l - 1]
else:
if l % 2 == 1:
rep += S_even[l - 1]
else:
rep += S_odd[l - 1]
# print(rep)
return rep
for q in range(Q):
# print(X[q])
i = bisect.bisect_right(L, X[q])
# print(i,i + (N-i-1)//2)
ans[q] = calc_score(i, i + (N - i - 1) // 2)
for v in ans:
print(v)
return
def examE():
ans = 0
print(ans)
return
import sys, copy, bisect, itertools, heapq, math, random
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque
def I():
return int(sys.stdin.readline())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LSI():
return list(map(str, sys.stdin.readline().split()))
def LS():
return sys.stdin.readline().split()
def SI():
return sys.stdin.readline().strip()
global mod, mod2, inf, alphabet, _ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10 ** (-12)
alphabet = [chr(ord("a") + i) for i in range(26)]
if __name__ == "__main__":
examD()
"""
"""
| Statement
There are N cards. The i-th card has an integer A_i written on it. For any two
cards, the integers on those cards are different.
Using these cards, Takahashi and Aoki will play the following game:
* Aoki chooses an integer x.
* Starting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:
* Takahashi should take the card with the largest integer among the remaining card.
* Aoki should take the card with the integer closest to x among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.
* The game ends when there is no card remaining.
You are given Q candidates for the value of x: X_1, X_2, ..., X_Q. For each i
(1 \leq i \leq Q), find the sum of the integers written on the cards that
Takahashi will take if Aoki chooses x = X_i. | [{"input": "5 5\n 3 5 7 11 13\n 1\n 4\n 9\n 10\n 13", "output": "31\n 31\n 27\n 23\n 23\n \n\nFor example, when x = X_3(= 9), the game proceeds as follows:\n\n * Takahashi takes the card with 13.\n * Aoki takes the card with 7.\n * Takahashi takes the card with 11.\n * Aoki takes the card with 5.\n * Takahashi takes the card with 3.\n\nThus, 13 + 11 + 3 = 27 should be printed on the third line.\n\n* * *"}, {"input": "4 3\n 10 20 30 40\n 2\n 34\n 34", "output": "70\n 60\n 60"}] |
Print Q lines. The i-th line (1 \leq i \leq Q) should contain the answer for x
= X_i.
* * * | s317181849 | Accepted | p03158 | Input is given from Standard Input in the following format:
N Q
A_1 A_2 ... A_N
X_1
X_2
:
X_Q | def d_nearest_card_game(N, Q, A, X):
# 最初は、高橋くんは数字の大きなカードを、青木くんはxに近いものから取っていく。
# するといつか高橋くんが取りたいカードが青木くんに取られているような状況になるので、
# そこからは2人で値の大きなものから順に取っていく。
# そのため、2人で順に取っていく領域の広さ(N/2通り)がわかればいい。
# N/2通りなのは、順に取っていくフェイズの前に2人がそれぞれ固まった領域の
# カードを取るフェイズがN/2回あるため。
# (Nが偶数のとき。奇数のときは両者が両端から取っていって
# 最後に高橋くんが真ん中のカードを取ることがありうる)
# これらの場合について、境界となるxの値を先に求めておけば、各クエリに対して
# どの場合に当たるのかを高速に判定できる。
# 境界となるxは青木くんがまとめて取ることになる領域の左右端の中央にある。
# 数列のインデックスを右から0-basedで付けていくと、
# 高橋くんがまとめて取っている領域は 0, 1, ..., i
# 青木くんがまとめて取っている領域は i+1, i+2, ..., 2i+1
# 境界となるxは (A[i+1]+A[2i+2])//2 + 1
# iの値が分かったときに高橋くんの得点を求めるには、
# Aの累積和とAの右から偶数番目だけ取る累積和を求めておけばいい。
import bisect
a = A[::-1] # 「右から」はわかりづらいので逆にする
# 累積和と偶数番目だけ足す累積和
cumsum, evensum = [0] * (N + 1), [0] * (N + 1)
for k, a_k in enumerate(a):
cumsum[k + 1] = cumsum[k] + a_k
evensum[k + 1] = evensum[k] + (a_k if k % 2 == 0 else 0)
# 得点が変化するxの境界とそのときの得点
threshold, threshold_score = [], []
for k in range((N - 1) // 2):
threshold.append((a[k + 1] + a[2 * k + 2]) // 2 + 1)
threshold_score.append(
(cumsum[k + 1] - cumsum[0]) + (evensum[N] - evensum[2 * k + 2])
)
# Aを逆にしたので、もう一度逆にする
threshold = threshold[::-1]
threshold_score = threshold_score[::-1]
ans = []
for x in X:
idx = bisect.bisect_right(threshold, x)
if idx == 0:
ans.append(cumsum[(N + 1) // 2] - cumsum[0])
else:
ans.append(threshold_score[idx - 1])
ans = "\n".join(map(str, ans))
return ans
N, Q = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
X = [int(input()) for _ in range(Q)]
print(d_nearest_card_game(N, Q, A, X))
| Statement
There are N cards. The i-th card has an integer A_i written on it. For any two
cards, the integers on those cards are different.
Using these cards, Takahashi and Aoki will play the following game:
* Aoki chooses an integer x.
* Starting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:
* Takahashi should take the card with the largest integer among the remaining card.
* Aoki should take the card with the integer closest to x among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.
* The game ends when there is no card remaining.
You are given Q candidates for the value of x: X_1, X_2, ..., X_Q. For each i
(1 \leq i \leq Q), find the sum of the integers written on the cards that
Takahashi will take if Aoki chooses x = X_i. | [{"input": "5 5\n 3 5 7 11 13\n 1\n 4\n 9\n 10\n 13", "output": "31\n 31\n 27\n 23\n 23\n \n\nFor example, when x = X_3(= 9), the game proceeds as follows:\n\n * Takahashi takes the card with 13.\n * Aoki takes the card with 7.\n * Takahashi takes the card with 11.\n * Aoki takes the card with 5.\n * Takahashi takes the card with 3.\n\nThus, 13 + 11 + 3 = 27 should be printed on the third line.\n\n* * *"}, {"input": "4 3\n 10 20 30 40\n 2\n 34\n 34", "output": "70\n 60\n 60"}] |
Print Q lines. The i-th line (1 \leq i \leq Q) should contain the answer for x
= X_i.
* * * | s028412515 | Runtime Error | p03158 | Input is given from Standard Input in the following format:
N Q
A_1 A_2 ... A_N
X_1
X_2
:
X_Q | //header
#define set_header 1
#ifdef set_header
#include <bits/stdc++.h>
#ifdef LOCAL
#include "cxx-prettyprint-master/prettyprint.hpp"
#define print(x) cout << x << endl
#else
#define print(...) 42
#endif
using namespace std;
using ll = long long;
#define INF 1'010'000'000'000'000'017LL
#define mod 998244353LL
#define eps 0.0001
#define all(x) (x).begin(), (x).end()
#define reverse(x) (x).rbegin(), (x).rend()
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define SZ(x) ((ll)(x).size())
#define sum(x) accumulate(ALL(x), 0LL)//?
#define pb(x) push_back(x)
typedef pair < ll , ll >P;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <std::uint_fast64_t Modulus> class modint {
using u64 = std::uint_fast64_t;
public:
u64 a;
constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
constexpr u64 &value() noexcept { return a; }
constexpr const u64 &value() const noexcept { return a; }
constexpr modint operator+(const modint rhs) const noexcept {
return modint(*this) += rhs;
}
constexpr modint operator-(const modint rhs) const noexcept {
return modint(*this) -= rhs;
}
constexpr modint operator*(const modint rhs) const noexcept {
return modint(*this) *= rhs;
}
constexpr modint operator/(const modint rhs) const noexcept {
return modint(*this) /= rhs;
}
constexpr modint &operator+=(const modint rhs) noexcept {
a += rhs.a;
if (a >= Modulus) {
a -= Modulus;
}
return *this;
}
constexpr modint &operator-=(const modint rhs) noexcept {
if (a < rhs.a) {
a += Modulus;
}
a -= rhs.a;
return *this;
}
constexpr modint &operator*=(const modint rhs) noexcept {
a = a * rhs.a % Modulus;
return *this;
}
constexpr modint &operator/=(modint rhs) noexcept {
u64 exp = Modulus - 2;
while (exp) {
if (exp % 2) {
*this *= rhs;
}
rhs *= rhs;
exp /= 2;
}
return *this;
}
};
template< typename T >
T mod_pow(T x, T n, const T &p) {
T ret = 1;
while(n > 0) {
if(n & 1) (ret *= x) %= p;
(x *= x) %= p;
n >>= 1;
}
return ret;
}
class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};
uint64_t my_rand(void) {
static uint64_t x = 88172645463325252ULL;
x = x ^ (x << 13); x = x ^ (x >> 7);
return x = x ^ (x << 17);
}
#endif
//library
int N;
vector<ll> A;
bool C(ll x, ll y){
int r = distance(begin(A), upper_bound(all(A), y));
int l = distance(begin(A), lower_bound(all(A), x*2-y));
if(N-r >= r-l) return true;
return false;
}
//main
int main() {
int Q;
cin >> N >> Q;
A.resize(N);
vector<ll> S(N+1), S0(N+1), S1(N+1);
rep(i, N){
cin >> A[i];
S[i+1] = S[i]+A[i];
if(i%2 == 0){
S0[i+1] = S0[i]+A[i];
S1[i+1] = S1[i];
}else{
S1[i+1] = S1[i]+A[i];
S0[i+1] = S0[i];
}
}
rep(i, Q){
ll x;
cin >> x;
ll ok = x, ng = A[N-1];
while((ng-ok)>1){
ll mid = (ok+ng)/2;
if(C(x, mid))ok = mid;
else ng = mid;
}
ll y = ok;
int r = distance(begin(A), upper_bound(all(A), y));
int l = distance(begin(A), upper_bound(all(A), x*2-y));
if(N-r-(r-l) > 1)l--;
ll taka = S[N]-S[r];
if(N-r-(r-l) == l%2)taka+=S1[l];
else taka+=S0[l];
cout << taka << endl;
}
} | Statement
There are N cards. The i-th card has an integer A_i written on it. For any two
cards, the integers on those cards are different.
Using these cards, Takahashi and Aoki will play the following game:
* Aoki chooses an integer x.
* Starting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:
* Takahashi should take the card with the largest integer among the remaining card.
* Aoki should take the card with the integer closest to x among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.
* The game ends when there is no card remaining.
You are given Q candidates for the value of x: X_1, X_2, ..., X_Q. For each i
(1 \leq i \leq Q), find the sum of the integers written on the cards that
Takahashi will take if Aoki chooses x = X_i. | [{"input": "5 5\n 3 5 7 11 13\n 1\n 4\n 9\n 10\n 13", "output": "31\n 31\n 27\n 23\n 23\n \n\nFor example, when x = X_3(= 9), the game proceeds as follows:\n\n * Takahashi takes the card with 13.\n * Aoki takes the card with 7.\n * Takahashi takes the card with 11.\n * Aoki takes the card with 5.\n * Takahashi takes the card with 3.\n\nThus, 13 + 11 + 3 = 27 should be printed on the third line.\n\n* * *"}, {"input": "4 3\n 10 20 30 40\n 2\n 34\n 34", "output": "70\n 60\n 60"}] |
Print Q lines. The i-th line (1 \leq i \leq Q) should contain the answer for x
= X_i.
* * * | s094898041 | Accepted | p03158 | Input is given from Standard Input in the following format:
N Q
A_1 A_2 ... A_N
X_1
X_2
:
X_Q | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
N, Q = map(int, readline().split())
A = np.array(readline().split(), np.int64)
X = np.array(read().split(), np.int64)
INF = 10**15
A = np.concatenate([[-INF, -INF, -INF, -INF], A])
"""
・ある数が後手の右端となるのはどのような場合か
・n番目の右側にr>=1個あるとする
・【長さが奇数のときは、先頭に0を追加しておく】
→ 後手は、[n-r+1,n]をとって、先手は[n+1:]およびn-rを回収する。
・n+1番目をとらない iff r-1個自由にとると n+1番目を含まない iff |A_{n+1}-x| >= |A_{n-r+2}-x|
iff r = 1 or x <= (A_{n+1}+A_{n-r+2})/2 iff r = 1 or x <= (A_{n+1}+A_{n-r+2})//2
・n-r番目をとらない iff r個自由にとると、n-r番目を含まない iff |A_n-x| < |A_{n-r}-x|
iff x > (A_n+A_{n-r})/2 iff x > (A_n+A_{n-r})//2
"""
n = np.arange(N + 4)
r = N - n + 3
ind = (n - r >= 0) & (r >= 1)
n = n[ind]
r = r[ind]
lower = (A[n] + A[n - r]) // 2 + 1
# upper = (A[n+1] + A[n-r+2])//2 不要
# 得点の計算:n+1~の和 + n-rから2つずつ下へ
Acum = np.cumsum(A)
Acum_ev = np.zeros_like(A)
Acum_ev[::2] = A[::2].cumsum()
Acum_ev[1::2] = A[1::2].cumsum()
score = Acum[-1] - Acum[n] + Acum_ev[n - r] + INF + INF
I = np.searchsorted(lower, X, side="right") - 1
answer = score[I]
print("\n".join(answer.astype(str)))
| Statement
There are N cards. The i-th card has an integer A_i written on it. For any two
cards, the integers on those cards are different.
Using these cards, Takahashi and Aoki will play the following game:
* Aoki chooses an integer x.
* Starting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:
* Takahashi should take the card with the largest integer among the remaining card.
* Aoki should take the card with the integer closest to x among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.
* The game ends when there is no card remaining.
You are given Q candidates for the value of x: X_1, X_2, ..., X_Q. For each i
(1 \leq i \leq Q), find the sum of the integers written on the cards that
Takahashi will take if Aoki chooses x = X_i. | [{"input": "5 5\n 3 5 7 11 13\n 1\n 4\n 9\n 10\n 13", "output": "31\n 31\n 27\n 23\n 23\n \n\nFor example, when x = X_3(= 9), the game proceeds as follows:\n\n * Takahashi takes the card with 13.\n * Aoki takes the card with 7.\n * Takahashi takes the card with 11.\n * Aoki takes the card with 5.\n * Takahashi takes the card with 3.\n\nThus, 13 + 11 + 3 = 27 should be printed on the third line.\n\n* * *"}, {"input": "4 3\n 10 20 30 40\n 2\n 34\n 34", "output": "70\n 60\n 60"}] |
Print Q lines. The i-th line (1 \leq i \leq Q) should contain the answer for x
= X_i.
* * * | s771741086 | Accepted | p03158 | Input is given from Standard Input in the following format:
N Q
A_1 A_2 ... A_N
X_1
X_2
:
X_Q | import sys
input = sys.stdin.readline
def I():
return int(input())
def MI():
return map(int, input().split())
def LI():
return list(map(int, input().split()))
def main():
mod = 10**9 + 7
N, Q = MI()
A = LI()
if N % 2 == 1: # 長さが奇数なら0を足しておく
A += [0]
N += 1
A.sort()
"""
連続する区間or交互
"""
S = [0] * (N + 1)
S2 = [0] * (N + 1) # 偶数のみ
for i in range(N):
S[i + 1] = S[i] + A[i]
for i in range(0, N - 1):
S2[i + 2] = S2[i] + A[i]
# print(S)
# print(S2)
def calc(P):
# 先手が上からP枚,後手がその後のP枚をとり,残りを交互に取った時の先手のscore
fi = S[-1] - S[-P - 1]
fi += S2[-2 * P]
return fi
def ch(X, P):
# xが指定され,先手が上からP枚以上取れるか
maxa = A[-P - 1] # 後手が取るmax
mina = A[
-2 * P + 1
] # 後手がP-1ターン目までに取る取るmin(後手がPターン目に取るものはなんでも良い)
diff = A[-P] - X
# print(X,P,mina,maxa,diff)
if diff < 0:
return False
if X - diff <= mina and maxa <= X + diff:
return True
return False
for _ in range(Q):
x = I()
# 先手が上から何枚以上取れるか
ng = N // 2 + 1
ok = 1 # 先手が最大値をとる
while ng - ok > 1:
med = (ok + ng) // 2
if ch(x, med):
ok = med
else:
ng = med
# print(ok)
print(calc(ok))
main()
| Statement
There are N cards. The i-th card has an integer A_i written on it. For any two
cards, the integers on those cards are different.
Using these cards, Takahashi and Aoki will play the following game:
* Aoki chooses an integer x.
* Starting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:
* Takahashi should take the card with the largest integer among the remaining card.
* Aoki should take the card with the integer closest to x among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.
* The game ends when there is no card remaining.
You are given Q candidates for the value of x: X_1, X_2, ..., X_Q. For each i
(1 \leq i \leq Q), find the sum of the integers written on the cards that
Takahashi will take if Aoki chooses x = X_i. | [{"input": "5 5\n 3 5 7 11 13\n 1\n 4\n 9\n 10\n 13", "output": "31\n 31\n 27\n 23\n 23\n \n\nFor example, when x = X_3(= 9), the game proceeds as follows:\n\n * Takahashi takes the card with 13.\n * Aoki takes the card with 7.\n * Takahashi takes the card with 11.\n * Aoki takes the card with 5.\n * Takahashi takes the card with 3.\n\nThus, 13 + 11 + 3 = 27 should be printed on the third line.\n\n* * *"}, {"input": "4 3\n 10 20 30 40\n 2\n 34\n 34", "output": "70\n 60\n 60"}] |
Print Q lines. The i-th line (1 \leq i \leq Q) should contain the answer for x
= X_i.
* * * | s062536075 | Accepted | p03158 | Input is given from Standard Input in the following format:
N Q
A_1 A_2 ... A_N
X_1
X_2
:
X_Q | # -*- coding: utf-8 -*-
import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5:
from math import gcd
else:
from fractions import gcd
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits
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 ceil(x, y=1):
return int(-(-x // y))
def round(x):
return int((x * 2 + 1) // 2)
def fermat(x, y, MOD):
return x * pow(y, MOD - 2, MOD) % MOD
def lcm(x, y):
return (x * y) // gcd(x, y)
def lcm_list(nums):
return reduce(lcm, nums, 1)
def gcd_list(nums):
return reduce(gcd, nums, nums[0])
def INT():
return int(input())
def MAP():
return map(int, input().split())
def LIST():
return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
INF = float("inf")
MOD = 10**9 + 7
N, Q = MAP()
A = LIST()
sm = sum([A[i] for i in range(N - 1, -1, -2)])
borders = [(INF, sm)]
j = N - 3
for i in range(N - 2, N // 2 - 1, -1):
border = (A[j] + A[i]) // 2
val = A[i] - A[j]
sm += val
borders.append((border, sm))
j -= 2
borders.sort()
for _ in range(Q):
x = INT()
idx = bisect_left(borders, (x, 0))
print(borders[idx][1])
| Statement
There are N cards. The i-th card has an integer A_i written on it. For any two
cards, the integers on those cards are different.
Using these cards, Takahashi and Aoki will play the following game:
* Aoki chooses an integer x.
* Starting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:
* Takahashi should take the card with the largest integer among the remaining card.
* Aoki should take the card with the integer closest to x among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.
* The game ends when there is no card remaining.
You are given Q candidates for the value of x: X_1, X_2, ..., X_Q. For each i
(1 \leq i \leq Q), find the sum of the integers written on the cards that
Takahashi will take if Aoki chooses x = X_i. | [{"input": "5 5\n 3 5 7 11 13\n 1\n 4\n 9\n 10\n 13", "output": "31\n 31\n 27\n 23\n 23\n \n\nFor example, when x = X_3(= 9), the game proceeds as follows:\n\n * Takahashi takes the card with 13.\n * Aoki takes the card with 7.\n * Takahashi takes the card with 11.\n * Aoki takes the card with 5.\n * Takahashi takes the card with 3.\n\nThus, 13 + 11 + 3 = 27 should be printed on the third line.\n\n* * *"}, {"input": "4 3\n 10 20 30 40\n 2\n 34\n 34", "output": "70\n 60\n 60"}] |
Print Q lines. The i-th line (1 \leq i \leq Q) should contain the answer for x
= X_i.
* * * | s756943339 | Runtime Error | p03158 | Input is given from Standard Input in the following format:
N Q
A_1 A_2 ... A_N
X_1
X_2
:
X_Q | from bisect import bisect_left
import sys
if sys.version_info[0:2] >= (3, 3):
from collections.abc import Sequence
else:
from collections import Sequence
class LazySequence(Sequence):
def __init__(self, f, n):
self.f = f
self.n = n
def __len__(self):
return self.n
def __getitem__(self, i):
if not (0 <= i < self.n):
raise IndexError
return self.f(i)
N, Q = map(int, input().split())
A = [int(s) for s in input().split()]
X = []
for _ in range(Q):
X.append(int(input()))
A.sort()
s = [0] * (N + 1)
for i in range(N + 1):
s[i] = s[i - 1] + x[i - 1]
t = [0, A[0]] + [0] * (N - 1)
for i in range(N):
t[i] = t[i - 2] + A[i - 1]
def index_hidari(x, i):
val = 2 * x - A[i]
return bisect_left(A, val)
# x <= A[i]
def nankaime(x, i):
return i - index_hidari(x, i) + 1
def npi(x, i):
return nankaime(x, i) + i
def index_migi(x, istart):
ls = LazySequence(lambda i: npi(x, i + istart), N - istart)
return istart + bisect_left(ls, N) - 1
def getans(x):
istart = bisect_left(A, x)
if istart = N:
return t[N]
j = index_migi(x, istart)
turn = N - 1 - i
i = j - turn
return t[i - 1] + s[N] - s[j + 1]
for i in range(Q):
print(getans(X[i]))
| Statement
There are N cards. The i-th card has an integer A_i written on it. For any two
cards, the integers on those cards are different.
Using these cards, Takahashi and Aoki will play the following game:
* Aoki chooses an integer x.
* Starting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:
* Takahashi should take the card with the largest integer among the remaining card.
* Aoki should take the card with the integer closest to x among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.
* The game ends when there is no card remaining.
You are given Q candidates for the value of x: X_1, X_2, ..., X_Q. For each i
(1 \leq i \leq Q), find the sum of the integers written on the cards that
Takahashi will take if Aoki chooses x = X_i. | [{"input": "5 5\n 3 5 7 11 13\n 1\n 4\n 9\n 10\n 13", "output": "31\n 31\n 27\n 23\n 23\n \n\nFor example, when x = X_3(= 9), the game proceeds as follows:\n\n * Takahashi takes the card with 13.\n * Aoki takes the card with 7.\n * Takahashi takes the card with 11.\n * Aoki takes the card with 5.\n * Takahashi takes the card with 3.\n\nThus, 13 + 11 + 3 = 27 should be printed on the third line.\n\n* * *"}, {"input": "4 3\n 10 20 30 40\n 2\n 34\n 34", "output": "70\n 60\n 60"}] |
Print Q lines. The i-th line (1 \leq i \leq Q) should contain the answer for x
= X_i.
* * * | s688722074 | Runtime Error | p03158 | Input is given from Standard Input in the following format:
N Q
A_1 A_2 ... A_N
X_1
X_2
:
X_Q | import copy
N, Q = map(int, input().split())
Alist = list(map(int, input().split()))
Xlist = []
sumT = 0
for i in range(Q):
Xtmp = int(input())
Xlist.append(Xtmp)
for i in range(len(Xlist)):
Tlist = []
A = copy.deepcopy(Alist)
Adifflist = []
if Xlist[i] <= A[0]:
if len(A) % 2 == 0:
print(sum(A[len(A)/2:]))
else:
print(sum(A[A//2:))
elif A[-1] <= Xlist[i]:
for i in range(len(A)):
if i % 2 == 0:
sumT += A[len(A)-1-i]
print(sumT)
else:
for j in range(len(A)):
Adifflist.append([abs(A[j]-Xlist[i]), A[j]])
Adifflist.sort(reverse=False)
while 1:
Ttmp = A.pop(-1)
Tlist.append(Ttmp)
Adifflist.remove([abs(Ttmp-Xlist[i]), Ttmp])
if A == []:
print(sum(Tlist))
break
Atmp = Adifflist[0][1]
del Adifflist[0]
A.remove(Atmp)
if A == []:
print(sum(Tlist))
break | Statement
There are N cards. The i-th card has an integer A_i written on it. For any two
cards, the integers on those cards are different.
Using these cards, Takahashi and Aoki will play the following game:
* Aoki chooses an integer x.
* Starting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:
* Takahashi should take the card with the largest integer among the remaining card.
* Aoki should take the card with the integer closest to x among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.
* The game ends when there is no card remaining.
You are given Q candidates for the value of x: X_1, X_2, ..., X_Q. For each i
(1 \leq i \leq Q), find the sum of the integers written on the cards that
Takahashi will take if Aoki chooses x = X_i. | [{"input": "5 5\n 3 5 7 11 13\n 1\n 4\n 9\n 10\n 13", "output": "31\n 31\n 27\n 23\n 23\n \n\nFor example, when x = X_3(= 9), the game proceeds as follows:\n\n * Takahashi takes the card with 13.\n * Aoki takes the card with 7.\n * Takahashi takes the card with 11.\n * Aoki takes the card with 5.\n * Takahashi takes the card with 3.\n\nThus, 13 + 11 + 3 = 27 should be printed on the third line.\n\n* * *"}, {"input": "4 3\n 10 20 30 40\n 2\n 34\n 34", "output": "70\n 60\n 60"}] |
Print Q lines. The i-th line (1 \leq i \leq Q) should contain the answer for x
= X_i.
* * * | s157138116 | Runtime Error | p03158 | Input is given from Standard Input in the following format:
N Q
A_1 A_2 ... A_N
X_1
X_2
:
X_Q | import bisect
n,q=map(int,input().split())
a=list(map(int,input().split()))
x=[0]*q
ans=[0]*q
for i in range(q):
x[i]=int(input())
aa=0
k=a[n//2:]
aa=sum(k)
bb=0
c=list(a)
while len(c)>0
bb+=c[len(c)-1]
c.pop()
if len(c)>0:
c.pop():
for i in range(q):
b=list(a)
xx=x[i]
sum=0
ll=bisect.bisect_left(b, xx)-1
if ll<=len(b)//4:
ans[i]=aa
elif ll>=len(b)//2+len(b)//4:
ans[i]=bb
else:
while len(b)>0:
sum+=b[len(b)-1]
b.pop()
if len(b)>0:
ll=bisect.bisect_left(b, xx)-1
rr=ll+1
if ll>=len(b)-1:
b.pop()
elif abs(b[rr]-xx)<abs(b[ll]-xx):
b.pop(rr)
else:
b.pop(ll)
ans[i]=sum
for i in ans:
print(i) | Statement
There are N cards. The i-th card has an integer A_i written on it. For any two
cards, the integers on those cards are different.
Using these cards, Takahashi and Aoki will play the following game:
* Aoki chooses an integer x.
* Starting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:
* Takahashi should take the card with the largest integer among the remaining card.
* Aoki should take the card with the integer closest to x among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.
* The game ends when there is no card remaining.
You are given Q candidates for the value of x: X_1, X_2, ..., X_Q. For each i
(1 \leq i \leq Q), find the sum of the integers written on the cards that
Takahashi will take if Aoki chooses x = X_i. | [{"input": "5 5\n 3 5 7 11 13\n 1\n 4\n 9\n 10\n 13", "output": "31\n 31\n 27\n 23\n 23\n \n\nFor example, when x = X_3(= 9), the game proceeds as follows:\n\n * Takahashi takes the card with 13.\n * Aoki takes the card with 7.\n * Takahashi takes the card with 11.\n * Aoki takes the card with 5.\n * Takahashi takes the card with 3.\n\nThus, 13 + 11 + 3 = 27 should be printed on the third line.\n\n* * *"}, {"input": "4 3\n 10 20 30 40\n 2\n 34\n 34", "output": "70\n 60\n 60"}] |
Print Q lines. The i-th line (1 \leq i \leq Q) should contain the answer for x
= X_i.
* * * | s618331248 | Runtime Error | p03158 | Input is given from Standard Input in the following format:
N Q
A_1 A_2 ... A_N
X_1
X_2
:
X_Q | import bisect
n,q=map(int,input().split())
a=list(map(int,input().split()))
x=[0]*q
ans=[0]*q
for i in range(q):
x[i]=int(input())
aa=0
k=a[n//2:]
aa=sum(k)
bb=0
c=list(a)
while len(c)>0:
bb+=c[len(c)-1]
c.pop()
if len(c)>0:
c.pop():
for i in range(q):
b=list(a)
xx=x[i]
sum=0
ll=bisect.bisect_left(b, xx)-1
if ll<=len(b)//4:
ans[i]=aa
elif ll>=len(b)//2+len(b)//4:
ans[i]=bb
else:
while len(b)>0:
sum+=b[len(b)-1]
b.pop()
if len(b)>0:
ll=bisect.bisect_left(b, xx)-1
rr=ll+1
if ll>=len(b)-1:
b.pop()
elif abs(b[rr]-xx)<abs(b[ll]-xx):
b.pop(rr)
else:
b.pop(ll)
ans[i]=sum
for i in ans:
print(i) | Statement
There are N cards. The i-th card has an integer A_i written on it. For any two
cards, the integers on those cards are different.
Using these cards, Takahashi and Aoki will play the following game:
* Aoki chooses an integer x.
* Starting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:
* Takahashi should take the card with the largest integer among the remaining card.
* Aoki should take the card with the integer closest to x among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.
* The game ends when there is no card remaining.
You are given Q candidates for the value of x: X_1, X_2, ..., X_Q. For each i
(1 \leq i \leq Q), find the sum of the integers written on the cards that
Takahashi will take if Aoki chooses x = X_i. | [{"input": "5 5\n 3 5 7 11 13\n 1\n 4\n 9\n 10\n 13", "output": "31\n 31\n 27\n 23\n 23\n \n\nFor example, when x = X_3(= 9), the game proceeds as follows:\n\n * Takahashi takes the card with 13.\n * Aoki takes the card with 7.\n * Takahashi takes the card with 11.\n * Aoki takes the card with 5.\n * Takahashi takes the card with 3.\n\nThus, 13 + 11 + 3 = 27 should be printed on the third line.\n\n* * *"}, {"input": "4 3\n 10 20 30 40\n 2\n 34\n 34", "output": "70\n 60\n 60"}] |
Print Q lines. The i-th line (1 \leq i \leq Q) should contain the answer for x
= X_i.
* * * | s008010433 | Wrong Answer | p03158 | Input is given from Standard Input in the following format:
N Q
A_1 A_2 ... A_N
X_1
X_2
:
X_Q | #!/usr/bin/env python3
import sys
from typing import (
Any,
Callable,
Deque,
Dict,
List,
Mapping,
Optional,
Sequence,
Set,
Tuple,
TypeVar,
Union,
)
# import time
# import math, cmath
# import numpy as np
# import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random # random, uniform, randint, randrange, shuffle, sample
# import string # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
from bisect import (
bisect_left,
bisect_right,
) # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict # subclass of dict. defaultdict(facroty)
# from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce # reduce(f, iter[, init])
# from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import _heapify_max, _heappop_max, _siftdown_max
# from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate # accumulate(iter[, f])
# from operator import itemgetter # itemgetter(1), itemgetter('key')
# from fractions import Fraction # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)
def main():
Num = Union[int, float]
mod = 1000000007 # 10^9+7
inf = float("inf") # sys.float_info.max = 1.79e+308
# inf = 2 ** 63 - 1 # (for fast JIT compile in PyPy) 9.22e+18
sys.setrecursionlimit(10**6) # 1000 -> 1000000
def input():
return sys.stdin.readline().rstrip()
def ii():
return int(input())
def isp():
return input().split()
def mi():
return map(int, input().split())
def mi_0():
return map(lambda x: int(x) - 1, input().split())
def lmi():
return list(map(int, input().split()))
def lmi_0():
return list(map(lambda x: int(x) - 1, input().split()))
def li():
return list(input())
def debug(x):
print(x, file=sys.stderr)
# def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)
def calc_takahasi_top_n(x):
# x - span <= k <= x + span なる k 軸 x 中心とした幅 span の区間を考える
# この区間に含まれる L の要素の個数が、それよりも右側の要素の個数と一致 or 1 個少ない場合求める span である
left = 0
right = 10**9
while True:
mid = (left + right) // 2
aoki = bisect_right(L, x + mid) - bisect_left(L, x - mid)
takahashi = n - bisect_right(L, x + mid)
if aoki == takahashi or aoki == takahashi - 1:
return takahashi
elif aoki == takahashi + 1:
return takahashi + 1
elif aoki > takahashi + 1:
right = mid
else:
left = mid
def solve(x):
top_n = calc_takahasi_top_n(x)
res = max(0, n - top_n * 2)
# debug(f'top_n {top_n}')
# debug(f'res {res}')
return rev_acum[top_n] + skip_sum[res]
n, q = mi()
L = lmi()
query = [ii() for _ in range(q)]
rev_acum = [0] + list(reversed(L))
for i in range(n):
if i > 0:
rev_acum[i] += rev_acum[i - 1]
skip_sum = [0] + L[:]
for i in range(n):
if i > 1:
skip_sum[i] += skip_sum[i - 2]
# debug(rev_acum)
# debug(skip_sum)
for x in query:
print(solve(x))
if __name__ == "__main__":
main()
| Statement
There are N cards. The i-th card has an integer A_i written on it. For any two
cards, the integers on those cards are different.
Using these cards, Takahashi and Aoki will play the following game:
* Aoki chooses an integer x.
* Starting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:
* Takahashi should take the card with the largest integer among the remaining card.
* Aoki should take the card with the integer closest to x among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.
* The game ends when there is no card remaining.
You are given Q candidates for the value of x: X_1, X_2, ..., X_Q. For each i
(1 \leq i \leq Q), find the sum of the integers written on the cards that
Takahashi will take if Aoki chooses x = X_i. | [{"input": "5 5\n 3 5 7 11 13\n 1\n 4\n 9\n 10\n 13", "output": "31\n 31\n 27\n 23\n 23\n \n\nFor example, when x = X_3(= 9), the game proceeds as follows:\n\n * Takahashi takes the card with 13.\n * Aoki takes the card with 7.\n * Takahashi takes the card with 11.\n * Aoki takes the card with 5.\n * Takahashi takes the card with 3.\n\nThus, 13 + 11 + 3 = 27 should be printed on the third line.\n\n* * *"}, {"input": "4 3\n 10 20 30 40\n 2\n 34\n 34", "output": "70\n 60\n 60"}] |
Print Q lines. The i-th line (1 \leq i \leq Q) should contain the answer for x
= X_i.
* * * | s154530979 | Wrong Answer | p03158 | Input is given from Standard Input in the following format:
N Q
A_1 A_2 ... A_N
X_1
X_2
:
X_Q | import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10**7)
inf = 10**20
INF = float("INF")
ans = 0
tmp = 0
cnt = 0
ansli = []
tmpli = []
candili = []
stillset = set()
eps = 1.0 / 10**10
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
nx = j + dx; ny = i + dy
if 0 <= nx < w and 0 <= ny < h:"""
def wi():
return list(map(int, sys.stdin.readline().split()))
def wip():
return [int(x) - 1 for x in sys.stdin.readline().split()] # WideIntPoint
def ws():
return sys.stdin.readline().split()
def i():
return int(sys.stdin.readline())
def s():
return input()
def s_list():
return list(input())
def hi(n):
return [i() for _ in range(n)]
def hs(n):
return [s() for _ in range(n)] # HeightString
def mi(n):
return [wi() for _ in range(n)] # MatrixInt
def num_grid(n):
return [
[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)
] # NumberGrid
def mip(n):
return [wip() for _ in range(n)]
def ms(n):
return [ws() for _ in range(n)]
def grid(n):
return [s_list() for _ in range(n)]
if __name__ == "__main__":
n, q = wi()
A = wi()
X = hi(q)
accu_a = list(accumulate(A))
# from_zero_sum = [i for idx, i in enumerate(a) if idx % 2 == 0]
# from_one_sum = [i for idx, i in enumerate(a) if idx % 2 == 1]
# 単調性のある関数の解を見つける
def isOK(mid):
turn = n - 1 - mid
d = mid + 1
c = mid
b = c - turn + 2
a = b - 1
if b < 0:
return "f", "t"
if abs(A[a] - x) < abs(A[c] - x) and a >= 0:
a -= 1
if abs(A[a] - x) < abs(A[c] - x) and a >= 0:
return "t", "t"
return "d", "t"
elif abs(A[b] - x) > abs(A[d] - x):
return "f", "a"
else:
return "d", "t"
# 汎用的な二分探索のテンプレ
# 条件を満たす最小値(ng,ok)
def binary_search():
ng = -1 # 「index = 0」が条件を満たすこともあるので、初期値は -1
ok = len(
A
) # 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
# ok と ng のどちらが大きいかわからないことを考慮
while abs(ok - ng) > 1:
mid = (ok + ng) // 2
B = isOK(mid)
if B[0] == "t":
ok, t_or_a = mid, B[1]
elif B[0] == "f":
ng, t_or_a = mid, B[1]
else:
ok, t_or_a = mid, B[1]
return ok, t_or_a
return ok, t_or_a
for _, x in enumerate(X):
# r_b = bisect_right(A, x)
ok, t_or_a = binary_search()
ans += accu_a[-1] - accu_a[ok]
turn = n - 1 - ok
b = ok - turn + 2
if t_or_a == "t":
b -= 2
for i in range(b, -1, -2):
ans += A[i]
print(ans)
ans = 0
| Statement
There are N cards. The i-th card has an integer A_i written on it. For any two
cards, the integers on those cards are different.
Using these cards, Takahashi and Aoki will play the following game:
* Aoki chooses an integer x.
* Starting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:
* Takahashi should take the card with the largest integer among the remaining card.
* Aoki should take the card with the integer closest to x among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.
* The game ends when there is no card remaining.
You are given Q candidates for the value of x: X_1, X_2, ..., X_Q. For each i
(1 \leq i \leq Q), find the sum of the integers written on the cards that
Takahashi will take if Aoki chooses x = X_i. | [{"input": "5 5\n 3 5 7 11 13\n 1\n 4\n 9\n 10\n 13", "output": "31\n 31\n 27\n 23\n 23\n \n\nFor example, when x = X_3(= 9), the game proceeds as follows:\n\n * Takahashi takes the card with 13.\n * Aoki takes the card with 7.\n * Takahashi takes the card with 11.\n * Aoki takes the card with 5.\n * Takahashi takes the card with 3.\n\nThus, 13 + 11 + 3 = 27 should be printed on the third line.\n\n* * *"}, {"input": "4 3\n 10 20 30 40\n 2\n 34\n 34", "output": "70\n 60\n 60"}] |
Print Q lines. The i-th line (1 \leq i \leq Q) should contain the answer for x
= X_i.
* * * | s068346803 | Accepted | p03158 | Input is given from Standard Input in the following format:
N Q
A_1 A_2 ... A_N
X_1
X_2
:
X_Q | from bisect import bisect_left
N, Q = map(int, input().split())
A = [int(i) for i in input().split()]
P = []
m = N // 2
for k in range(N - m - 1):
P.append((A[k + m] + A[2 * (k + m) - N + 1]) / 2)
S, S_o, S_e = [0], [0], [0]
for i in range(N):
S.append(S[-1] + A[i])
if i % 2 == 0:
S_o.append(S_o[-1] + A[i])
S_e.append(S_e[-1])
if i % 2 == 1:
S_o.append(S_o[-1])
S_e.append(S_e[-1] + A[i])
for q in range(Q):
a = int(input())
l = bisect_left(P, a)
if N % 2:
ans = S[N] - S[N - m + l - 1] + S_o[max(N - 2 * (m - l + 1), 0)]
else:
ans = S[N] - S[N - m + l] + S_e[max(N - 2 * (m - l), 0)]
print(ans)
| Statement
There are N cards. The i-th card has an integer A_i written on it. For any two
cards, the integers on those cards are different.
Using these cards, Takahashi and Aoki will play the following game:
* Aoki chooses an integer x.
* Starting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:
* Takahashi should take the card with the largest integer among the remaining card.
* Aoki should take the card with the integer closest to x among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.
* The game ends when there is no card remaining.
You are given Q candidates for the value of x: X_1, X_2, ..., X_Q. For each i
(1 \leq i \leq Q), find the sum of the integers written on the cards that
Takahashi will take if Aoki chooses x = X_i. | [{"input": "5 5\n 3 5 7 11 13\n 1\n 4\n 9\n 10\n 13", "output": "31\n 31\n 27\n 23\n 23\n \n\nFor example, when x = X_3(= 9), the game proceeds as follows:\n\n * Takahashi takes the card with 13.\n * Aoki takes the card with 7.\n * Takahashi takes the card with 11.\n * Aoki takes the card with 5.\n * Takahashi takes the card with 3.\n\nThus, 13 + 11 + 3 = 27 should be printed on the third line.\n\n* * *"}, {"input": "4 3\n 10 20 30 40\n 2\n 34\n 34", "output": "70\n 60\n 60"}] |
Print the maximum number of edges that can be added.
* * * | s391856543 | Wrong Answer | p03508 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | n, m = map(int, input().strip().split(" "))
print((n - 1) * (m - 1))
| Statement
You are given an undirected graph G. G has N vertices and M edges. The
vertices are numbered from 1 through N, and the i-th edge (1 ≤ i ≤ M) connects
Vertex a_i and b_i. G does not have self-loops and multiple edges.
You can repeatedly perform the operation of adding an edge between two
vertices. However, G must not have self-loops or multiple edges as the result.
Also, if Vertex 1 and 2 are connected directly or indirectly by edges, your
body will be exposed to a voltage of 1000000007 volts. This must also be
avoided.
Under these conditions, at most how many edges can you add? Note that Vertex 1
and 2 are never connected directly or indirectly in the beginning. | [{"input": "4 1\n 1 3", "output": "2\n \n\n\n\nAs shown above, two edges can be added. It is not possible to add three or\nmore edges.\n\n* * *"}, {"input": "2 0", "output": "0\n \n\n\n\nNo edge can be added.\n\n* * *"}, {"input": "9 6\n 1 4\n 1 8\n 2 5\n 3 6\n 4 8\n 5 7", "output": "12"}] |
Print the answer.
* * * | s169183139 | Wrong Answer | p03322 | Input is given from Standard Input in the following format:
N
S | from collections import defaultdict
def takahashi(s):
a = defaultdict(lambda: 0)
P = 0
for c in s:
if c == "+":
a[P] += 1
elif c == "-":
a[P] -= 1
elif c == ">":
P += 1
else:
P -= 1
keys = a.keys()
return {k: v for k, v in a.items() if v != 0}
def main():
N = int(input())
s = input()
ans = takahashi(s)
# print(ans)
n = 0
for i in range(N):
for j in range(i + 1, N + 1):
# print(s[i:j], takahashi(s[i:j]) == ans)
if takahashi(s[i:j]) == ans:
n += 1
print(n)
| Statement
In Takahashi's mind, there is always an integer sequence of length 2 \times
10^9 + 1: A = (A_{-10^9}, A_{-10^9 + 1}, ..., A_{10^9 - 1}, A_{10^9}) and an
integer P.
Initially, all the elements in the sequence A in Takahashi's mind are 0, and
the value of the integer P is 0.
When Takahashi eats symbols `+`, `-`, `>` and `<`, the sequence A and the
integer P will change as follows:
* When he eats `+`, the value of A_P increases by 1;
* When he eats `-`, the value of A_P decreases by 1;
* When he eats `>`, the value of P increases by 1;
* When he eats `<`, the value of P decreases by 1.
Takahashi has a string S of length N. Each character in S is one of the
symbols `+`, `-`, `>` and `<`. He chose a pair of integers (i, j) such that 1
\leq i \leq j \leq N and ate the symbols that are the i-th, (i+1)-th, ...,
j-th characters in S, in this order. We heard that, after he finished eating,
the sequence A became the same as if he had eaten all the symbols in S from
first to last. How many such possible pairs (i, j) are there? | [{"input": "5\n +>+<-", "output": "3\n \n\nIf Takahashi eats all the symbols in S, A_1 = 1 and all other elements would\nbe 0. The pairs (i, j) that leads to the same sequence A are as follows:\n\n * (1, 5)\n * (2, 3)\n * (2, 4)\n\n* * *"}, {"input": "5\n +>+-<", "output": "5\n \n\nNote that the value of P may be different from the value when Takahashi eats\nall the symbols in S.\n\n* * *"}, {"input": "48\n -+><<><><><>>>+-<<>->>><<><<-+<>><+<<>+><-+->><<", "output": "475"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s850410214 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | n=int(input())
if n<1200:
print(“ABC”)
elif n<2800:
print(“ARC”)
else:
print(“AGC”) | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s882464727 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | N = int(input())
if N < 1200:
print("ABC")
elif N < 2800:
print("ARC")
else
print("AGC")
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s849394796 | Accepted | p03288 | Input is given from Standard Input in the following format:
R | import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-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 pf(s):
return print(s, flush=True)
def main():
r = I()
if r < 1200:
return "ABC"
if r < 2800:
return "ARC"
return "AGC"
print(main())
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s188317614 | Accepted | p03288 | Input is given from Standard Input in the following format:
R | ###############################################################################
from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict
mod = 1
def intin():
input_tuple = input().split()
if len(input_tuple) <= 1:
return int(input_tuple[0])
return tuple(map(int, input_tuple))
def intina():
return [int(i) for i in input().split()]
def intinl(count):
return [intin() for _ in range(count)]
def modadd(x, y):
global mod
return (x + y) % mod
def modmlt(x, y):
global mod
return (x * y) % mod
def lcm(x, y):
while y != 0:
z = x % y
x = y
y = z
return x
def combination(x, y):
assert x >= y
if y > x // 2:
y = x - y
ret = 1
for i in range(0, y):
j = x - i
i = i + 1
ret = ret * j
ret = ret // i
return ret
def get_divisors(x):
retlist = []
for i in range(1, int(x**0.5) + 3):
if x % i == 0:
retlist.append(i)
retlist.append(x // i)
return retlist
def get_factors(x):
retlist = []
for i in range(2, int(x**0.5) + 3):
while x % i == 0:
retlist.append(i)
x = x // i
retlist.append(x)
return retlist
def make_linklist(xylist):
linklist = {}
for a, b in xylist:
linklist.setdefault(a, [])
linklist.setdefault(b, [])
linklist[a].append(b)
linklist[b].append(a)
return linklist
def calc_longest_distance(linklist, v=1):
distance_list = {}
distance_count = 0
distance = 0
vlist_previous = []
vlist = [v]
nodecount = len(linklist)
while distance_count < nodecount:
vlist_next = []
for v in vlist:
distance_list[v] = distance
distance_count += 1
vlist_next.extend(linklist[v])
distance += 1
vlist_to_del = vlist_previous
vlist_previous = vlist
vlist = list(set(vlist_next) - set(vlist_to_del))
max_distance = -1
max_v = None
for v, distance in distance_list.items():
if distance > max_distance:
max_distance = distance
max_v = v
return (max_distance, max_v)
def calc_tree_diameter(linklist, v=1):
_, u = calc_longest_distance(linklist, v)
distance, _ = calc_longest_distance(linklist, u)
return distance
###############################################################################
def main():
r = intin()
if r < 1200:
print("ABC")
elif r < 2800:
print("ARC")
else:
print("AGC")
if __name__ == "__main__":
main()
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s372111827 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | import java.util.Scanner;
public class main {
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
int r = sc.nextInt();
if(r < 1200){
System.out.println("ABC");
}else if(1200 <= r && r < 2800){
System.out.println("ARC");
} else{
System.out.println("AGC");
}
}
}
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s761392900 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | def dfs(i, total, S, remain):
global ans
if i == D:
if S < G:
use = max(remain)
N = min(L[use - 1][0], (G - S) // (100 * use))
S += 100 * N * use
total += N
if S >= G:
ans = min(ans, total)
else:
dfs(i + 1, total, S, remain)
dfs(
i + 1,
total + L[i][0],
S + 100 * (i + 1) * L[i][0] + L[i][1],
remain - {i + 1},
)
D, G = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(D)]
ans = 10**9
dfs(0, 0, 0, set(range(1, D + 1)))
print(ans)
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s296335698 | Wrong Answer | p03288 | Input is given from Standard Input in the following format:
R | S = input()
L = len(S)
Q = 10**9 + 7
anum = [0 for _ in range(L + 1)]
# bnum = [ 0 for _ in range(L+1)]
cnum = [0 for _ in range(L + 1)]
hnum = [0 for _ in range(L + 1)]
for i in range(1, L + 1):
if S[i - 1] == "A":
anum[i] = anum[i - 1] + 1
# bnum[i] = bnum[i-1]
cnum[i] = cnum[i - 1]
hnum[i] = hnum[i - 1]
elif S[i - 1] == "B":
anum[i] = anum[i - 1]
# bnum[i] = bnum[i-1] + 1
cnum[i] = cnum[i - 1]
hnum[i] = hnum[i - 1]
elif S[i - 1] == "C":
anum[i] = anum[i - 1]
# bnum[i] = bnum[i-1]
cnum[i] = cnum[i - 1] + 1
hnum[i] = hnum[i - 1]
else:
anum[i] = anum[i - 1]
# bnum[i] = bnum[i-1]
cnum[i] = cnum[i - 1]
hnum[i] = hnum[i - 1] + 1
ans = 0
czen = cnum[L]
hzen = hnum[L]
for i in range(1, L + 1):
if S[i - 1] == "B" or S[i - 1] == "?":
A = (
anum[i - 1] * (3 ** hnum[i - 1]) + hnum[i - 1] * (3 ** (hnum[i - 1] - 1))
) % Q
C = (
(czen - cnum[i]) * (3 ** (hzen - hnum[i]))
+ (hzen - hnum[i]) * (3 ** (hzen - hnum[i] - 1))
) % Q
K = (A * C) % Q
ans = (ans + K) % Q
print(int(ans))
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s036311818 | Wrong Answer | p03288 | Input is given from Standard Input in the following format:
R | S = input()
MOD = 10**9 + 7
# time complexity: O(|S|)
def dp(S):
dp = [[0] * 4 for _ in range(len(S) + 1)]
dp[len(S)][3] = 1
for i in range(len(S))[::-1]:
dp[i][3] = 3 * dp[i + 1][3] if S[i] == "?" else dp[i + 1][3]
dp[i][3] %= MOD
if S[i] == "?":
dp[i][0] = (3 * dp[i + 1][0] + dp[i + 1][1]) % MOD
dp[i][1] = (3 * dp[i + 1][1] + dp[i + 1][2]) % MOD
dp[i][2] = (3 * dp[i + 1][2] + dp[i + 1][3]) % MOD
else:
dp[i][0] = (dp[i + 1][0] + int(S[i] == "A") * dp[i + 1][1]) % MOD
dp[i][1] = (dp[i + 1][1] + int(S[i] == "B") * dp[i + 1][2]) % MOD
dp[i][2] = (dp[i + 1][2] + int(S[i] == "C") * dp[i + 1][3]) % MOD
print(dp[0][0])
# time complexity: O(|S|)
def focus_on_B(S):
cuml = {"A": [], "C": [], "?": []}
current_nums = {"A": 0, "C": 0, "?": 0}
for char in S:
if char in cuml.keys():
current_nums[char] += 1
for key in cuml.keys():
cuml[key].append(current_nums[key])
# num_combinations[i]: i番目をBとした時に、可能な組み合わせの数
num_combinations = [0] * len(S)
for i in range(1, len(S) - 1):
if S[i] in {"B", "?"}:
A_L = cuml["A"][i - 1]
Q_L = cuml["?"][i - 1]
C_R = cuml["C"][-1] - cuml["C"][i]
Q_R = cuml["?"][-1] - cuml["?"][i]
num_combinations[i] = (
(A_L * 3 + Q_L)
* int(3 ** (Q_L - 1))
* (C_R * 3 + Q_R)
* int(3 ** (Q_R - 1))
) % MOD
else:
continue
print(sum(num_combinations) % MOD)
focus_on_B(S)
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s978008458 | Accepted | p03288 | Input is given from Standard Input in the following format:
R | print(f"A{'BRG'[int(input())//50+8>>5]}C")
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s573276893 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | =int(input())
if a<1200:
print("ABC")
elif 2800<=a:
print("AGC")
else:
print("ARC")
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s455853666 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | r = int(input())
if r < 1200:
print("ABC")
else r < 2800:
print("ARC")
else:
print("AGC") | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s553143230 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | n=int(input())
if n<1200:
print(‘abc’)
elif n<2800:
print(‘arc’)
else:
print(‘agc’) | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s617178667 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | # coding: utf-8
#codebegin
R=input()
r=int(R)
if r<1200:
print("ABC"):
if r>(1200-1) and r<2800:
print("ARC")
if r>(2800-1):
print("AGC") | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s473964128 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | def solve(levelNum, levelProblemNums, extraPoints, target):
target = int(target / 100)
dp = [[99999999] * (target + 1) for _ in range(levelNum + 1)]
for i in range(levelNum + 1):
dp[i][0] = 0
# print(dp)
# print(target)
# for each level
for l in range(1, levelNum + 1):
# for each point
# print( l)
for point in range(1, target + 1):
dp[l][point] = dp[l - 1][point]
for p in range(1, levelProblemNums[l - 1] + 1):
curPoint = (
p * l
if p < levelProblemNums[l - 1]
else p * l + int(extraPoints[l - 1] / 100)
)
subPoint = point - curPoint if point > curPoint else 0
dp[l][point] = min(dp[l - 1][subPoint] + p, dp[l][point])
return dp[l][target]
D, G = map(int, input().split())
P, C = [], []
for i in range(D):
p, c = map(int, input().split())
P.append(p)
C.append(c)
# res = [D]
rt = solve(D, P, C, G)
print(rt)
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s294772434 | Wrong Answer | p03288 | Input is given from Standard Input in the following format:
R | mod = 10**9 + 7
s = input()
n = len(s)
dp = [[0] * 4 for i in range(n + 1)] # A B C ABC
dp[0][0] = 1
for i in range(1, n + 1):
if s[i - 1] == "A":
dp[i][0] = dp[i - 1][0] % mod
dp[i][1] = (dp[i - 1][1] + dp[i - 1][0]) % mod
dp[i][2] = dp[i - 1][2] % mod
dp[i][3] = dp[i - 1][3] % mod
elif s[i - 1] == "B":
dp[i][0] = dp[i - 1][0] % mod
dp[i][1] = dp[i - 1][1] % mod
dp[i][2] = (dp[i - 1][2] + dp[i - 1][1]) % mod
dp[i][3] = dp[i - 1][3] % mod
elif s[i - 1] == "C":
dp[i][0] = dp[i - 1][0] % mod
dp[i][1] = dp[i - 1][1] % mod
dp[i][2] = dp[i - 1][2] % mod
dp[i][3] = (dp[i - 1][3] + dp[i - 1][2]) % mod
else:
dp[i][0] = dp[i - 1][0] * 3 % mod
dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % mod
dp[i][2] = (dp[i - 1][2] * 3 + dp[i - 1][1]) % mod
dp[i][3] = (dp[i - 1][3] * 3 + dp[i - 1][2]) % mod
print(dp[-1][-1] % mod)
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s622932910 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | =int(input())
if a<1200:
print("ABC")
else if 2800<=a:
print("AGC")
else:
print("ARC") | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s240532421 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | R = input()
if R < 1200:
print("ABC")
elif 1200 <= R < 2800:
print("ARC")
else print("AGC") | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s785532653 | Wrong Answer | p03288 | Input is given from Standard Input in the following format:
R | s = list(input())
ans = "AC"
if (
s[0] != "A"
or s.count("C") != 1
or s[2:-1].count("C") != 1
or "".join([i for i in s if i != "A" and i != "C"]).islower != True
):
ans = "WA"
print(ans)
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s609749854 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | R=input()
0<=R and R<=4208
if R>=1 and R<1200
print('ABC')
elif R>=1200 and R<2800
print('ARC')
elif R>=2800 and R<=4208
print('AGC') | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s184151702 | Accepted | p03288 | Input is given from Standard Input in the following format:
R | print("A" + "BRG"[(int(input()) + 400) // 1600] + "C")
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s162253156 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | n=int(input())
if(n<1200):
print("ABC")
elif(n<2800):
print("ARC"):
else:
print("AGC") | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s660200752 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | a=int(input())
if a<1500:
print("ABC")
else if a<2800:
print("ARC")
else:
print("AGC") | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s004292344 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | R=int(input())
if R<1200:
print("ABC")
elseif R<2800:
print("ARC")
else:
print("AGC") | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s246247000 | Wrong Answer | p03288 | Input is given from Standard Input in the following format:
R | s = input()[:2]
print("AAAGRBCCC"[(s < "12") + (s < "28") :: 3])
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s568454813 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | a=int(input());print("ABC"if a<1200"ARC"elif a<2800else"AGC") | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s608024423 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | R=input()
0<=R and R<=4208
if R>=1 and R<1200
print('ABC')
elif R>=1200 and R<2800
print('ARC')
elif R>=2800
print('AGC') | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s963214463 | Wrong Answer | p03288 | Input is given from Standard Input in the following format:
R | S = input()
N = len(S)
a, b, c, d = 0, 0, 0, 1
mod = 10**9 + 7
for x in reversed(S):
if x == "?":
a, b, c, d = 3 * a + b, 3 * b + c, 3 * c + d, 3 * d
elif x == "A":
a += b
elif x == "B":
b += c
elif x == "C":
c += d
a %= mod
b %= mod
c %= mod
d %= mod
print(a)
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s744712898 | Wrong Answer | p03288 | Input is given from Standard Input in the following format:
R | # -*- coding: utf-8 -*-
import sys
import itertools # これは色々使える組み込み関数みたいなやつ
import math # 数学的計算はこれでいける。普通に0.5乗しても計算可能
# w=input()
i = 0
j = 0
# N=int(input())
# N, W=input().split()
S = input()
# T=input()
# S_list=list(S)
# h_list= list(map(int, input().split(" ")))
# M=int(input())
# drink_list = [list(map(int, input().split(" ")))for i in range(M)]
# print(T_list[1])
# N=int(N)
# W=int(W)
# 不本意だが内包表記で二次元の空のリストを作成する
# dp=[['' for i in range(2)] for j in range(N)]
# K=int(K)
# S_list=[]
sentence_list = []
# total=0
# mojiretu=""
# センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい!
# for i in range(K):
# ID_list.append(i+1)
# print(ID_list)
# for i in range(H)
# この下の行が二次元リストの読み込
# intを消して記号を読み込めるようにしたしかしこれでは文字列から読み込んでいるのと同じ
# weight_value_list = [list(input())for i in range(N)]#一文字づつばらして入れてしまう
# s = [input() for i in range(N)]
# 複数行に複数の入力値を取得し、出力する
# sentence_list = (list(input())for i in range(N))
# for i in range(H):
# ppixel_list=list(input())
#
# print(pixel_list)
# high_pixel_list =[['' for i in range(W)]for j in range(2*H)]
# print(high_pixel_list)
# print(pixel_list[0][1])#行 列の順番にかっこが並んでいる
# print(a_list)
first_term = 0
second_term = 0
# 整数二次元配列を読み込む時のやり方
# a_b_c_list = [list(map(int, input().split(" ")))for i in range(N)]
# センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい!
# print(S)
# sentence_list=sorted(S)
sentence_list = list(S)
# print(sentence_list)
# スペースでいれつつ値を取得
if len(S) < 4 or len(S) > 10:
print("WA")
sys.exit()
if sentence_list[0] == "A": # and sentence_list[2]=="C":
# print(1231234)
del sentence_list[0]
pass
else:
print("WA")
sys.exit()
for j in range(len(sentence_list) - 3):
# print(len(S))
# print(j+4)
if j + 4 == len(sentence_list):
print("WA")
sys.exit()
if sentence_list[j + 1] == "C":
del sentence_list[j + 1]
break
S = "".join(sentence_list)
if S.islower() == True:
print("AC")
sys.exit()
print("WA")
# x, y = [0]*N, [0]*N#N個の空のリストを作成
# l = list(range(N))#範囲がNのリストを作成する
# for i in range(N):
# x[i], y[i] = map(int, input().split())
# 分けて入力する形式を設定することで可読性が高く仕上がっている
# 素晴らしいことだ
distance = 0
# comb = list(itertools.permutations(l))
# prmutation:英語の意味としては順列である
"""p[, r]で
長さrのタプル列、重複なしのあらゆる並びを表す
今回はリストlの重複なしの並び替え順序を新たなリストに収納している
並び方を計算しリストに収納しているイメージ
l[0,1,2]
l[0,2,1]これにもリスト番号が0,1,2と割り振られている
これが全通り入っている
これ作った人はすごい
自分も早く理解したい
"""
# for i in range(0, len(comb)):#i番目のパターンの時を考える。
# for j in range(0, N-1):#lのリスト番号を読み込み
# distance += math.sqrt((x[comb[i][j]]-x[comb[i][j+1]])**2 + (y[comb[i][j]]-y[comb[i][j+1]])**2)
"""
各経路の距離を足していき全距離分を経路数
で割れば平均距離が出るので各経路ごとの距離は
不必要と判断されている。
"""
# print(distance/len(comb))
i = 0
j = 0
# 1を選んだとき0,2を選ぶってのがどう実装すべきかわからんかった
# だからここで学ぶ
# 2019/1/4参考サイトに見当たらず 仕方がないのでその場しのぎ
# for i in range(N):
for j in range(3):
pass
# dp[i+1][j]=max(dp[i][j]+a_b_c_list[i],dp[i][j],dp[i][j])
# リストを一周するようにすればいいのか
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s521745668 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | r=int(input())
if r<1200:
print('ABC')
elif r<2800:
print('ARC')
else:
print('AGC')
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s544380164 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R |
r = int(input())
if r < 1200:
print("ABC")
elif r 2800:
print("ARC")
else:
print("AGC")
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s018209612 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | r = int(input())
if r >= 2800 :
print('AGC')
elif r >= 1200 :
print('ARC'):
else:
print('ABC')
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s592849494 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | R = int(input())
if R < 1200:
print(“ABC”)
elif R < 2800:
print(“ARC”)
else:
print(“AGC”)
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s111101986 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | R = int(input())
if R < 1200:
print('ABC')
elif:
R < 2800:
print('ARC')
else:
print('AGC')
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s014902477 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | n=int(input())
if n<1200:
print('ABC')
elif (n<2800)&&(n>=1200):
print('ARC')
else:
print('AGC')
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s655582656 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | r = int(input())
ans = ''
if r < 1200:
print('ABC')
elfi r < 2800:
print('ARC')
else:
print('AGC') | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s778212099 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | a = int(input())
if a < 1200:
print("ABC")
elif a < 2800:
print("ARC")
else a
print("AGC") | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s502216798 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | n = int(input())
if n<1200:
print("ABC")
elif 1200=<n<2800:
print("ARC")
else:
print("AGC") | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s963771903 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | R = int(input())
if R < 1200:
print('ABC')
elif 1200 <= R < 2800
print('ARC')
else:
print('AGC') | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s451122123 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | r = int.input()
if r < 1200:
print("ABC")
else if r < 2800
print("ARC")
else
print("AGC")
| Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s329431813 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | a = int(input())
if a < 1200:
print("ABC")
elif a < 2800:
print("ARC")
else
print("AGC") | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s628746959 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | R = int(input())
if R < 1200:
r = 'ABC'
elif R < 2800:
r = 'ARC':
else:
r ='AGC'
print(r) | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or
`AGC`).
* * * | s632083589 | Runtime Error | p03288 | Input is given from Standard Input in the following format:
R | a = int(input())
if a < 1200:
print("ABC")
else if a < 2800:
print("ARC")
else:
print("AGC") | Statement
A programming competition site _AtCode_ regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with
ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants with
ratings less than 2800.
The contest after the ARC is called AGC, which is rated for all contestants.
Takahashi's rating on AtCode is R. What is the next contest rated for him? | [{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.