wrong_submission_id
stringlengths 10
10
| problem_id
stringlengths 6
6
| user_id
stringlengths 10
10
| time_limit
float64 1k
8k
| memory_limit
float64 131k
1.05M
| wrong_status
stringclasses 2
values | wrong_cpu_time
float64 10
40k
| wrong_memory
float64 2.94k
3.37M
| wrong_code_size
int64 1
15.5k
| problem_description
stringlengths 1
4.75k
| wrong_code
stringlengths 1
6.92k
| acc_submission_id
stringlengths 10
10
| acc_status
stringclasses 1
value | acc_cpu_time
float64 10
27.8k
| acc_memory
float64 2.94k
960k
| acc_code_size
int64 19
14.9k
| acc_code
stringlengths 19
14.9k
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s065012670
|
p03971
|
u488884575
| 2,000
| 262,144
|
Wrong Answer
| 98
| 4,016
| 205
|
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
|
N, A, B = map(int, input().split())
S = input()
a = b = 0
for s in S:
if s == 'a' and a+b < A+B:
print('Yes')
a += 1
elif s == 'b' and b < B:
print('Yes')
b += 1
else:
print('No')
|
s660271061
|
Accepted
| 100
| 4,016
| 219
|
N, A, B = map(int, input().split())
S = input()
a = b = 0
for s in S:
if s == 'a' and a+b < A+B:
print('Yes')
a += 1
elif s == 'b' and a+b < A+B and b < B:
print('Yes')
b += 1
else:
print('No')
|
s541791270
|
p02613
|
u709079466
| 2,000
| 1,048,576
|
Wrong Answer
| 136
| 16,296
| 210
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
n = int(input())
s = [input() for _ in range(n)]
#print(s)
print('AC × ' + str(s.count('AC')))
print('WA × ' + str(s.count('WA')))
print('TLE × ' + str(s.count('TLE')))
print('RE × ' + str(s.count('RE')))
|
s155925068
|
Accepted
| 142
| 16,268
| 206
|
n = int(input())
s = [input() for _ in range(n)]
#print(s)
print('AC x ' + str(s.count('AC')))
print('WA x ' + str(s.count('WA')))
print('TLE x ' + str(s.count('TLE')))
print('RE x ' + str(s.count('RE')))
|
s298160048
|
p03779
|
u804358525
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 59
|
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
|
# -*- Coding: utf-8 -*-
x = int(input())
print(x*(x+1)/2)
|
s637713736
|
Accepted
| 30
| 2,940
| 245
|
# -*- Coding: utf-8 -*-
x = int(input())
def answer(x):
for i in range(x):
if(i*(i+1)//2 < x):
continue
else:
return i
result = answer(x)
if(result == None):
print(x)
else:
print(answer(x))
|
s319239446
|
p03971
|
u384476576
| 2,000
| 262,144
|
Wrong Answer
| 127
| 4,080
| 443
|
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
|
N, A, B = list(map(int, input().split()))
S = input()
passed_num = 0
passed_foreigners_num = 0
for i in S:
if passed_num < A + B:
if i == 'a':
print('yes')
passed_num += 1
elif i == 'b' and passed_foreigners_num < B:
print(i)
print('yes')
passed_num += 1
passed_foreigners_num += 1
else:
print('No')
else:
print('No')
|
s427709204
|
Accepted
| 110
| 4,016
| 422
|
N, A, B = list(map(int, input().split()))
S = input()
passed_num = 0
passed_foreigners_num = 0
for i in S:
if passed_num < A + B:
if i == 'a':
print('Yes')
passed_num += 1
elif i == 'b' and passed_foreigners_num < B:
print('Yes')
passed_num += 1
passed_foreigners_num += 1
else:
print('No')
else:
print('No')
|
s239401768
|
p03409
|
u197078193
| 2,000
| 262,144
|
Wrong Answer
| 42
| 3,508
| 451
|
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.
|
N = int(input())
A = [[int(i) for i in reversed(input().split())] for n in range(N)]
B = [[int(i) for i in input().split()] for n in range(N)]
A.sort(); A.reverse(); B.sort()
C = 0
i = 0
for b in B:
found = False
while not found:
a = A[i]
if a[1] < b[0] and a[0] < b[1]:
found = True
C += 1
A.pop(i)
i = 0
elif i+1 == len(A):
found = True
i = 0
else:
i += 1
print(a,b,found,C)
print(C)
|
s538694057
|
Accepted
| 21
| 3,064
| 428
|
N = int(input())
A = [[int(i) for i in reversed(input().split())] for n in range(N)]
B = [[int(i) for i in input().split()] for n in range(N)]
A.sort(); A.reverse(); B.sort()
C = 0
i = 0
for b in B:
found = False
while not found:
a = A[i]
if a[1] < b[0] and a[0] < b[1]:
found = True
C += 1
A.pop(i)
i = 0
elif i+1 == len(A):
found = True
i = 0
else:
i += 1
print(C)
|
s926742508
|
p02613
|
u165133750
| 2,000
| 1,048,576
|
Wrong Answer
| 145
| 16,616
| 218
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
import collections
n = int(input())
s = [input() for _ in range(n)]
s = collections.Counter(s)
print("AC x " + str(s["AC"]))
print("WA x " + str(s["WA"]))
print("ATLE x " + str(s["TLE"]))
print("RE x " + str(s["RE"]))
|
s394088286
|
Accepted
| 147
| 16,624
| 217
|
import collections
n = int(input())
s = [input() for _ in range(n)]
s = collections.Counter(s)
print("AC x " + str(s["AC"]))
print("WA x " + str(s["WA"]))
print("TLE x " + str(s["TLE"]))
print("RE x " + str(s["RE"]))
|
s120423059
|
p03605
|
u258647915
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 60
|
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
|
n = input()
print("YES" if n[0]=='9' or n[1]=='9' else "NO")
|
s905790189
|
Accepted
| 17
| 2,940
| 60
|
n = input()
print("Yes" if n[0]=='9' or n[1]=='9' else "No")
|
s210679943
|
p03048
|
u267300160
| 2,000
| 1,048,576
|
Wrong Answer
| 2,104
| 3,064
| 300
|
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?
|
R,G,B,N = map(int,input().split())
ans = 0
RGB = sorted([R,G,B],reverse=True)
print(RGB)
R,G,B = RGB[0],RGB[1],RGB[2]
for r in range(-(-N//R)+1):
for g in range(((N-R*r)//G)+1):
for b in range((N-(R*r+G*g)//B)+1):
if(R*r + G*g + B*b == N):
ans += 1
print(ans)
|
s382365230
|
Accepted
| 1,495
| 2,940
| 164
|
R,G,B,N = map(int,input().split())
ans = 0
for r in range(N//R+1):
for g in range((N-R*r)//G+1):
if (N-R*r-G*g)%B == 0:
ans += 1
print(ans)
|
s474807402
|
p03069
|
u202634017
| 2,000
| 1,048,576
|
Wrong Answer
| 2,104
| 4,840
| 462
|
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.
|
N = int(input())
S = input()
ans = 2*10**5+1
tmp = 0
S_list = list(S)
S_list.insert(0,"+")
S_list.insert(N+1,"+")
for i in reversed(range(1,N+1)):
if (S_list[i] == "."):
for j in range(0,i):
if (S_list[j] == "#"):
tmp += 1
for j in range(i+1,len(S_list)):
if (S_list[j] == "."):
tmp += 1
print(tmp)
if tmp < ans :
ans = tmp
tmp = 0
print(ans)
|
s099108725
|
Accepted
| 173
| 3,500
| 296
|
N = int(input())
S = input()
lS = len(S)
l = 0
bw = [0, 0]
for i in range(lS):
if (S[i] == "."):
bw[1] += 1
ans = sum(bw)
for i in range(lS):
if (S[i] == "#"):
bw[0] += 1
if (S[i] == "."):
bw[1] -= 1
if (ans > sum(bw)):
ans = sum(bw)
print(ans)
|
s573879219
|
p02612
|
u135914156
| 2,000
| 1,048,576
|
Wrong Answer
| 31
| 9,140
| 38
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n=int(input())
ans=n%1000
print(ans)
|
s626370237
|
Accepted
| 25
| 9,148
| 67
|
n=int(input())
ans=1000-n%1000
if ans==1000:
ans=0
print(ans)
|
s288693778
|
p03680
|
u210440747
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 104,428
| 466
|
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
|
if __name__ == "__main__":
N = int(input())
a = [int(input()) for _ in range(N)]
index = 0
count = 0
number = 1
flags = [0 for _ in range(N)]
flags[index] = 1
while(number != 2):
number = a[index]
index = number - 1
count += 1
print(flags)
if flags[index] == 1:
break
else:
flags[index] = 1
if number == 2:
print(count)
else:
print(-1)
|
s808055927
|
Accepted
| 207
| 7,852
| 444
|
if __name__ == "__main__":
N = int(input())
a = [int(input()) for _ in range(N)]
index = 0
count = 0
number = 1
flags = [0 for _ in range(N)]
flags[index] = 1
while(number != 2):
number = a[index]
index = number - 1
count += 1
if flags[index] == 1:
break
else:
flags[index] = 1
if number == 2:
print(count)
else:
print(-1)
|
s435268044
|
p03635
|
u439392790
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 56
|
In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?
|
s=input()
print(s[0])
print(str(len(s)-2))
print(s[-1])
|
s326110144
|
Accepted
| 17
| 2,940
| 47
|
a,b=map(int,input().split())
print((a-1)*(b-1))
|
s466451727
|
p02850
|
u941753895
| 2,000
| 1,048,576
|
Wrong Answer
| 371
| 25,912
| 953
|
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colorings satisfying the condition above, construct one that uses the minimum number of colors.
|
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy
sys.setrecursionlimit(10**7)
inf=10**20
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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()
def main():
n=I()
edges=[[]*n for _ in range(n)]
for _ in range(n-1):
a,b=LI()
a-=1
b-=1
edges[a].append(b)
edges[b].append(a)
colors=[0]*n
colors[0]=1
q=collections.deque()
q.append((0,1))
while q:
a,c=q.popleft()
color=1
for b in edges[a]:
if color==c:
color+=1
if colors[b]!=0:
continue
colors[b]=color
q.append((b,color))
color+=1
for x in colors:
print(x)
main()
# print(main())
|
s205270843
|
Accepted
| 619
| 61,760
| 1,036
|
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy
sys.setrecursionlimit(10**7)
inf=10**20
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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()
def main():
n=I()
G=[[]*n for _ in range(n)]
vp=[]
for _ in range(n-1):
a,b=LI()
a-=1
b-=1
G[a].append(b)
G[b].append(a)
vp.append((a,b))
k=0
d={}
cs=[0]*n
used=[False]*n
used[0]=True
q=collections.deque()
q.append(0)
while q:
v=q.popleft()
k=max(k,len(G[v]))
cur=1
for u in G[v]:
if used[u]:
continue
if cur==cs[v]:
cur+=1
cs[u]=d[(u,v)]=d[(v,u)]=cur
cur+=1
used[u]=True
q.append(u)
print(k)
for a,b in vp:
print(d[(a,b)])
main()
# print(main())
|
s926108688
|
p04029
|
u185424824
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 63
|
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
N = int(input())
n = 0
for i in range(N):
n =+ i+1
print(n)
|
s322732069
|
Accepted
| 17
| 2,940
| 63
|
N = int(input())
n = 0
for i in range(N):
n += i+1
print(n)
|
s293417514
|
p02663
|
u536034761
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 9,092
| 73
|
In this problem, we use the 24-hour clock. Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying?
|
H, M, h, m, K = map(int, input().split())
print((60*h + m - 60*H - M)//K)
|
s483637766
|
Accepted
| 22
| 9,148
| 72
|
H, M, h, m, K = map(int, input().split())
print(60*h + m - 60*H - M - K)
|
s636157040
|
p03080
|
u688375653
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 127
|
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
|
input()
DATA=input()
R=DATA.count("R")
B=DATA.count("B")
if R< B:
print("R")
elif B>R:
print("B")
else:
print("No")
|
s788569512
|
Accepted
| 17
| 2,940
| 104
|
input()
DATA=input()
R=DATA.count("R")
B=DATA.count("B")
if R> B:
print("Yes")
else:
print("No")
|
s711355954
|
p02865
|
u306497037
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 70
|
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
|
n = int(input())
if n % 2 == 0:
print(n/2-1)
else:
print((n-1)/2)
|
s091355640
|
Accepted
| 18
| 2,940
| 78
|
n = int(input())
if n%2 == 0:
print(int(n/2-1))
else:
print(int((n-1)/2))
|
s892111794
|
p03476
|
u047197186
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,206
| 9,268
| 320
|
We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime. You are given Q queries. In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.
|
q = int(input())
primes = [2]
for L in range(3, 100000, 2):
for L2 in primes:
if L % L2 == 0:
break
else:
primes.append(L)
for i in range(q):
cnt = 0
l, r = map(int, input().split())
for j in range(l, r+1):
if j in primes and (j+1)//2 in primes:
cnt += 1
print(cnt)
|
s887859276
|
Accepted
| 504
| 12,780
| 379
|
flag = [False]*100001
c = [0]*100002
n = int(input())
for i in range(2,100000):
if(not(flag[i])):
for j in range(i+i,100000,i):
flag[j] = True
for i in range(3,100000,2):
if(not(flag[i]) and not(flag[(i+1)//2])):
c[i]+=1
for i in range(3,100000):
c[i]+=c[i-1]
while(n):
n-=1
l,r = map(int,input().split())
print(c[r]-c[l-1])
|
s316587302
|
p03486
|
u138045722
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,060
| 199
|
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
a=list(input())
b=list(input())
a.sort()
b.sort(reverse=True)
i=0
while i <= min(len(a), len(b))-1:
if a[i] > b[i]:
print('No')
break
i+=1
else:
print('Yes')
|
s579700295
|
Accepted
| 17
| 3,060
| 220
|
a=list(input())
b=list(input())
a.sort()
b.sort(reverse=True)
i=0
while a[i] == b[i] and i<min(len(a),len(b))-1:
i+=1
if a[i]<b[i] or (a[i]==b[i] and len(a)<len(b)):
print('Yes')
else:
print('No')
|
s535800830
|
p03998
|
u215065194
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 232
|
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game.
|
a=input()
b=input()
c=input()
dic={'a':[_ for _ in a],'b':[_ for _ in b],'c':[_ for _ in c]}
char='a'
print(dic)
for i in range(len(a)+len(b)+len(c)):
if len(dic[char]) == 0:
break
char = dic[char].pop(0)
print(char)
|
s819982925
|
Accepted
| 17
| 3,064
| 229
|
a=input()
b=input()
c=input()
dic={'a':[_ for _ in a],'b':[_ for _ in b],'c':[_ for _ in c]}
char='a'
for i in range(len(a)+len(b)+len(c)):
if len(dic[char]) == 0:
break
char = dic[char].pop(0)
print(char.upper())
|
s422338378
|
p02389
|
u567380442
| 1,000
| 131,072
|
Wrong Answer
| 30
| 6,720
| 62
|
Write a program which calculates the area and perimeter of a given rectangle.
|
a, b = map(int, input().split())
print(a * b)
print(2 * a * b)
|
s825852555
|
Accepted
| 30
| 6,720
| 73
|
a, b = map(int, input().split())
print(a * b, end=' ')
print(2 * (a + b))
|
s800261848
|
p03457
|
u859897687
| 2,000
| 262,144
|
Wrong Answer
| 369
| 3,060
| 190
|
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
n=int(input())
tt,xx,yy=0,0,0
ans=0
for i in range(n):
t,x,y=map(int,input().split())
if (x-xx+y-yy)%2>0:
ans=1
if x-xx+y-yy>t-tt:
ans=1
tt,xx,yy=t,x,y
print("YNeos"[ans::2])
|
s446114242
|
Accepted
| 377
| 3,064
| 198
|
n=int(input())
tt,xx,yy=0,0,0
ans=0
for i in range(n):
t,x,y=map(int,input().split())
if (x-xx+y-yy)%2!=(t-tt)%2:
ans=1
if x-xx+y-yy>t-tt:
ans=1
tt,xx,yy=t,x,y
print("YNeos"[ans::2])
|
s780145064
|
p02663
|
u445807804
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,064
| 187
|
In this problem, we use the 24-hour clock. Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying?
|
def resolve():
T = input()
S = ""
for i in range(len(T)):
if T[i] == "D" or T[i] == "?":
S += "D"
else:
S += "P"
print(S)
resolve()
|
s562196594
|
Accepted
| 30
| 9,100
| 107
|
H_1,M_1,H_2,M_2,K = map(int,input().split())
time_1 = H_1*60+M_1
time_2 = H_2*60+M_2
print(time_2-time_1-K)
|
s076121375
|
p03997
|
u439392790
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 61
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h/2)
|
s868777607
|
Accepted
| 18
| 2,940
| 66
|
a=int(input())
b=int(input())
h=int(input())
print(int((a+b)*h/2))
|
s599832397
|
p00013
|
u618637847
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,528
| 177
|
This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top- right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. We can simulate the movement (comings and goings) of the cars as follow: * An entry of a car is represented by its number. * An exit of a car is represented by 0 For example, a sequence 1 6 0 8 10 demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks.
|
list = {}
while True:
try:
num = int(input())
if num == 0:
print(list.pop())
else:
list.append(num)
except:
break
|
s252183342
|
Accepted
| 10
| 7,432
| 177
|
list = []
while True:
try:
num = int(input())
if num == 0:
print(list.pop())
else:
list.append(num)
except:
break
|
s136923603
|
p03471
|
u217940964
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 3,060
| 266
|
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
N, Y = map(int, input().split())
ans = '-1 -1 -1'
for i in range(N+1):
for j in range(N+1 -i):
for k in range(N+1 -i -j):
if (i*10000 + j*5000 + k*1000) == Y:
ans = '{} {} {}'.format(i, j, k)
break
print(ans)
|
s033827368
|
Accepted
| 918
| 3,060
| 357
|
N, Y = map(int, input().split())
count_max = Y / 1000 # all 1000
ans = '-1 -1 -1'
for i in range(N+1): # 10000
for j in range(N+1 - i): # 5000
k = N - i - j
if k < 0:
continue
total = 10000 * i + 5000 * j + 1000 * k
if total == Y:
ans = '{} {} {}'.format(i, j, k)
break
print(ans)
|
s490893122
|
p02796
|
u496821919
| 2,000
| 1,048,576
|
Wrong Answer
| 454
| 20,640
| 339
|
In a factory, there are N robots placed on a number line. Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative. We want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect. Here, for each i (1 \leq i \leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints. Find the maximum number of robots that we can keep.
|
from operator import itemgetter
N = int(input())
X = []
L = []
for i in range(N):
a,b = map(int,input().split())
X.append(a-b)
L.append(a+b)
xl = sorted([(X[i],L[i]) for i in range(N)], key = itemgetter(1))
ans = 0
last = 0
for i in range(N):
if last <= xl[i][0]:
ans += 1
last = xl[i][1]
print(ans)
|
s297666423
|
Accepted
| 429
| 20,572
| 351
|
from operator import itemgetter
N = int(input())
X = []
L = []
for i in range(N):
a,b = map(int,input().split())
X.append(a-b)
L.append(a+b)
xl = sorted([(X[i],L[i]) for i in range(N)], key = itemgetter(1))
ans = 0
last = -float("inf")
for i in range(N):
if last <= xl[i][0]:
ans += 1
last = xl[i][1]
print(ans)
|
s148700662
|
p02613
|
u670567845
| 2,000
| 1,048,576
|
Wrong Answer
| 143
| 16,320
| 207
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
N=int(input())
list = [input() for i in range(N)]
print('AC x ' + str(list.count('AC')))
print('WA x ' + str(list.count('WA')))
print('TLE x ' + str(list.count('TLE')))
print('RA x ' + str(list.count('RA')))
|
s250495005
|
Accepted
| 145
| 16,292
| 207
|
N=int(input())
list = [input() for i in range(N)]
print('AC x ' + str(list.count('AC')))
print('WA x ' + str(list.count('WA')))
print('TLE x ' + str(list.count('TLE')))
print('RE x ' + str(list.count('RE')))
|
s150290990
|
p04030
|
u059262067
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 108
|
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
|
x = input()
for i in range(11):
x.replace('1B', '')
x.replace('0B', '')
x.replace('B', '')
print(x)
|
s162424793
|
Accepted
| 17
| 2,940
| 112
|
x = input()
for i in range(11):
x=x.replace('1B', '')
x=x.replace('0B', '')
x=x.replace('B', '')
print(x)
|
s970455461
|
p04044
|
u995062424
| 2,000
| 262,144
|
Wrong Answer
| 21
| 3,060
| 217
|
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
|
n, l = map(int, input().split())
s = []
for _ in range(n):
s.append(input())
for j in range(n-1):
for i in range(n):
if(s[i] < s[i-1]):
s[i], s[i-1] = s[i-1], s[i]
print(''.join(s))
|
s410617616
|
Accepted
| 17
| 3,060
| 109
|
n, l = map(int, input().split())
s = []
for _ in range(n):
s.append(input())
s.sort()
print(''.join(s))
|
s628941316
|
p04043
|
u733321071
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 249
|
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
# -*- coding: utf-8 -*-
a_b_c = list(map(int, input().split()))
tmp = [5, 7, 5]
flag = True
for i in a_b_c:
if i in tmp:
tmp.remove(i)
else:
print('No')
flag = False
break
if flag:
print('Yes')
|
s477286101
|
Accepted
| 17
| 2,940
| 241
|
# -*- coding: utf-8 -*-
a_b_c = list(map(int, input().split()))
tmp = [5, 7, 5]
flag = True
for i in a_b_c:
if i in tmp:
tmp.remove(i)
else:
print('NO')
flag = False
break
if flag:
print('YES')
|
s104254431
|
p02393
|
u187646742
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,604
| 63
|
Write a program which reads three integers, and prints them in ascending order.
|
a = list(map(int,input().split()))
print(" ".join(map(str, a)))
|
s016760306
|
Accepted
| 60
| 7,680
| 72
|
a = list(map(int,input().split()))
a.sort()
print(" ".join(map(str, a)))
|
s671473122
|
p03861
|
u352359612
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 103
|
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
a, b, x = input().split()
if x <= b:
print(int(b) // int(x) - int(a) // int(x))
else:
print(0)
|
s153673969
|
Accepted
| 17
| 3,060
| 215
|
a, b, x = input().split()
a = int(a)
b = int(b)
x = int(x)
if a % x == 0 and x <= b:
print(b // x - a // x + 1)
elif x <= b:
print(b // x - a // x)
elif a % x == 0 and x > b:
print(1)
else:
print(0)
|
s346610025
|
p03129
|
u739528957
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 93
|
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
|
def antiAdjacency(n, k):
if n - k > 0:
return "YES"
else:
return "NO"
|
s015106125
|
Accepted
| 17
| 2,940
| 114
|
n, k = (int(i) for i in input().split())
re = ""
if (2 * k - 1) <= n:
re = "YES"
else:
re = "NO"
print(re)
|
s459559911
|
p03795
|
u685244071
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 129
|
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
n = int(input())
cash_out = 600 * n
count_back = n//15
cash_in = 200 *count_back
cash_net = cash_out - cash_in
print(cash_net)
|
s809231827
|
Accepted
| 17
| 2,940
| 65
|
n = int(input())
x = 800 * n
c = n//15
y = 200 * c
print(x - y)
|
s920361779
|
p03448
|
u149752754
| 2,000
| 262,144
|
Wrong Answer
| 76
| 8,280
| 309
|
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
a = int(input())
b = int(input())
c = int(input())
x = int(input())
LI = []
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
x = 500*i+100*j+50*k
LI.append(x)
counter = 0
for l in range(len((LI))):
if LI[l] == x:
counter += 1
print(counter)
|
s798765970
|
Accepted
| 79
| 8,276
| 309
|
a = int(input())
b = int(input())
c = int(input())
x = int(input())
LI = []
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
y = 500*i+100*j+50*k
LI.append(y)
counter = 0
for l in range(len((LI))):
if LI[l] == x:
counter += 1
print(counter)
|
s434643204
|
p04030
|
u663710122
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 147
|
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
|
# S = input()
# for s in S:
# if s == 'B' and len(s):
# ret.pop()
# else:
# ret.append(s)
# print(''.join(ret))
|
s502272968
|
Accepted
| 18
| 2,940
| 144
|
S = input()
ret = []
for s in S:
if s == 'B':
if len(ret):
ret.pop()
else:
ret.append(s)
print(''.join(ret))
|
s431690791
|
p00001
|
u305077559
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,648
| 194
|
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
|
if __name__ == "__main__":
a = []
for i in range(0,10):
val = input()
int(val)
a.append(val)
a.reverse()
for i in range(0,3):
print(a[i])
|
s421872513
|
Accepted
| 20
| 7,612
| 187
|
if __name__ == "__main__":
a = []
for i in range(0,10):
val = input()
a.append(int(val))
a.sort()
a.reverse()
for i in range(0,3):
print(a[i])
|
s338528974
|
p03657
|
u487288850
| 2,000
| 262,144
|
Wrong Answer
| 23
| 9,144
| 96
|
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
|
a,b=map(int,input().split())
print('Possible' if a%3==0 or b%3==0 or (a+b)%3 else "Impossible")
|
s008687777
|
Accepted
| 27
| 9,028
| 99
|
a,b=map(int,input().split())
print('Possible' if a%3==0 or b%3==0 or (a+b)%3==0 else "Impossible")
|
s412443182
|
p03433
|
u951947571
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 123
|
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
n = int(input())
a = int(input())
remainder = n % 500
if remainder <= a and a > 0:
print(True)
else:
print(False)
|
s204196631
|
Accepted
| 17
| 2,940
| 158
|
# !/usr/bin python3
# -*- coding: utf-8 -*-
n = int(input())
a = int(input())
remainder = n % 500
if remainder <= a:
print('Yes')
else:
print('No')
|
s557103722
|
p02748
|
u517152997
| 2,000
| 1,048,576
|
Wrong Answer
| 943
| 51,148
| 618
|
You are visiting a large electronics store to buy a refrigerator and a microwave. The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen. You have M discount tickets. With the i-th ticket ( 1 \le i \le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time. You are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.
|
#
import sys
import math
import numpy as np
import itertools
a, b, m = (int(i) for i in input().split())
aprice = [int(i) for i in input().split()]
bprice = [int(i) for i in input().split()]
c = [[int(i) for i in input().split()] for i in range(m)]
print(aprice,bprice,c)
amin=999999
for i in range(a):
amin = min(amin,aprice[i])
bmin=999999
for i in range(b):
bmin = min(bmin,bprice[i])
p=[]
for i in range(m):
print(c[i][0],c[i][1],c[i][2])
p.append(aprice[c[i][0]-1]+bprice[c[i][1]-1]-c[i][2])
answer = amin+bmin
for i in p:
answer = min(answer, i)
print(answer)
|
s840301295
|
Accepted
| 677
| 45,500
| 620
|
#
import sys
import math
import numpy as np
import itertools
a, b, m = (int(i) for i in input().split())
aprice = [int(i) for i in input().split()]
bprice = [int(i) for i in input().split()]
c = [[int(i) for i in input().split()] for i in range(m)]
#print(aprice,bprice,c)
amin=999999
for i in range(a):
amin = min(amin,aprice[i])
bmin=999999
for i in range(b):
bmin = min(bmin,bprice[i])
p=[]
for i in range(m):
# print(c[i][0],c[i][1],c[i][2])
p.append(aprice[c[i][0]-1]+bprice[c[i][1]-1]-c[i][2])
answer = amin+bmin
for i in p:
answer = min(answer, i)
print(answer)
|
s710550583
|
p04029
|
u897328029
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 57
|
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
n = int(input())
ans = sum(list(range(n, 0)))
print(ans)
|
s565108315
|
Accepted
| 17
| 2,940
| 61
|
n = int(input())
ans = sum(list(range(n, 0, -1)))
print(ans)
|
s322346204
|
p03836
|
u518958552
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 254
|
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
sx, sy ,tx, ty = map(int,input().split())
momo=""
xz = abs(tx-sx)
yz = abs(ty-sy)
momo += "U" * yz + "R" * xz + "D" * yz + "L" * xz
momo += "L" * 1 + "U" * (yz+1) + "R" * (xz+1) + "D" * 1
momo += "R" * 1 + "D" * yz + "L" * 1 + "D" *1 + "L"*xz
print(momo)
|
s101094844
|
Accepted
| 17
| 3,060
| 255
|
sx, sy ,tx, ty = map(int,input().split())
momo=""
xz = abs(tx-sx)
yz = abs(ty-sy)
momo += "U" * yz + "R" * xz + "D" * yz + "L" * xz
momo += "L" * 1 + "U" * (yz+1) + "R" * (xz+1) + "D" * 1
momo += "R" * 1 + "D" * (yz+1) + "L" * (xz+1) + "U" * 1
print(momo)
|
s381786646
|
p03814
|
u940102677
| 2,000
| 262,144
|
Wrong Answer
| 96
| 4,840
| 160
|
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
s = list(input())
n = len(s)
i = 0
while i<n:
if s[i] == "a":
break
i += 1
j=n-1
while j>0:
if s[j] == "z":
break
j -= 1
print(j-i+1)
|
s841244196
|
Accepted
| 56
| 4,840
| 160
|
s = list(input())
n = len(s)
i = 0
while i<n:
if s[i] == "A":
break
i += 1
j=n-1
while j>0:
if s[j] == "Z":
break
j -= 1
print(j-i+1)
|
s719651619
|
p03836
|
u219197917
| 2,000
| 262,144
|
Wrong Answer
| 21
| 3,188
| 254
|
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
sx, sy, tx, ty = map(int, input().split())
x, y = tx - sx, ty - sy
print(x, y)
u, d, l, r = "UDLR"
p = ""
p += u * y
p += r * x
p += d * y
p += l * x
p += l
p += u * (y + 1)
p += r * (x + 1)
p += d
p += r
p += d * (y + 1)
p += l * (x + 1)
p += u
print(p)
|
s215169095
|
Accepted
| 19
| 3,060
| 122
|
a,b,c,d=map(int,input().split());x,y=c-a,d-b;u,d,l,r="UDLR";print(u*y+r*x+d*y+l*x+l+u*(y+1)+r*(x+1)+d+r+d*(y+1)+l*(x+1)+u)
|
s164482241
|
p02678
|
u674052742
| 2,000
| 1,048,576
|
Wrong Answer
| 807
| 34,980
| 733
|
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
# -*- coding: utf-8 -*-
"""
Created on Sun May 17 20:56:20 2020
@author: Kanaru Sato
"""
import collections
n,m = list(map(int,input().split()))
connected = [[]for i in range(n+1)]
for i in range(m):
a,b = list(map(int,input().split()))
connected[a].append(b)
connected[b].append(a)
distance = [-1,0]
for i in range(n-1):
distance.append(-1)
ans = [-1 for i in range(n+1)]
ans[1] = 1
q = [1]
q = collections.deque(q)
while q:
cp = q.popleft()
for np in connected[cp]:
if ans[np] == -1 or distance[ans[np]] > distance[cp]:
print(np,cp)
q.append(np)
ans[np] = cp
distance[np] = distance[cp] + 1
print("Yes")
for i in range(n-1):
print(ans[i+2])
|
s357864616
|
Accepted
| 819
| 35,108
| 708
|
# -*- coding: utf-8 -*-
"""
Created on Sun May 17 20:56:20 2020
@author: Kanaru Sato
"""
import collections
n,m = list(map(int,input().split()))
connected = [[]for i in range(n+1)]
for i in range(m):
a,b = list(map(int,input().split()))
connected[a].append(b)
connected[b].append(a)
distance = [-1,0]
for i in range(n-1):
distance.append(-1)
ans = [-1 for i in range(n+1)]
ans[1] = 1
q = [1]
q = collections.deque(q)
while q:
cp = q.popleft()
for np in connected[cp]:
if ans[np] == -1 or distance[ans[np]] > distance[cp]:
q.append(np)
ans[np] = cp
distance[np] = distance[cp] + 1
print("Yes")
for i in range(n-1):
print(ans[i+2])
|
s573875954
|
p04043
|
u696491170
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 392
|
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
def main():
input_str = input()
a,b,c = input_str.split(' ')
a = int(a)
b = int(b)
c = int(c)
flag = False
for i in [a,b,c,'fin']:
if i == 'fin':
if a+b+c== 15:
flag = True
elif not i in [5,7]:
break
if flag:
print('YES')
else:
print('NO')
if __name__=='__main__':
main()
|
s352510939
|
Accepted
| 17
| 3,060
| 392
|
def main():
input_str = input()
a,b,c = input_str.split(' ')
a = int(a)
b = int(b)
c = int(c)
flag = False
for i in [a,b,c,'fin']:
if i == 'fin':
if a+b+c== 17:
flag = True
elif not i in [5,7]:
break
if flag:
print('YES')
else:
print('NO')
if __name__=='__main__':
main()
|
s183738122
|
p03370
|
u112002050
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 129
|
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
|
N,X = map(int,input().split())
d = sorted([int(i) for i in input().split()])
answer = len(d) + (X - sum(d)) // d[0]
print(answer)
|
s912443675
|
Accepted
| 17
| 2,940
| 129
|
N,X = map(int,input().split())
d = sorted([int(input()) for _ in range(N)])
answer = len(d) + (X - sum(d)) // d[0]
print(answer)
|
s695182800
|
p02578
|
u617953889
| 2,000
| 1,048,576
|
Wrong Answer
| 135
| 32,188
| 134
|
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
|
n = int(input())
a = list(map(int,input().split()))
c = 0
for i in range(1,n):
if a[i-1]>a[i]:
c += (a[i-1]-a[i])
print(c)
|
s301252338
|
Accepted
| 168
| 32,212
| 170
|
n = int(input())
a = list(map(int,input().split()))
c = 0
for i in range(1,n):
if a[i-1]>a[i]:
q = (a[i-1]-a[i])
c += q
a[i] = a[i]+q
print(c)
|
s322676653
|
p02936
|
u669173971
| 2,000
| 1,048,576
|
Wrong Answer
| 1,260
| 18,928
| 320
|
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations.
|
n,q=map(int,input().split())
par=[-1]*n
par[0]=0
ans=[0]*n
for i in range(n-1):
a,b=map(int,input().split())
if par[a-1]>-1:
par[b-1]=a
elif par[b-1]>-1:
par[a-1]=b
for i in range(q):
p,x=map(int,input().split())
ans[p-1]+=x
for i in range(1,n):
ans[i]+=ans[par[i]-1]
print(ans)
|
s816159848
|
Accepted
| 1,800
| 56,088
| 461
|
from collections import deque
n,q=map(int,input().split())
arr=[[] for _ in range(n)]
ans=[0]*n
for i in range(n-1):
a,b=map(int,input().split())
arr[a-1].append(b-1)
arr[b-1].append(a-1)
for i in range(q):
p,x=map(int,input().split())
ans[p-1]+=x
que=deque([0])
visited=[0]*n
while que:
x=que.popleft()
visited[x]=-1
for i in arr[x]:
if visited[i]>-1:
ans[i]+=ans[x]
que.append(i)
print(*ans)
|
s037517331
|
p03140
|
u035453792
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 9,112
| 238
|
You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters. Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation: * Operation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter. What is the minimum number of operations required to achieve the objective?
|
n = int(input())
a = input()
b = input()
c = input()
cnt=0
for i in range(n):
if a[i]==b[i] and b[i]==c[i]:
pass
elif a[i]==b[i] or a[i]==c[i] or b[i]==c[i]:
cnt+=1
else:
cnt+=2
|
s359603129
|
Accepted
| 26
| 9,016
| 248
|
n = int(input())
a = input()
b = input()
c = input()
cnt=0
for i in range(n):
if a[i]==b[i] and b[i]==c[i]:
pass
elif a[i]==b[i] or a[i]==c[i] or b[i]==c[i]:
cnt+=1
else:
cnt+=2
print(cnt)
|
s951474047
|
p02602
|
u502731482
| 2,000
| 1,048,576
|
Wrong Answer
| 2,206
| 31,604
| 346
|
M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term. M-kun scored A_i in the exam at the end of the i-th term. For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is **strictly** greater than the grade for the (i-1)-th term.
|
n, k = map(int, input().split())
a = list(map(int, input().split()))
score = [0] * (n - k + 1)
x = 1
for i in range(n):
x *= a[i]
if i >= k - 1:
print(x, a[i])
score[i - k + 1] = x
x //= a[i - k + 1]
for i in range(1, n - k + 1):
if score[i - 1] < score[i]:
print("Yes")
else:
print("No")
|
s467727567
|
Accepted
| 185
| 32,396
| 337
|
from collections import deque
n, k = map(int, input().split())
a = list(map(int, input().split()))
queue = deque()
for i in range(n):
if i <= k - 1:
queue.append(a[i])
elif i >= k:
x = queue.popleft()
if x < a[i]:
print("Yes")
else:
print("No")
queue.append(a[i])
|
s506849966
|
p03131
|
u945418216
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 99
|
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
|
K,A,B = map(int, input().split())
rest = K- (A-1)
b = A + (B-1)*rest//2 + rest%2
print(max(K+1, b))
|
s947218128
|
Accepted
| 17
| 2,940
| 120
|
K,A,B = map(int, input().split())
rest = K- (A-1)
b=0
if rest>0:
b = A + (B-A)*(rest//2) + rest%2
print(max(K+1, b))
|
s707949479
|
p00424
|
u847467233
| 1,000
| 131,072
|
Wrong Answer
| 300
| 5,720
| 314
|
与えられた変換表にもとづき,データを変換するプログラムを作成しなさい. データに使われている文字は英字か数字で,英字は大文字と小文字を区別する.変換表に現れる文字の順序に規則性はない. 変換表は空白をはさんで前と後ろの 2 つの文字がある(文字列ではない).変換方法は,変換表のある行の前の文字がデータに現れたら,そのたびにその文字を後ろの文字に変換し出力する.変換は 1 度だけで,変換した文字がまた変換対象の文字になっても変換しない.変換表に現れない文字は変換せず,そのまま出力する. 入力ファイルには,変換表(最初の n + 1 行)に続き変換するデータ(n + 2 行目以降)が書いてある. 1 行目に変換表の行数 n,続く n 行の各行は,空白をはさんで 2 つの文字,さらに続けて, n + 2 行目に変換するデータの行数 m,続く m 行の各行は 1 文字である. m ≤ 105 とする.出力は,出力例のように途中に空白や改行は入れず 1 行とせよ. 入力例 --- 3 A a 0 5 5 4 10 A B C 0 1 4 5 a b A 出力例 aBC5144aba
|
# AOJ 0501: Data Conversion
# Python3 2018.6.29 bal4u
while True:
n = int(input())
if n == 0: break
tbl = {}
for i in range(n):
a, b = input().split()
print("i=",i,a,b)
tbl[a] = b
ans = ''
m = int(input())
for i in range(m):
a = input()[0]
if a in tbl: ans += tbl[a]
else: ans += a
print(ans)
|
s394650777
|
Accepted
| 290
| 5,708
| 283
|
# AOJ 0501: Data Conversion
# Python3 2018.6.29 bal4u
while True:
n = int(input())
if n == 0: break
tbl = {}
for i in range(n):
a, b = input().split()
tbl[a] = b
ans = ''
m = int(input())
for i in range(m):
a = input()[0]
ans += tbl[a] if a in tbl else a
print(ans)
|
s352506406
|
p03909
|
u932465688
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 288
|
There is a grid with H rows and W columns. The square at the i-th row and j-th column contains a string S_{i,j} of length 5. The rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `A` through the W-th letter of the alphabet. Exactly one of the squares in the grid contains the string `snuke`. Find this square and report its location. For example, the square at the 6-th row and 8-th column should be reported as `H6`.
|
H,W = map(int,input().split())
A = [list(input().split()) for i in range(H)]
for j in range(H):
for k in range(W):
if (A[j][k] == 'snuke'):
break
L = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
print(L[k-1]+str(j))
|
s001423083
|
Accepted
| 18
| 3,064
| 319
|
H,W = map(int,input().split())
L = []
A = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
for i in range(H):
L.append(input().split())
for i in range(H):
for j in range(W):
if L[i][j] == 'snuke':
k = i+1
l = A[j]
break
print(l+str(k))
|
s306111842
|
p03836
|
u556160473
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 171
|
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
sx,sy,tx,ty = map(int,input().split(' '))
w,h = abs(sx-tx),abs(sy-ty)
res = 'U'*h+'R'*w+'D'*h+'L'*w
res += 'L'+'U'*(h+1)+'R'*(h+1)+'DR'+'D'*(h+1)+'L'*(w+1)+'U'
print(res)
|
s612491029
|
Accepted
| 31
| 3,060
| 171
|
sx,sy,tx,ty = map(int,input().split(' '))
w,h = abs(sx-tx),abs(sy-ty)
res = 'U'*h+'R'*w+'D'*h+'L'*w
res += 'L'+'U'*(h+1)+'R'*(w+1)+'DR'+'D'*(h+1)+'L'*(w+1)+'U'
print(res)
|
s988190257
|
p03149
|
u816070625
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 164
|
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
|
a=list(map(int,input().split()))
b=[1,7,9,4]
c=[0]*4
d=[True,True,True,True]
for i in range(4):
c[i]=(b[i] in a)
if c==d:
print("Yes")
else:
print("No")
|
s103678712
|
Accepted
| 17
| 2,940
| 164
|
a=list(map(int,input().split()))
b=[1,7,9,4]
c=[0]*4
d=[True,True,True,True]
for i in range(4):
c[i]=(b[i] in a)
if c==d:
print("YES")
else:
print("NO")
|
s624007224
|
p03610
|
u526532903
| 2,000
| 262,144
|
Wrong Answer
| 39
| 3,188
| 82
|
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
|
x = ""
s = input()
for i in range(len(s)):
if i % 2 == 1:
x = x + s[i]
print(x)
|
s178655539
|
Accepted
| 42
| 3,188
| 82
|
x = ""
s = input()
for i in range(len(s)):
if i % 2 == 0:
x = x + s[i]
print(x)
|
s441641527
|
p03433
|
u372259664
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 110
|
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
N = input()
A = input()
N = int(N)
A = int(A)
rest = N % 500
if rest<=A:
print("yes")
else:print("No")
|
s226663481
|
Accepted
| 17
| 2,940
| 116
|
N = input()
A = input()
N = int(N)
A = int(A)
rest = N % 500
if rest<=A:
print("Yes")
else:
print("No")
|
s358879269
|
p02690
|
u536034761
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 9,056
| 239
|
Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X.
|
N = input()
a = [i**5 for i in range(120)]
for i in range(120):
for j in range(i + 1, 120):
if a[j] - a[i] == N:
print(j, i)
break
if a[j] + a[i] == N:
print(j, -i)
break
else:
continue
break
|
s208119802
|
Accepted
| 23
| 9,164
| 245
|
N = int(input())
a = [i**5 for i in range(120)]
for i in range(120):
for j in range(i + 1, 120):
if a[j] - a[i] == N:
print(j, i)
break
if a[j] + a[i] == N:
print(j, -i)
break
else:
continue
break
|
s384905806
|
p02393
|
u316702155
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,572
| 67
|
Write a program which reads three integers, and prints them in ascending order.
|
z = input()
z = z.split( )
list(map(int, z))
z.sort()
print(z)
|
s845618992
|
Accepted
| 20
| 5,588
| 96
|
z = input()
z = z.split( )
list(map(int, z))
z.sort()
print(z[0] + ' ' + z[1] + ' ' + z[2])
|
s869643995
|
p02678
|
u374531474
| 2,000
| 1,048,576
|
Wrong Answer
| 767
| 42,876
| 517
|
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
from collections import defaultdict, deque
N, M = map(int, input().split())
X = defaultdict(list)
for i in range(M):
Ai, Bi = map(lambda s: int(s) - 1, input().split())
X[Ai].append(Bi)
X[Bi].append(Ai)
V = [False] * N
P = [0] * N
A = [0] * N
Q = deque([0])
V[0] = True
while len(Q) > 0:
r = Q.popleft()
for nr in X[r]:
if V[nr] == True:
continue
V[nr] = True
P[nr] = P[r] + 1
A[nr] = r + 1
Q.append(nr)
for i in range(1, N):
print(A[i])
|
s617427088
|
Accepted
| 840
| 42,840
| 530
|
from collections import defaultdict, deque
N, M = map(int, input().split())
X = defaultdict(list)
for i in range(M):
Ai, Bi = map(lambda s: int(s) - 1, input().split())
X[Ai].append(Bi)
X[Bi].append(Ai)
V = [False] * N
P = [0] * N
A = [0] * N
Q = deque([0])
V[0] = True
while len(Q) > 0:
r = Q.popleft()
for nr in X[r]:
if V[nr] == True:
continue
V[nr] = True
P[nr] = P[r] + 1
A[nr] = r + 1
Q.append(nr)
print('Yes')
for i in range(1, N):
print(A[i])
|
s463359212
|
p03377
|
u167681750
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 84
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
A, B, X = map(int, input().split())
print("YES" if B - X >= 0 and A <= 0 else "NO")
|
s664726154
|
Accepted
| 17
| 2,940
| 87
|
A, B, X = map(int, input().split())
all = A + B
print("YES" if all >= X >= A else "NO")
|
s802968415
|
p03160
|
u430160646
| 2,000
| 1,048,576
|
Wrong Answer
| 2,104
| 111,068
| 300
|
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
n = int(input())
a = list(map(int, input().split()))
a.append(99999)
dp = [0] * (n+1)
dp[0] = 0
for i in range(n):
print(dp)
if (i > 0):
dp[i+1] = min(dp[i] + abs(a[i]-a[i+1]),
dp[i-1] + abs(a[i-1]-a[i+1]) )
else:
dp[i+1] = dp[i] + abs(a[i]-a[i+1])
|
s972247899
|
Accepted
| 135
| 13,976
| 318
|
n = int(input())
a = list(map(int, input().split()))
a.append(99999)
dp = [0] * (n+1)
dp[0] = 0
for i in range(n):
# print(dp)
if (i > 0):
dp[i+1] = min(dp[i] + abs(a[i]-a[i+1]),
dp[i-1] + abs(a[i-1]-a[i+1]) )
else:
dp[i+1] = dp[i] + abs(a[i]-a[i+1])
print(dp[n-1])
|
s219547854
|
p03738
|
u790877102
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 115
|
You are given two positive integers A and B. Compare the magnitudes of these numbers.
|
a = int(input())
b = int(input())
if a<b:
print("LESS")
elif a==b:
print("EQUAL")
else:
print("GRATER")
|
s735934344
|
Accepted
| 17
| 2,940
| 117
|
a = int(input())
b = int(input())
if a<b:
print("LESS")
elif a==b:
print("EQUAL")
else:
print("GREATER")
|
s747091826
|
p03140
|
u509368316
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,060
| 140
|
You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters. Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation: * Operation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter. What is the minimum number of operations required to achieve the objective?
|
n=int(input())
a=input()
b=input()
c=input()
d=0
for i in range(n):
if a[i]!=b[i]!=c[i]:
d+=2
elif not a[i]==b[i]==c[i]:
d+=1
print(d)
|
s238592667
|
Accepted
| 17
| 3,060
| 164
|
n=int(input())
a=input()
b=input()
c=input()
d=0
for i in range(n):
if a[i]!=b[i] and b[i]!=c[i] and a[i]!=c[i]:
d+=2
elif not a[i]==b[i]==c[i]:
d+=1
print(d)
|
s424706949
|
p02409
|
u474232743
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,780
| 348
|
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
|
house = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
for i in range(int(input())):
b, f, r, v = map(int, input().split())
house[b-1][f-1][r-1] += v
for b in range(3, -1, -1):
for f in range(2, -1, -1):
house[b][f].reverse()
print(' ' + ' '.join(map(str, house[b][f])))
print('####################')
|
s097147966
|
Accepted
| 20
| 7,752
| 411
|
house = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
for i in range(int(input())):
b, f, r, v = map(int, input().split())
house[b-1][f-1][r-1] += v
for b in range(4):
for f in range(3):
house[b][f] = ' ' + ' '.join(map(str, house[b][f]))
house[b] = '\n'.join(map(str, house[b])) + '\n'
border = '#' * 20 + '\n'
house = border.join(map(str, house))
print(house.rstrip())
|
s893443040
|
p02608
|
u630467326
| 2,000
| 1,048,576
|
Wrong Answer
| 447
| 9,096
| 256
|
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
N = int(input())
ans = [0 for _ in range(N + 1)]
for x in range(1, 100):
for y in range(1, 100):
for z in range(1, 100):
v = x * x + y * y + z * z + x * y + y * z + z * x
if v < N:
ans[v] += 1
for i in range(N):
print(ans[i])
|
s309954974
|
Accepted
| 466
| 9,084
| 275
|
N = int(input())
ans = [0 for _ in range(N + 1)]
for x in range(1, 101):
for y in range(1, 101):
for z in range(1, 101):
v = x * x + y * y + z * z + x * y + y * z + z * x
if v > N:
continue
ans[v - 1] += 1
for i in range(N):
print(ans[i])
|
s400376871
|
p03565
|
u587589241
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 72
|
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
|
s=input()
t=input()
if t in s:
ans=s.replace("?","a")
print(ans)
|
s483583225
|
Accepted
| 17
| 3,060
| 281
|
s=input()
t=input()
for i in range(len(t)-1,len(s))[::-1]:
if s[i]==t[-1] or s[i]=="?":
if all(s[i-j]==t[-1-j] or s[i-j]=="?" for j in range(len(t))):
s=s.replace("?","a")
print(s[:i-len(t)+1]+t+s[i+1:])
exit()
print("UNRESTORABLE")
|
s295913560
|
p02742
|
u032798323
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 120
|
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
inp = list(map(int,input().split()))
a = inp[0]*inp[1]
if (a %2 == 1):
b = int(a/2)+1
else:
b = a/2
print(b)
|
s560045762
|
Accepted
| 17
| 3,060
| 248
|
inp = list(map(int,input().split()))
a = inp[0]*inp[1]
if (inp[0]==1 or inp[1]==1):
print("1")
else:
if (a %2 == 1):
b = int(a/2)+1
print('{:.19g}'.format(b))
else:
b = a/2
print('{:.19g}'.format(b))
|
s103683780
|
p03814
|
u726439578
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,720
| 58
|
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
s=input()
st=s.find("A")
ed=s.rfind("Z")
print(s[st:ed+1])
|
s055840016
|
Accepted
| 18
| 3,500
| 63
|
s=input()
st=s.find("A")
ed=s.rfind("Z")
print(len(s[st:ed+1]))
|
s550807289
|
p02408
|
u886729200
| 1,000
| 131,072
|
Wrong Answer
| 30
| 5,604
| 623
|
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
|
d = {"S":[1,2,3,4,5,6,7,8,9,10,11,12,13],
"H":[1,2,3,4,5,6,7,8,9,10,11,12,13],
"D":[1,2,3,4,5,6,7,8,9,10,11,12,13],
"C":[1,2,3,4,5,6,7,8,9,10,11,12,13]}
n = int(input())
for i in range(n):
N, M = map(str,input().split())
d[N][int(M)-1] ="None"
print("Answer")
for j in range(len(d)):
if j==1:
list_d = d["S"]
c = "S"
elif j == 2:
list_d = d["H"]
c = "H"
elif j == 3:
list_d = d["C"]
c = "C"
else:
list_d = d["D"]
c = "D"
for i in range(len(list_d)):
if(list_d[i] != "None"):
print(c , list_d[i])
|
s840136705
|
Accepted
| 20
| 5,616
| 608
|
d = {"S":[1,2,3,4,5,6,7,8,9,10,11,12,13],
"H":[1,2,3,4,5,6,7,8,9,10,11,12,13],
"C":[1,2,3,4,5,6,7,8,9,10,11,12,13],
"D":[1,2,3,4,5,6,7,8,9,10,11,12,13]}
n = int(input())
for i in range(n):
N, M = map(str,input().split())
d[N][int(M)-1] ="None"
for j in range(len(d)):
if j==0:
list_d = d["S"]
c = "S"
elif j == 1:
list_d = d["H"]
c = "H"
elif j == 2:
list_d = d["C"]
c = "C"
else:
list_d = d["D"]
c = "D"
for i in range(len(list_d)):
if(list_d[i] != "None"):
print(c , list_d[i])
|
s936068798
|
p02694
|
u731448038
| 2,000
| 1,048,576
|
Wrong Answer
| 21
| 9,084
| 116
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
x = int(input())
a = 100
import sys
for i in range(10**7):
a = int(a*1.01)
if a>x:
print(i+1)
sys.exit()
|
s110004508
|
Accepted
| 23
| 9,160
| 118
|
x = int(input())
a = 100
import sys
for i in range(10**7):
a = int(a*1.01)
if a>=x:
print(i+1)
sys.exit()
|
s583603953
|
p03023
|
u103146596
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 96
|
Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees, but do not print units.
|
l = list(map(str, input().split()))
if(l.count("x") < 8):
print("YES")
else:
print("NO")
|
s155997270
|
Accepted
| 17
| 2,940
| 35
|
l = int(input())
print(180*(l-2))
|
s946985259
|
p03433
|
u256464928
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 71
|
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
n = int(input())
a = int(input())
print('Yes' if (-n%500)<=a else 'No')
|
s343891360
|
Accepted
| 17
| 2,940
| 70
|
n = int(input())
a = int(input())
print('Yes' if (n%500)<=a else 'No')
|
s455669092
|
p03943
|
u444238096
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 100
|
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a, b, c = map(int, input().split())
if a+b==c or b+c==a or c+a==b:
print("YES")
else:
print("NO")
|
s007182907
|
Accepted
| 17
| 2,940
| 102
|
a, b, c = map(int, input().split())
if a+b==c or b+c==a or c+a==b:
print("Yes")
else:
print("No")
|
s253197140
|
p03386
|
u887524368
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 122
|
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
a, b, k = map(int, input().split(" "))
for i in range(k):
print(a + k)
for i in range(k):
print(b - (k - 1) + i)
|
s427952483
|
Accepted
| 40
| 3,064
| 406
|
a, b, k = map(int, input().split(" "))
for i in range(k):
if i == 0:
ans = [a + i]
else:
if a + i <= b:
ans.append(a + i)
else:
break
for i in range(k):
p = b - (k - 1) + i
if p < a:
break
elif p not in ans:
ans.append(p)
else:
continue
for i in range(len(ans)):
print(ans[i])
|
s487531116
|
p02858
|
u819048695
| 2,000
| 1,048,576
|
Wrong Answer
| 19
| 3,064
| 282
|
In 2937, DISCO creates a new universe called DISCOSMOS to celebrate its 1000-th anniversary. DISCOSMOS can be described as an H \times W grid. Let (i, j) (1 \leq i \leq H, 1 \leq j \leq W) denote the square at the i-th row from the top and the j-th column from the left. At time 0, one robot will be placed onto each square. Each robot is one of the following three types: * Type-H: Does not move at all. * Type-R: If a robot of this type is in (i, j) at time t, it will be in (i, j+1) at time t+1. If it is in (i, W) at time t, however, it will be instead in (i, 1) at time t+1. (The robots do not collide with each other.) * Type-D: If a robot of this type is in (i, j) at time t, it will be in (i+1, j) at time t+1. If it is in (H, j) at time t, however, it will be instead in (1, j) at time t+1. There are 3^{H \times W} possible ways to place these robots. In how many of them will every square be occupied by one robot at times 0, T, 2T, 3T, 4T, and all subsequent multiples of T? Since the count can be enormous, compute it modulo (10^9 + 7).
|
def gcd(x,y):
if x<y:
x,y=y,x
if y==0:
return x
else:
return gcd(y,x%y)
H,W,T=map(int,input().split())
mod=10**9+7
h=gcd(H,T)
w=gcd(W,T)
H//=h
W//=w
print(h,w,H,W)
ans=pow(2,H,mod)+pow(2,W,mod)+pow(2,gcd(H,W),mod)-3
print(pow(ans,h*w,mod))
|
s583491843
|
Accepted
| 18
| 3,064
| 267
|
def gcd(x,y):
if x<y:
x,y=y,x
if y==0:
return x
else:
return gcd(y,x%y)
H,W,T=map(int,input().split())
mod=10**9+7
h=gcd(H,T)
w=gcd(W,T)
H//=h
W//=w
ans=pow(2,H,mod)+pow(2,W,mod)+pow(2,gcd(H,W),mod)-3
print(pow(ans,h*w,mod))
|
s055305058
|
p02409
|
u514853553
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,652
| 370
|
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
|
array=[[0 for i in range(10)]for j in range(12)]
n=int(input())
for i in range(n):
call=list(map(int,input().split()))
array[(call[0]-1)*3-1+call[1]][call[2]-1]+=call[3]
for i in range(0,12):
if i%3==0 and i!=0:
for j in range(10):
print("#",end=" ")
print()
for j in range(10):
print(array[i][j],end=" ")
print()
|
s718090484
|
Accepted
| 50
| 7,688
| 377
|
array=[[0 for i in range(10)]for j in range(12)]
n=int(input())
for i in range(n):
call=list(map(int,input().split()))
array[(call[0]-1)*3-1+call[1]][call[2]-1]+=call[3]
for i in range(0,12):
if i%3==0 and i!=0:
for j in range(20):
print("#",end="")
print()
for j in range(10):
print(" "+str(array[i][j]),end="")
print()
|
s891535194
|
p03386
|
u678009529
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 177
|
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
a, b, k = map(int, input().split())
ans = []
for i in range(k):
if a + i > b - i:
break
ans.append(a + i)
ans.append(b - i)
for i in set(ans):
print(i)
|
s398387972
|
Accepted
| 20
| 3,060
| 185
|
a, b, k = map(int, input().split())
ans = []
for i in range(k):
if a + i > b - i:
break
ans.append(a + i)
ans.append(b - i)
for i in sorted(set(ans)):
print(i)
|
s224790699
|
p03730
|
u279229189
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 230
|
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
v = input().split(" ")
a = int(v[0])
b = int(v[1])
c = int(v[2])
amari = []
tmp1 = 0
tmp2 = 0
for i in range(1, b + 1, 1):
tmp1 += a
amari.append(tmp1 % b)
if c in amari:
print("Yes")
else:
print("No")
|
s319417993
|
Accepted
| 17
| 3,064
| 228
|
v = input().split(" ")
a = int(v[0])
b = int(v[1])
c = int(v[2])
amari = []
tmp1 = 0
tmp2 = 0
for i in range(1, b + 1, 1):
tmp1 += a
amari.append(tmp1 % b)
if c in amari:
print("YES")
else:
print("NO")
|
s621238933
|
p03564
|
u227085629
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,104
| 3,064
| 104
|
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.
|
n = int(input())
k = int(input())
s = 1
while n > 0:
if s < k:
s = s*2
else:
s += k
print(s)
|
s649107297
|
Accepted
| 17
| 2,940
| 113
|
n = int(input())
k = int(input())
s = 1
while n > 0:
if s < k:
s = s*2
else:
s += k
n -= 1
print(s)
|
s025472983
|
p02409
|
u962381052
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,536
| 312
|
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
|
rooms = [0] * (4*3*10)
count = int(input())
for i in range(count):
b, f, r, v = [int(x) for x in input().split()]
rooms[30*(b-1) + 10*(f-1) + r] += v
for i, room in enumerate(rooms):
if i%30 == 0:
print('#'*20)
if (i+1)%10 == 0:
print(room)
else:
print(room, end=' ')
|
s323858482
|
Accepted
| 20
| 7,664
| 323
|
rooms = [0] * (4*3*10)
count = int(input())
for i in range(count):
b, f, r, v = [int(x) for x in input().split()]
rooms[30*(b-1) + 10*(f-1) + (r-1)] += v
for i, room in enumerate(rooms, start=1):
print('', room, end='')
if i%10 == 0:
print()
if i%30 == 0 and i%120 != 0:
print('#'*20)
|
s366897862
|
p03455
|
u778700306
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 99
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a, b = map(int, input().split())
if a * b // 2 == 0:
print("Even")
else:
print("Odd")
|
s732409444
|
Accepted
| 17
| 2,940
| 98
|
a, b = map(int, input().split())
if a * b % 2 == 0:
print("Even")
else:
print("Odd")
|
s967563179
|
p03944
|
u460245024
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 478
|
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
|
W, H, N = map(int, input().split())
left_under = (0, 0)
right_top = (W, H)
for _ in range(N):
x, y, a = map(int, input().split())
if a == 1:
left_under = (x, left_under[1])
elif a == 2:
right_top = (x, right_top[1])
elif a == 3:
left_under = (left_under[0], y)
elif a == 4:
right_top = (right_top[1], y)
if right_top[0] - left_under[0] <= 0 or right_top[1] - left_under[1] <= 0:
print(0)
else:
print((right_top[0] - left_under[0])*(right_top[1] - left_under[1]))
|
s820569161
|
Accepted
| 17
| 3,064
| 562
|
W, H, N = map(int, input().split())
left_under = (0, 0)
right_top = (W, H)
for _ in range(N):
x, y, a = map(int, input().split())
if a == 1:
left_under = (max([x, left_under[0]]), left_under[1])
elif a == 2:
right_top = (min([x,right_top[0]]), right_top[1])
elif a == 3:
left_under = (left_under[0], max([y,left_under[1]]))
elif a == 4:
right_top = (right_top[0], min([y,right_top[1]]))
if right_top[0] - left_under[0] <= 0 or right_top[1] - left_under[1] <= 0:
print(0)
else:
print((right_top[0] - left_under[0])*(right_top[1] - left_under[1]))
|
s937926390
|
p02612
|
u111559399
| 2,000
| 1,048,576
|
Wrong Answer
| 30
| 9,140
| 28
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N=int(input())
print(1000-N)
|
s800105174
|
Accepted
| 27
| 9,176
| 69
|
N=int(input())
if N%1000>0:
print(1000-N%1000)
else:
print(0)
|
s429520958
|
p03251
|
u358254559
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 217
|
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
n,m,X,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.append(X)
y.append(Y)
x.sort()
y.sort()
if x[-1] < y[0]:
print("NO WAR")
else:
print("WAR")
|
s555517679
|
Accepted
| 17
| 3,060
| 202
|
n,m,X,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.append(X)
y.append(Y)
if max(x) < min(y):
print("No War")
else:
print("War")
|
s351015358
|
p02413
|
u248424983
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,604
| 248
|
Your task is to perform a simple table calculation. Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.
|
r,c = map(int,input().split())
total = 0
for i in range(r):
li = list(map(int,input().split()))
sub = sum(li)
li.append(sub)
total += sub
if i == r-1 : li.append(total)
strli = " ".join([str(i) for i in li])
print(strli)
|
s594301347
|
Accepted
| 20
| 8,216
| 234
|
r,c = map(int,input().split())
rc=[]
total=[]
for _ in range(r): rc.append(list(map(int,input().split())))
for i in range(r): rc[i].append(sum(rc[i]))
for i in zip(*rc): total.append(sum(i))
rc.append(total)
for col in rc: print(*col)
|
s063486213
|
p02646
|
u912208257
| 2,000
| 1,048,576
|
Wrong Answer
| 22
| 9,168
| 185
|
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
if A<B and (V-W)*T>B-A:
print("Yes")
elif A>B and (V-W)*T>A-B:
print("Yes")
else:
print("No")
|
s680963108
|
Accepted
| 21
| 9,180
| 187
|
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
if A<B and (V-W)*T>=B-A:
print("YES")
elif A>B and (V-W)*T>=A-B:
print("YES")
else:
print("NO")
|
s519257329
|
p03860
|
u969190727
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 33
|
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
A,B,C=input().split()
print(B[0])
|
s889818635
|
Accepted
| 19
| 3,060
| 41
|
A,B,C=input().split()
print("A"+B[0]+"C")
|
s358100691
|
p03079
|
u331226975
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 157
|
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
|
ABC = list(map(int, input().split()))
if ABC[0] + ABC[1] < ABC[2] or ABC[1] + ABC[2] < ABC[0] or ABC[0] + ABC[2] < ABC[1]:
print("Yes")
else:
print("No")
|
s595565087
|
Accepted
| 18
| 2,940
| 132
|
ABC = list(map(int, input().split()))
if ABC[0] == ABC[1] and ABC[1]==ABC[2] and ABC[2]==ABC[0]:
print("Yes")
else:
print("No")
|
s473544240
|
p03377
|
u516242950
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 126
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
cat, hatena, x = map(int, input().split())
kakutei_cat = cat - x
if kakutei_cat >= hatena:
print('YES')
else:
print('NO')
|
s937815479
|
Accepted
| 17
| 2,940
| 92
|
a, b, x = map(int, input().split())
if a <= x <= a + b:
print('YES')
else:
print('NO')
|
s652974363
|
p03545
|
u609738635
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 385
|
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
# -*- coding: utf-8 -*-
from itertools import product
import sys
def main(A, B, C, D):
for op1, op2, op3 in product(("+", "-"), repeat=3):
e = A + op1 + B + op2 + C + op3 + D
print(e)
x = eval(e)
if x == 7:
print(e + "=7")
sys.exit()
if(__name__ == "__main__"):
A, B, C, D = list(input())
main(A, B, C, D)
|
s014904703
|
Accepted
| 17
| 3,188
| 499
|
# -*- coding: utf-8 -*-
def main(S):
for i in range(1 << len(S)):
st = str(S[0])
num = int(S[0])
for j in range(len(S)-1):
if((i >> j) & 1):
st = st + "+" + str(S[j+1])
num += int(S[j+1])
else:
st = st + "-" + str(S[j+1])
num -= int(S[j+1])
if(num == 7):
print(st + "=7")
break
if(__name__ == "__main__"):
S = list(input())
main(S)
|
s612048569
|
p03448
|
u772261431
| 2,000
| 262,144
|
Wrong Answer
| 30
| 9,176
| 378
|
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
a = 0
b = 0
c = 0
while a <= A:
a += 1
while b <= B:
b +=1
while c <= C:
c +=1
total = 500 * a + 100 * b + 50 * c
if total == X:
count += 1
print(count)
|
s082845384
|
Accepted
| 57
| 9,160
| 338
|
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(A+1):
for b in range(B+1):
for c in range(C+1):
total = 500 * a + 100 * b + 50 * c
if total == X:
count += 1
print(count)
|
s578781159
|
p04014
|
u483645888
| 2,000
| 262,144
|
Wrong Answer
| 81
| 3,064
| 445
|
For integers b (b \geq 2) and n (n \geq 1), let the function f(b,n) be defined as follows: * f(b,n) = n, when n < b * f(b,n) = f(b,\,{\rm floor}(n / b)) + (n \ {\rm mod} \ b), when n \geq b Here, {\rm floor}(n / b) denotes the largest integer not exceeding n / b, and n \ {\rm mod} \ b denotes the remainder of n divided by b. Less formally, f(b,n) is equal to the sum of the digits of n written in base b. For example, the following hold: * f(10,\,87654)=8+7+6+5+4=30 * f(100,\,87654)=8+76+54=138 You are given integers n and s. Determine if there exists an integer b (b \geq 2) such that f(b,n)=s. If the answer is positive, also find the smallest such b.
|
n = int(input())
s = int(input())
flag = False
if s == n:
print(n+1)
exit()
import math
def chk(b, n):
if b//n == 0:
return n
else:
return chk(b,math.floor(n/b))+n%b
for b in range(2, int(n**0.5)+1):
if chk(b, n) == s:
print(chk(b,n))
print(b)
flag = True
break
for i in range(int(n**0.5), n, -1):
b = (n-s)/i + 1
if chk(b, n) == s:
print(b)
flag = True
break
if flag == False:
print(-1)
|
s811111067
|
Accepted
| 567
| 3,064
| 476
|
n = int(input())
s = int(input())
flag = False
if s > n or (n//2)+1<s<n:
print(-1)
exit()
if s == n:
print(n+1)
exit()
def chk(b, n):
if n//b == 0:
return n
else:
return chk(b,n//b) + n%b
for b in range(2, int(n**0.5)+1):
if chk(b, n) == s:
print(b)
flag = True
exit()
for i in range(int(n**0.5), 0, -1):
b = (n-s)//i + 1
if chk(b, n) == s:
if b > 1:
print(b)
flag = True
exit()
if flag == False:
print(-1)
|
s675281106
|
p03415
|
u906651641
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 60
|
We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.
|
A = input()
B = input()
C = input()
print(A[0], B[1], C[2])
|
s948477665
|
Accepted
| 18
| 2,940
| 58
|
A = input()
B = input()
C = input()
print(A[0]+B[1]+C[2])
|
s622705535
|
p00038
|
u136916346
| 1,000
| 131,072
|
Wrong Answer
| 30
| 5,996
| 715
|
ポーカーの手札データを読み込んで、それぞれについてその役を出力するプログラムを作成してください。ただし、この問題では、以下のルールに従います。 * ポーカーはトランプ 5 枚で行う競技です。 * 同じ数字のカードは 5 枚以上ありません。 * ジョーカーは無いものとします。 * 以下のポーカーの役だけを考えるものとします。(番号が大きいほど役が高くなります。) 1. 役なし(以下に挙げるどれにも当てはまらない) 2. ワンペア(2 枚の同じ数字のカードが1 組ある) 3. ツーペア(2 枚の同じ数字のカードが2 組ある) 4. スリーカード(3 枚の同じ数字のカードが1 組ある) 5. ストレート(5 枚のカードの数字が連続している) ただし、A を含むストレートの場合、A で終わる並びもストレートとします。つまり、A を含むストレート は、A 2 3 4 5 と 10 J Q K A の2種類です。J Q K A 2 などのように、A をまたぐ並び はストレートではありません。(この場合、「役なし」になります)。 6. フルハウス(3 枚の同じ数字のカードが1 組と、残りの2 枚が同じ数字のカード) 7. フォーカード(4 枚の同じ数字のカードが1 組ある)
|
from collections import Counter
import sys
for t in sys.stdin:
l=sorted(map(int,t[:-1].split(",")))
s=False
p1=Counter(l)
p2=Counter(p1.values())
if 3 in p2 and 2 in p2:
print("full house")
elif 2 in p2:
if p2[2]==1:
print("one pair")
elif p2[2]==2:
print("two pair")
elif 3 in p2:
print("three card")
elif 4 in p2:
print("four card")
else:
for i in range(1,10):
if list(range(i,i+5))==l:
print("straight")
s=True
break
if [1,10,11,12,13]==i:
print("straight")
s=True
if not s:
print("null")
|
s545397756
|
Accepted
| 20
| 5,992
| 715
|
from collections import Counter
import sys
for t in sys.stdin:
l=sorted(map(int,t[:-1].split(",")))
s=False
p1=Counter(l)
p2=Counter(p1.values())
if 3 in p2 and 2 in p2:
print("full house")
elif 2 in p2:
if p2[2]==1:
print("one pair")
elif p2[2]==2:
print("two pair")
elif 3 in p2:
print("three card")
elif 4 in p2:
print("four card")
else:
for i in range(1,10):
if list(range(i,i+5))==l:
print("straight")
s=True
break
if [1,10,11,12,13]==l:
print("straight")
s=True
if not s:
print("null")
|
s752762306
|
p03434
|
u624475441
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 77
|
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
N=int(input())
A=sorted(map(int,input().split()))
print(sum(A[::2])*2-sum(A))
|
s124467661
|
Accepted
| 17
| 2,940
| 83
|
N=int(input())
A=sorted(map(int,input().split()))[::-1]
print(sum(A[::2])*2-sum(A))
|
s540506177
|
p03380
|
u633355062
| 2,000
| 262,144
|
Wrong Answer
| 2,207
| 53,400
| 600
|
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
|
import bisect
from scipy.special import comb
n = int(input())
a = sorted(map(int, input().split()))
ans = []
if len(a) == 2:
print(a[1], a[0])
exit(0)
for n in a:
tmp = n // 2
l = a[bisect.bisect_left(a, tmp)]
r = a[bisect.bisect_right(a, tmp)]
print(n, l, r)
if n < r:
ans.append([comb(n, l, exact=True), n, l])
else:
l_comb = comb(n, l, exact=True)
r_comb = comb(n, r, exact=True)
if l_comb > r_comb:
ans.append([l_comb, n, l])
else:
ans.append([r_comb, n, r])
ans.sort()
print(ans[-1][1], ans[-1][2])
|
s753558250
|
Accepted
| 162
| 38,564
| 516
|
import numpy as np
def getNearestValue(list, num):
idx = np.abs(np.asarray(list) - num).argmin()
return list[idx]
N = int(input())
A = sorted(map(int, input().split()))
n = A.pop()
m = getNearestValue(A, n/2)
print(n, m)
|
s049494747
|
p02678
|
u484052148
| 2,000
| 1,048,576
|
Wrong Answer
| 545
| 33,980
| 896
|
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
def resolve():
n, m = map(int, input().split())
adj = [[] for i in range(n+1)]
for i in range(m):
A, B = map(int, input().split())
adj[A].append(B)
adj[B].append(A)
#print(adj)
from collections import deque
q = deque([1])
ans = [-1 for i in range(n+1)]
while q:
v = q.popleft()
for u in adj[v]:
if ans[u] == -1:
ans[u] = v
q.append(u)
print("yes")
for i in range(2, n+1):
print(ans[i])
resolve()
|
s415436267
|
Accepted
| 560
| 34,008
| 896
|
def resolve():
n, m = map(int, input().split())
adj = [[] for i in range(n+1)]
for i in range(m):
A, B = map(int, input().split())
adj[A].append(B)
adj[B].append(A)
#print(adj)
from collections import deque
q = deque([1])
ans = [-1 for i in range(n+1)]
while q:
v = q.popleft()
for u in adj[v]:
if ans[u] == -1:
ans[u] = v
q.append(u)
print("Yes")
for i in range(2, n+1):
print(ans[i])
resolve()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.