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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s375127162 | p02853 | u170296094 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 279 | We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen. DISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver. Find the total amount of money he earned. | x, y = input().split()
s = 0
if x == 1:
s += 300000
elif x == 2:
s += 200000
elif x == 3:
s += 100000
else:
s += 0
if y == 1:
s += 300000
elif y == 2:
s += 200000
elif y == 3:
s += 100000
else:
s += 0
if x == 1 and y == 1:
s += 400000
print(s) | s542227202 | Accepted | 17 | 3,060 | 319 | x, y = input().split()
s = 0
if int(x) == 1:
s += 300000
elif int(x) == 2:
s += 200000
elif int(x) == 3:
s += 100000
else:
s += 0
if int(y) == 1:
s += 300000
elif int(y) == 2:
s += 200000
elif int(y) == 3:
s += 100000
else:
s += 0
if int(x) == 1 and int(y) == 1:
s += 400000
print(s) |
s817518603 | p00015 | u723913470 | 1,000 | 131,072 | Wrong Answer | 20 | 7,584 | 975 | A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647. Your task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers. If given integers or the sum have more than 80 digits, print "overflow". | import sys
N=int(input())
N=int(N/2)
for i in range(N):
a=input()
b=input()
len_a=len(a)
len_b=len(b)
c=[]
kuriage=0
if(len_a>=len_b):
for i in range(len_b):
c.append((kuriage+int(a[len_a-1-i])+int(b[len_b-1-i]))%10)
kuriage=(kuriage+int(a[len_a-1-i])+int(b[len_b-1-i]))//10
for i in range(len_b,len_a):
c.append((kuriage+int(a[len_a-1-i]))%10)
kuriage=(kuriage+int(a[len_a-1-i]))//10
else :
for i in range(len_a):
c.append((kuriage+int(a[len_a-1-i])+int(b[len_b-1-i]))%10)
kuriage=(kuriage+int(a[len_a-1-i])+int(b[len_b-1-i]))//10
for i in range(len_a,len_b):
c.append((kuriage+int(b[len_b-1-i]))%10)
kuriage=(kuriage+int(b[len_b-1-i]))//10
if(kuriage==1):
c.append(1)
if(len(c)>=80):
print('overflow')
else:
for i in c[::-1]:
print(i,end='')
print('') | s991448816 | Accepted | 20 | 7,620 | 964 | import sys
N=int(input())
for i in range(N):
a=input()
b=input()
len_a=len(a)
len_b=len(b)
c=[]
kuriage=0
if(len_a>=len_b):
for i in range(len_b):
c.append((kuriage+int(a[len_a-1-i])+int(b[len_b-1-i]))%10)
kuriage=(kuriage+int(a[len_a-1-i])+int(b[len_b-1-i]))//10
for i in range(len_b,len_a):
c.append((kuriage+int(a[len_a-1-i]))%10)
kuriage=(kuriage+int(a[len_a-1-i]))//10
else :
for i in range(len_a):
c.append((kuriage+int(a[len_a-1-i])+int(b[len_b-1-i]))%10)
kuriage=(kuriage+int(a[len_a-1-i])+int(b[len_b-1-i]))//10
for i in range(len_a,len_b):
c.append((kuriage+int(b[len_b-1-i]))%10)
kuriage=(kuriage+int(b[len_b-1-i]))//10
if(kuriage==1):
c.append(1)
if(len(c)>=81):
print('overflow')
else:
for i in c[::-1]:
print(i,end='')
print('') |
s130255396 | p03846 | u405660020 | 2,000 | 262,144 | Wrong Answer | 86 | 14,692 | 501 | There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0. | n=int(input())
a=list(map(int, input().split()))
from collections import Counter
c=Counter(a)
cnt_lst=[0]*n
for key in c:
cnt_lst[key]+=c[key]
if n%2==1:
if cnt_lst[0]==1:
cnt_lst.pop(0)
print(cnt_lst)
if all([cnt_lst[i]==2 for i in range(n-1) if i%2==1]):
print(2**(n//2))
else:
print(0)
else:
print(0)
else:
if all([cnt_lst[i]==2 for i in range(n-1) if i%2==1]):
print(2**(n//2))
else:
print(0)
| s857579236 | Accepted | 102 | 14,692 | 531 | n=int(input())
a=list(map(int, input().split()))
mod=10**9+7
from collections import Counter
c=Counter(a)
cnt_lst=[0]*n
for key in c:
cnt_lst[key]+=c[key]
flag=True
if n%2==1:
if cnt_lst[0]==1:
cnt_lst.pop(0)
else:
flag=False
for i in range(n-1):
if (i%2==1 and cnt_lst[i]!=2) or (i%2==0 and cnt_lst[i]!=0):
flag=False
else:
for i in range(n):
if (i%2==1 and cnt_lst[i]!=2) or (i%2==0 and cnt_lst[i]!=0):
flag=False
print(2**(n//2)%mod if flag else 0) |
s528275076 | p03645 | u291988695 | 2,000 | 262,144 | Wrong Answer | 2,107 | 54,160 | 291 | In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him. | n,m=map(int,input().split())
l=[[0,0]]*m
t=[0]*m
tc=0
a=False
for k in range(m):
l[k]=list(map(int,input().split()))
l.sort()
for k in l:
if k[0]==1:
t[tc]=k[1]
tc+=1
elif k[1]==n:
if k[1] in t:
a=True
break
if a:
print("POSSIBLE")
else:
print("IMPOSSIBLE") | s192923037 | Accepted | 799 | 36,524 | 368 | n,m=map(int,input().split())
l=[[0,0]]*m
at=[0]*m
bt=[0]*m
atc=0
btc=0
a=False
f=0
for k in range(m):
ln=list(map(int,input().split()))
if ln[0]==1:
at[atc]=ln[1]
atc+=1
elif ln[1]==n:
bt[btc]=ln[0]
btc+=1
del at[atc:]
del bt[btc:]
at.sort()
bt.sort()
c=list(set(at)^set(bt))
if len(c)!=(atc+btc):
print("POSSIBLE")
else:
print("IMPOSSIBLE") |
s696391933 | p02659 | u818318325 | 2,000 | 1,048,576 | Wrong Answer | 27 | 9,964 | 269 | Compute A \times B, truncate its fractional part, and print the result as an integer. | import math
from decimal import *
getcontext().prec = 28
a,b=map(str, input().split())
#a_ = Decimal(a)
#b_ = Decimal(b)
a = int(a)
b = float(b)*100
#print(round(Decimal(Decimal(a)*Decimal(b))))
print((a*b)//100)
#print(math.floor(Decimal(a)*Decimal(b)/Decimal(100.0))) | s509121276 | Accepted | 20 | 9,164 | 277 | #import math
#from decimal import *
#getcontext().prec = 28
a,b=input().split()
#a_ = Decimal(a)
#b_ = Decimal(b)
a = int(a)
b = int(float(b)*1000)
#print(round(Decimal(Decimal(a)*Decimal(b))))
ans = a*b
print(ans//1000)
#print(math.floor(Decimal(a)*Decimal(b)/Decimal(100.0))) |
s547256902 | p02843 | u799916419 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 220 | AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible. (Ignore consumption tax.) | def bag(x):
max_num = x // 100
print(int(max_num * 5 <= x % 100))
if __name__ == "__main__":
import sys
in_str = ''
for line in sys.stdin:
in_str += line
n = [int(_) for _ in in_str.split()][0]
bag(n) | s510350447 | Accepted | 17 | 2,940 | 220 | def bag(x):
max_num = x // 100
print(int(max_num * 5 >= x % 100))
if __name__ == "__main__":
import sys
in_str = ''
for line in sys.stdin:
in_str += line
n = [int(_) for _ in in_str.split()][0]
bag(n) |
s442407829 | p03729 | u594762426 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 125 | You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`. | a, b , c= map(str, input().split())
if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
print("Yes")
else:
print("No") | s324135070 | Accepted | 17 | 2,940 | 125 | a, b, c = map(str, input().split())
if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
print("YES")
else:
print("NO") |
s922237321 | p02608 | u571199625 | 2,000 | 1,048,576 | Wrong Answer | 1,039 | 12,496 | 392 | 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())
dic = {}
for x in range(1,int(n**0.5)+1):
for y in range(1,int(n**0.5)+1):
for z in range(1,int(n**0.5)+1):
ans = x**2 + y **2 + z**2 +x*y+y*z+z*x
if ans in dic:
dic[ans] +=1
else:
dic[ans] = 1
print(dic)
for i in range(n):
if i+1 in dic:
print(dic[i+1])
else:
print(0) | s721431059 | Accepted | 1,062 | 11,588 | 380 | n = int(input())
dic = {}
for x in range(1,int(n**0.5)+1):
for y in range(1,int(n**0.5)+1):
for z in range(1,int(n**0.5)+1):
ans = x**2 + y **2 + z**2 +x*y+y*z+z*x
if ans in dic:
dic[ans] +=1
else:
dic[ans] = 1
for i in range(n):
if i+1 in dic:
print(dic[i+1])
else:
print(0) |
s681208456 | p04029 | u178536051 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 78 | 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())
print(N)
ret = 0
for i in range(N):
ret += i+1
print(ret) | s825180723 | Accepted | 17 | 2,940 | 69 | N = int(input())
ret = 0
for i in range(N):
ret += i+1
print(ret) |
s364037241 | p00254 | u221679506 | 1,000 | 131,072 | Wrong Answer | 30 | 8,308 | 393 | 0 から 9 の数字からなる四桁の数 N に対して以下の操作を行う。 1. N の桁それぞれの数値を大きい順に並べた結果得た数を L とする 2. N の桁それぞれの数値を小さい順に並べた結果得た数を S とする 3. 差 L-S を新しい N とする(1回分の操作終了) 4. 新しい N に対して 1. から繰り返す このとき、全桁が同じ数字(0000, 1111など)である場合を除き、あらゆる四桁の数はいつかは 6174になることが知られている。例えば N = 2012の場合 1回目 (N = 2012): L = 2210, S = 0122, L-S = 2088 2回目 (N = 2088): L = 8820, S = 0288, L-S = 8532 3回目 (N = 8532): L = 8532, S = 2358, L-S = 6174 となり、3 回の操作で 6174 に到達する。 0 から 9 の数字からなる四桁の数が与えられたとき、何回の操作で 6174 に到達するか計算するプログラムを作成して下さい。 | from functools import reduce
while True:
n = input()
if n == "0000":
break
n = n if len(n) >= 4 else n.zfill(4)
if reduce(lambda x,y:x and y,[n[0] == i for i in n]):
print("NA")
else:
cnt = 0
while n != "6174":
s = ''.join(sorted(n))
l = ''.join(sorted(n,reverse = True))
n = str(int(l)-int(s))
n = n if len(n) >= 4 else n.zfill(4)
print(n)
cnt += 1
print(cnt) | s236905724 | Accepted | 350 | 8,300 | 381 | from functools import reduce
while True:
n = input()
if n == "0000":
break
n = n if len(n) >= 4 else n.zfill(4)
if reduce(lambda x,y:x and y,[n[0] == i for i in n]):
print("NA")
else:
cnt = 0
while n != "6174":
s = ''.join(sorted(n))
l = ''.join(sorted(n,reverse = True))
n = str(int(l)-int(s))
n = n if len(n) >= 4 else n.zfill(4)
cnt += 1
print(cnt) |
s795564829 | p03556 | u102461423 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 34 | Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer. | N = int(input())
print(int(N**.5)) | s359242247 | Accepted | 17 | 2,940 | 37 | N = int(input())
print(int(N**.5)**2) |
s149404780 | p03494 | u215643129 | 2,000 | 262,144 | Wrong Answer | 25 | 9,072 | 131 | There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform. | n=input()
l=list(map(int, input().split()))
count=0
while all(i/2==0 for i in l):
l=[i/2 for i in l]
count+=1
print(count) | s180561607 | Accepted | 30 | 9,188 | 140 | int(input())
A = list(map(int, input().split()))
count = 0
while all(a%2==0 for a in A):
A = [a/2 for a in A]
count+=1
print(count) |
s892936345 | p03644 | u432333240 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 253 | Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times. | N = int(input())
count = 0
ans = 1
for i in range(1,N):
tmp_count = 0
tmp_i = i
while(tmp_i%2==0):
tmp_count+=1
tmp_i /= 2
print(i, tmp_count)
if count < tmp_count:
count = tmp_count
ans = i
print(ans) | s841923203 | Accepted | 18 | 2,940 | 232 | N = int(input())
count = 0
ans = 1
for i in range(1,N+1):
tmp_count = 0
tmp_i = i
while(tmp_i%2==0):
tmp_count+=1
tmp_i /= 2
if count < tmp_count:
count = tmp_count
ans = i
print(ans)
|
s830432579 | p02401 | u315329386 | 1,000 | 131,072 | Wrong Answer | 20 | 7,436 | 93 | Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part. | while True:
inst = input()
if inst.find("?") > 0:
break
print(eval(inst)) | s265916845 | Accepted | 20 | 7,448 | 112 | while True:
inst = input()
if inst.find("?") > 0:
break
print(eval(inst.replace("/", "//"))) |
s154849624 | p02388 | u027634846 | 1,000 | 131,072 | Wrong Answer | 20 | 7,496 | 29 | Write a program which calculates the cube of a given integer x. | x = int(input())
print(x * 3) | s481091292 | Accepted | 20 | 7,656 | 30 | x = int(input())
print(x ** 3) |
s184724796 | p03556 | u837852400 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 52 | Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer. | import math
print(str(int(math.sqrt(int(input()))))) | s463109589 | Accepted | 18 | 2,940 | 69 | import math
print(str(int(math.pow(int(math.sqrt(int(input()))),2)))) |
s502789365 | p03671 | u165988235 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 135 | Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells. | a,b,c = map(int,input().split())
list = []
list.append(a)
list.append(b)
list.append(c)
print(list)
list.sort()
print(list[0]+list[1])
| s298203544 | Accepted | 17 | 2,940 | 123 | a,b,c = map(int,input().split())
list = []
list.append(a)
list.append(b)
list.append(c)
list.sort()
print(list[0]+list[1])
|
s840827624 | p04029 | u349856770 | 2,000 | 262,144 | Wrong Answer | 27 | 9,160 | 106 | 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("人数を入力してね >"))
ame = 0
for i in range(1, n+1):
ame += i
print(ame) | s512298961 | Accepted | 26 | 9,024 | 74 | n = int(input())
ame = 0
for i in range(1, n+1):
ame += i
print(ame) |
s762447558 | p02678 | u531599639 | 2,000 | 1,048,576 | Wrong Answer | 627 | 35,548 | 400 | 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 deque
N,M = map(int,input().split())
cnct = [[] for i in range(N+1)]
for _ in range(M):
A,B = map(int,input().split())
cnct[A].append(B)
cnct[B].append(A)
Q = deque()
Q.append(1)
ans = [0]*(N+1)
vstd = [0]*(N+1)
while Q:
temp = Q.popleft()
for a in cnct[temp]:
if vstd[a] == 0:
ans[a] = temp
vstd[a] = 1
Q.append(a)
for a in ans[2:]:
print(a) | s551839070 | Accepted | 634 | 35,464 | 577 | from collections import deque
N,M = map(int,input().split())
cnct = [[] for i in range(N+1)]
for _ in range(M):
A,B = map(int,input().split())
cnct[A].append(B)
cnct[B].append(A)
Q = deque()
Q.append(1)
ans = [0]*(N+1)
vstd = [0]*(N+1)
while Q:
temp = Q.popleft()
for a in cnct[temp]:
if vstd[a] == 0:
ans[a] = temp
vstd[a] = 1
Q.append(a)
print('Yes')
for a in ans[2:]:
print(a) |
s585289023 | p02261 | u956645355 | 1,000 | 131,072 | Wrong Answer | 30 | 7,736 | 900 | Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance). | def main():
N = int(input())
CARD = tuple(input().split())
sort_ = []
for i in range(1, 10):
for s in CARD:
if str(i) in s:
sort_.append(s)
sort_ = tuple(sort_)
a = list(CARD)
bsort = tuple(bubbleSort(a, N))
ssort = tuple(selectionSort(a, N))
for s in (bsort, ssort):
print(*s, sep=' ')
if s == sort_:
print('Stable')
else:
print('Not stable')
def bubbleSort(c, n):
flag = 1
while flag:
flag = 0
for i in range(1, n):
if c[i][1] < c[i-1][1]:
c[i], c[i-1] = c[i-1], c[i]
flag = 1
return c
def selectionSort(c, n):
for i in range(n):
minj = i
for j in range(i, n):
if c[j][1] < c[minj][1]:
minj = j
c[i], c[minj] = c[minj], c[i]
return c
main() | s344388055 | Accepted | 20 | 7,744 | 899 | def main():
N = int(input())
CARD = tuple(input().split())
sort_ = []
for i in range(1, 10):
for s in CARD:
if str(i) in s:
sort_.append(s)
sort_ = tuple(sort_)
bsort = tuple(bubbleSort(list(CARD), N))
ssort = tuple(selectionSort(list(CARD), N))
for s in (bsort, ssort):
print(*s, sep=' ')
if s == sort_:
print('Stable')
else:
print('Not stable')
def bubbleSort(c, n):
flag = 1
while flag:
flag = 0
for i in range(1, n):
if c[i][1] < c[i-1][1]:
c[i], c[i-1] = c[i-1], c[i]
flag = 1
return c
def selectionSort(c, n):
for i in range(n):
minj = i
for j in range(i, n):
if c[j][1] < c[minj][1]:
minj = j
c[i], c[minj] = c[minj], c[i]
return c
main() |
s094830308 | p03448 | u526459074 | 2,000 | 262,144 | Wrong Answer | 49 | 3,060 | 207 | 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, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a):
for j in range (b):
for k in range (c):
if 500*i + 100*j + 50*k == x:
ans += 1
print(ans) | s984359729 | Accepted | 53 | 3,060 | 213 | a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
for j in range (b+1):
for k in range (c+1):
if 500*i + 100*j + 50*k == x:
ans += 1
print(ans) |
s708047267 | p03861 | u113255362 | 2,000 | 262,144 | Wrong Answer | 2,205 | 9,172 | 138 | 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,c=map(int,input().split())
k = 0
m = a % c
if m == 0:
k = a
else:
k = c-m + a
res = 0
for i in range(k,b,c):
res += 1
print(res) | s551095132 | Accepted | 27 | 9,112 | 211 | a,b,c=map(int,input().split())
mini = 0
m = a % c
if m == 0:
mini = a/c
else:
mini = (c-m + a)/c
maxi = 0
M = b % c
if M == 0:
maxi = b//c
else:
maxi = (b-M)//c
res = int(maxi) - int(mini) + 1
print(res) |
s548793966 | p03605 | u485566817 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 77 | 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()
if n[0] == 9 or n[1] == 9:
print("Yes")
else:
print("No") | s551187305 | Accepted | 17 | 2,940 | 81 | n = input()
if n[0] == "9" or n[1] == "9":
print("Yes")
else:
print("No") |
s062464529 | p03998 | u583507988 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 401 | 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 = list(map(str, input().split()))
b = list(map(str, input().split()))
c = list(map(str, input().split()))
n = 'a'
while True:
if n == 'a':
if len(a) == 0:
print('A')
break
else:
n = a.pop(0)
elif n == b:
if len(b) == 0:
print('B')
break
else:
n = b.pop(0)
else:
if len(c) == 0:
print('C')
break
else:
n = c.pop(0) | s267653041 | Accepted | 25 | 8,980 | 289 | sa=input()+'a'
sb=input()+'b'
sc=input()+'c'
st='a'
a=0
b=0
c=0
while a<len(sa) and b<len(sb) and c<len(sc):
if st=='a':
st=sa[a]
a+=1
elif st=='b':
st=sb[b]
b+=1
else:
st=sc[c]
c+=1
if a==len(sa):
print('A')
elif b==len(sb):
print('B')
else:
print('C') |
s718071245 | p03471 | u341855122 | 2,000 | 262,144 | Wrong Answer | 40 | 3,188 | 465 | 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 = list(map(int,input().split()))
sen=0
gosen=0
man = 0
man = N[0]
while(N[0]==man+gosen+sen and man > -1 and sen > -1 and gosen > -1):
while(N[0]==man+gosen+sen and man >-1 and sen > -1 and gosen > -1):
print(10000*man+5000*gosen+1000*sen)
if(N[1]==10000*man+5000*gosen+1000*sen):
print(str(man)+" "+str(gosen)+" "+str(sen))
exit()
gosen -= 1
sen += 1
man -= 1
gosen += 1
print("-1 -1 -1")
| s389211544 | Accepted | 1,880 | 3,064 | 389 | N = list(map(int,input().split()))
sen=0
gosen=0
man = N[0]
while(N[0]+1>gosen):
sen = 0
while(N[0]+1>sen):
man = N[0] - sen - gosen
if(man < 0):
sen += 1
continue
if(N[1]==(10000*man+5000*gosen+1000*sen)):
print(str(man)+" "+str(gosen)+" "+str(sen))
exit()
sen += 1
gosen += 1
print("-1 -1 -1")
|
s098372129 | p03054 | u102126195 | 2,000 | 1,048,576 | Wrong Answer | 254 | 3,896 | 857 | We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, there is a piece, which is initially placed at square (s_r,s_c). Takahashi and Aoki will play a game, where each player has a string of length N. Takahashi's string is S, and Aoki's string is T. S and T both consist of four kinds of letters: `L`, `R`, `U` and `D`. The game consists of N steps. The i-th step proceeds as follows: * First, Takahashi performs a move. He either moves the piece in the direction of S_i, or does not move the piece. * Second, Aoki performs a move. He either moves the piece in the direction of T_i, or does not move the piece. Here, to move the piece in the direction of `L`, `R`, `U` and `D`, is to move the piece from square (r,c) to square (r,c-1), (r,c+1), (r-1,c) and (r+1,c), respectively. If the destination square does not exist, the piece is removed from the grid, and the game ends, even if less than N steps are done. Takahashi wants to remove the piece from the grid in one of the N steps. Aoki, on the other hand, wants to finish the N steps with the piece remaining on the grid. Determine if the piece will remain on the grid at the end of the game when both players play optimally. | h, w, n = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
win = 0
SR = sr
SC = sc
sr = SR
sc = SC
for i in range(n):
if S[i] == "L":
sc -= 1
if sc <= 0:
break
if T[i] == "R" and sc < w:
sc += 1
if sc <= 0:
win = 1
sr = SR
sc = SC
for i in range(n):
if S[i] == "R":
sc += 1
if sc > w:
break
if T[i] == "L" and sc > 1:
sc -= 1
if sc > w:
win = 1
sr = SR
sc = SC
for i in range(n):
if S[i] == "D":
sr += 1
if sr > h:
break
if T[i] == "U" and sr > 1:
sr -= 1
if sr > h:
win = 1
sr = SR
sc = SC
for i in range(n):
if S[i] == "U":
sr -= 1
if sr <= 0:
break
if T[i] == "D" and sr < h:
sr += 1
if sr <= 0:
win = 1
if win:
print("No")
else:
print("Yes") | s210095864 | Accepted | 248 | 3,888 | 858 | h, w, n = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
win = 0
SR = sr
SC = sc
sr = SR
sc = SC
for i in range(n):
if S[i] == "L":
sc -= 1
if sc <= 0:
break
if T[i] == "R" and sc < w:
sc += 1
if sc <= 0:
win = 1
sr = SR
sc = SC
for i in range(n):
if S[i] == "R":
sc += 1
if sc > w:
break
if T[i] == "L" and sc > 1:
sc -= 1
if sc > w:
win = 1
sr = SR
sc = SC
for i in range(n):
if S[i] == "D":
sr += 1
if sr > h:
break
if T[i] == "U" and sr > 1:
sr -= 1
if sr > h:
win = 1
sr = SR
sc = SC
for i in range(n):
if S[i] == "U":
sr -= 1
if sr <= 0:
break
if T[i] == "D" and sr < h:
sr += 1
if sr <= 0:
win = 1
if win:
print("NO")
else:
print("YES")
|
s620045014 | p02602 | u019685451 | 2,000 | 1,048,576 | Wrong Answer | 2,206 | 34,056 | 323 | 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. | def prod(X):
val = 1
for x in X:
val = val * x
return val
N, K = map(int, input().split())
A = list(map(int, input().split()))
G = [prod(A[:K])]
for i in range(K, N):
val = G[-1] // A[i - K] * A[i]
G.append(val)
print(G)
for i in range(1, len(G)):
print('Yes' if G[i] > G[i - 1] else 'No') | s111576023 | Accepted | 152 | 31,604 | 137 | N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(K, N):
print('Yes' if A[i] > A[i - K] else 'No') |
s681101729 | p04011 | u235376569 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 160 | There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee. | a=int(input())
b=int(input())
c=int(input())
d=int(input())
ans=0
for i in range(a):
if 0<a:
ans+=c
else:
ans+=d
print(d)
| s614230489 | Accepted | 19 | 2,940 | 172 | a=int(input())
b=int(input())
c=int(input())
d=int(input())
ans=0
for i in range(a):
if 0<b:
ans+=c
else:
ans+=d
b=b-1
print(ans)
|
s915249331 | p03457 | u348868667 | 2,000 | 262,144 | Wrong Answer | 446 | 27,380 | 450 | 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())
txy = []
for i in range(N):
txy.append(list(map(int,input().split())))
ans = "YES"
t = 0
x = 0
y = 0
for i in range(N):
deft = txy[i][0] - t
defx = abs(txy[i][1] - x)
defy = abs(txy[i][2] - y)
t = txy[i][0]
x = txy[i][1]
y = txy[i][2]
if (defx + defy) > deft:
ans = "NO"
break
elif (deft - defx - defy)%2 != 0:
ans = "NO"
break
else:
continue
print(ans) | s591169361 | Accepted | 447 | 27,380 | 423 | N = int(input())
txy = []
for i in range(N):
txy.append(list(map(int,input().split())))
ans = "Yes"
t = 0
x = 0
y = 0
for i in range(N):
deft = txy[i][0] - t
defx = abs(txy[i][1] - x)
defy = abs(txy[i][2] - y)
t = txy[i][0]
x = txy[i][1]
y = txy[i][2]
if (defx + defy) > deft:
ans = "No"
break
elif (deft - defx - defy)%2 != 0:
ans = "No"
break
print(ans) |
s091937166 | p02742 | u151079949 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 80 | 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: | H,W=map(int,input().split())
if H*W%2==0:
print(H*W/2)
else:
print(H*W/2+1)
| s025116049 | Accepted | 17 | 2,940 | 134 | H,W=map(int,input().split())
if H!=1 and W!=1:
if H*W%2==0:
print(int(H*W/2))
else:
print(int(H*W/2+0.5))
else:
print(1) |
s729344267 | p03827 | u980503157 | 2,000 | 262,144 | Wrong Answer | 25 | 9,172 | 173 | You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation). | firstline = int(input())
sec = input()
maxN = 0
init = 0
for i in sec:
if i == "I":
init -= 1
else:
init += 1
if init > maxN:
maxN = init
print(maxN) | s700011489 | Accepted | 26 | 9,172 | 173 | firstline = int(input())
sec = input()
maxN = 0
init = 0
for i in sec:
if i == "I":
init += 1
else:
init -= 1
if init > maxN:
maxN = init
print(maxN) |
s191912593 | p03814 | u246820565 | 2,000 | 262,144 | Wrong Answer | 18 | 3,560 | 61 | 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()
a = s.index('A')
z = s.index('Z')
print(s[a:z+1]) | s068712067 | Accepted | 44 | 3,516 | 98 | s = input()
a = s.index('A')
for i in range(len(s)):
if s[i] == 'Z':
z = i+1
print(len(s[a:z])) |
s201927766 | p03386 | u803617136 | 2,000 | 262,144 | Wrong Answer | 2,103 | 26,704 | 188 | 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())
upper = min(a + k, b + 1)
bottom = min(max(b - k, upper), a + k, )
for i in range(a, upper):
print(i)
for j in range(bottom, b + 1):
print(j)
| s863193011 | Accepted | 17 | 3,060 | 174 | a, b, k = map(int, input().split())
upper = min(a + k, b)
bottom = max(b - k + 1, upper)
for i in range(a, upper):
print(i)
for j in range(bottom, b + 1):
print(j)
|
s058578418 | p03090 | u608088992 | 2,000 | 1,048,576 | Wrong Answer | 28 | 3,720 | 410 | You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem. | N = int(input())
S = 0
for i in range(2, N):
S += i
Ans = []
for i in range(2, N):
Ans.append((1, i))
Ans.append((N, i))
Total = [N+1] * N
Total[0], Total[N-1] = S, S
for i in range(1, N-1):
j = i+1
while Total[i] < S:
Ans.append((i+1, j+1))
Total[i] += j+1
Total[j] += i+1
j += 1
print(len(Ans))
for a in Ans:
print(" ".join(map(str, a))) | s218776046 | Accepted | 26 | 3,700 | 628 | import sys
def solve():
input = sys.stdin.readline
N = int(input())
Ans = []
AnsNum = 0
if N % 2 == 0:
for i in range(1, N):
for j in range(i + 1, N + 1):
if i + j != N + 1:
Ans.append((i, j))
AnsNum += 1
else:
for i in range(1, N):
for j in range(i + 1, N + 1):
if i + j != N:
Ans.append((i, j))
AnsNum += 1
print(AnsNum)
for i in range(AnsNum):
print(" ".join(map(str, Ans[i])))
return 0
if __name__ == "__main__":
solve() |
s964118737 | p02614 | u609561564 | 1,000 | 1,048,576 | Wrong Answer | 65 | 9,104 | 422 | We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices. | h, w, k = map(int, input().split())
c = []
ans = 0
c = [list(input()) for _ in range(h)]
print(c)
ans = 0
for i in range(2 ** h):
for j in range(2 ** w):
cnt = 0
for m in range(h):
for n in range(w):
if ((i >> m) & 1 == 0) and ((j >> n) & 1 == 0):
if c[m][n] == '#':
cnt += 1
if cnt == k:
ans += 1
print(ans)
| s132113735 | Accepted | 65 | 9,120 | 424 | h, w, k = map(int, input().split())
c = []
ans = 0
c = [list(input()) for _ in range(h)]
# print(c)
ans = 0
for i in range(2 ** h):
for j in range(2 ** w):
cnt = 0
for m in range(h):
for n in range(w):
if ((i >> m) & 1 == 0) and ((j >> n) & 1 == 0):
if c[m][n] == '#':
cnt += 1
if cnt == k:
ans += 1
print(ans)
|
s881629399 | p03433 | u372345564 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 215 | E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins. | def main():
N = int(input() )
A = int(input() )
surplus = N % 500
print(surplus)
if(surplus <= A):
print("Yes")
else:
print("No")
if __name__=="__main__":
main() | s589209075 | Accepted | 17 | 2,940 | 216 | def main():
N = int(input() )
A = int(input() )
surplus = N % 500
if(surplus <= A):
print("Yes")
else:
print("No")
if __name__=="__main__":
main() |
s520036261 | p03854 | u558961961 | 2,000 | 262,144 | Wrong Answer | 17 | 3,188 | 582 | You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. | S = input()
result = "NO"
while True:
if S[-5:-1] == "dream":
if len(S) == 5:
result = "YES"
break
S.rstrip("dream")
elif S[-5:-1] == "erase":
if len(S) == 5:
result = "YES"
break
S.rstrip("erase")
elif S[-6:-1] == "eraser":
if len(S) == 6:
result = "YES"
break
S.rstrip("eraser")
elif S[-7:-1] == "dreamer":
if len(S) == 7:
result = "YES"
break
S.rstrip("dreamer")
else:
break
print(result) | s918451931 | Accepted | 67 | 3,188 | 543 | S = input()
result = "NO"
while True:
if S[-5:] == "dream":
if len(S) == 5:
result = "YES"
break
S = S[:-5]
elif S[-5:] == "erase":
if len(S) == 5:
result = "YES"
break
S = S[:-5]
elif S[-6:] == "eraser":
if len(S) == 6:
result = "YES"
break
S = S[:-6]
elif S[-7:] == "dreamer":
if len(S) == 7:
result = "YES"
break
S = S[:-7]
else:
break
print(result) |
s227141789 | p03730 | u385167811 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 214 | 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`. | temp = input().rstrip().split(" ")
A = int(temp[0])
B = int(temp[1])
C = int(temp[2])
if A == B and C > 0:
print("No")
elif A == 1:
print("Yes")
elif A + C == B:
print("Yes")
else:
print("No") | s533278918 | Accepted | 19 | 3,064 | 361 | temp = input().rstrip().split(" ")
A = int(temp[0])
B = int(temp[1])
C = int(temp[2])
flag = 0
if A == B and C > 0:
print("NO")
elif A == 1:
print("YES")
elif A + C == B:
print("YES")
else:
for i in range(1,10000):
if (A * i) % B == C:
print("YES")
flag = 1
break
if flag == 0:
print("NO") |
s848367415 | p03361 | u136346222 | 2,000 | 262,144 | Wrong Answer | 161 | 12,508 | 1,001 | We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`. However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective. | # -*- coding: utf-8 -*-
from sys import stdin
import sys
import numpy as np
xy = stdin.readline().rstrip().split()
x = int(xy[0])
y = int(xy[1])
data = [stdin.readline().rstrip().split() for _ in range(x)]
print(*data, sep='\n')
print('----------------')
for i in range(x):
data[i] = list(data[i][0])
arr = np.array(data)
print(arr)
print('----------------')
OK = True
for i in range(x):
for j in range(y):
if arr[i][j] == '#':
can_paint = False
if i != 0:
if arr[i-1][j] == '#':
can_paint =True
if j != 0:
if arr[i][j-1] == '#':
can_paint = True
if i != x-1:
if arr[i+1][j] == '#':
can_paint = True
if j != y-1:
if arr[i][j+1] == '#':
can_paint = True
if can_paint != True:
OK = False
if OK == True:
print('Yes')
else:
print('No') | s092085925 | Accepted | 398 | 20,772 | 1,003 | # -*- coding: utf-8 -*-
from sys import stdin
import sys
import numpy as np
xy = stdin.readline().rstrip().split()
x = int(xy[0])
y = int(xy[1])
data = [stdin.readline().rstrip().split() for _ in range(x)]
#print(*data, sep='\n')
#print('----------------')
for i in range(x):
data[i] = list(data[i][0])
arr = np.array(data)
#print(arr)
#print('----------------')
OK = True
for i in range(x):
for j in range(y):
if arr[i][j] == '#':
can_paint = False
if i != 0:
if arr[i-1][j] == '#':
can_paint =True
if j != 0:
if arr[i][j-1] == '#':
can_paint = True
if i != x-1:
if arr[i+1][j] == '#':
can_paint = True
if j != y-1:
if arr[i][j+1] == '#':
can_paint = True
if can_paint != True:
OK = False
if OK == True:
print('Yes')
else:
print('No') |
s468790976 | p03574 | u002459665 | 2,000 | 262,144 | Wrong Answer | 29 | 3,064 | 935 | You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. | def main():
h, w = map(int, input().split())
b = []
for _ in range(h):
b.append(input())
# b[1][1] -> b[0][0], b[0][1], b[0][2], b[1][0], b[1][2], b[2][0], b[2][1], b[2][2]
ans = []
for i in range(h):
e = []
for j in range(w):
e.append(0)
ans.append(e)
for i in range(h):
for j in range(w):
count = 0
v = b[i][j]
if v == "#":
ans[i][j] = '#'
continue
for k in range(-1, 2):
for l in range(-1, 2):
if i + k < 0 or i + k >= h:
pass
elif j + l < 0 or j + l >= w:
pass
else:
if b[i + k][j + l] == "#":
count += 1
ans[i][j] = count
print(ans)
if __name__ == '__main__':
main()
| s367922107 | Accepted | 31 | 3,444 | 1,009 | def main():
h, w = map(int, input().split())
b = []
for _ in range(h):
b.append(input())
# b[1][1] -> b[0][0], b[0][1], b[0][2], b[1][0], b[1][2], b[2][0], b[2][1], b[2][2]
ans = []
for i in range(h):
e = []
for j in range(w):
e.append(0)
ans.append(e)
for i in range(h):
for j in range(w):
count = 0
v = b[i][j]
if v == "#":
ans[i][j] = '#'
continue
for k in range(-1, 2):
for l in range(-1, 2):
if i + k < 0 or i + k >= h:
pass
elif j + l < 0 or j + l >= w:
pass
else:
if b[i + k][j + l] == "#":
count += 1
ans[i][j] = count
for l1 in ans:
for l2 in l1:
print(l2, end="")
print("")
if __name__ == '__main__':
main()
|
s335748843 | p04030 | u303119576 | 2,000 | 262,144 | Wrong Answer | 25 | 8,940 | 1 | 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? | 0 | s490498701 | Accepted | 32 | 8,744 | 122 | s=input()
stk=[]
for c in s:
if c in '01':
stk.append(c)
elif stk:
stk.pop()
print(''.join(stk)) |
s608735469 | p03998 | u131881594 | 2,000 | 262,144 | Wrong Answer | 20 | 3,188 | 335 | 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,b,c=input(),input(),input()
string=[a,b,c]
s=[0,0,0]
ban=0
print(string)
while s[0]!=len(a) and s[1]!=len(b) and s[2]!=len(c):
temp=s[ban]
s[ban]+=1
if string[ban][temp]=="a": ban=0
elif string[ban][temp]=="b": ban=1
else: ban=2
if s[0]==len(a): print("A")
if s[1]==len(b): print("B")
if s[2]==len(c): print("C") | s182160235 | Accepted | 17 | 3,064 | 248 | a,b,c=input(),input(),input()
string=[a,b,c]
ans=["A","B","C"]
s=[0,0,0]
ban=0
while s[ban]!=len(string[ban]):
temp=s[ban]
s[ban]+=1
if string[ban][temp]=="a": ban=0
elif string[ban][temp]=="b": ban=1
else: ban=2
print(ans[ban]) |
s251970320 | p03563 | u331464808 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 53 | Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it. | r = int(input())
g = int(input())
print(float(2*g-r)) | s392594945 | Accepted | 17 | 2,940 | 46 | r = int(input())
g = int(input())
print(2*g-r) |
s614586112 | p03024 | u163320134 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 86 | Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility. | s=input()
cnt=s.count('o')
l=len(s)
if 15-l+cnt>=8:
print('Yes')
else:
print('No') | s783971964 | Accepted | 17 | 2,940 | 86 | s=input()
cnt=s.count('o')
l=len(s)
if 15-l+cnt>=8:
print('YES')
else:
print('NO') |
s973971336 | p03251 | u503228842 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 203 | 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()))
max_X = max(X,max(x))
min_Y = min(Y,min(y))
if max_X<min_Y:
print("War")
else:print("No war")
| s212180956 | Accepted | 18 | 2,940 | 204 | N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
max_X = max(X,max(x))
min_Y = min(Y,min(y))
if max_X<min_Y:
print("No War")
else:print("War")
|
s320710067 | p03657 | u384579799 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 145 | 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. | # -*- coding: utf-8 -*-
import sys
A, B = map(int, input().split())
C = A + B
if C%3 == 0:
print('possible')
else:
print('impossible') | s360140565 | Accepted | 17 | 2,940 | 219 | # -*- coding: utf-8 -*-
import sys
A, B = map(int, input().split())
C = A + B
if A%3 == 0:
print('Possible')
elif B%3 == 0:
print('Possible')
elif C%3 == 0:
print('Possible')
else:
print('Impossible') |
s548399403 | p03380 | u921773161 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 261 | 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. | a = list(map(int, input().split()))
x = max(a)
b1 = x//2
b2 = (x+1)//2
y = x
z = x
for i in range(len(a)):
if a[i] != x:
tmp = min(abs(a[i]-b1), abs(a[i]-b2))
if tmp < y:
z = a[i]
y = min(tmp, y)
ans = x*z
print(x, z) | s625928800 | Accepted | 131 | 14,052 | 294 | n = int(input())
a = list(map(int, input().split()))
x = max(a)
b1 = x//2
b2 = (x+1)//2
y = x
z = x
for i in range(len(a)):
if a[i] != x:
tmp = min(abs(a[i]-b1), abs(a[i]-b2))
if tmp < y:
z = a[i]
y = min(tmp, y)
ans = x*z
print(str(x) + ' '+ str(z)) |
s379622134 | p03637 | u617515020 | 2,000 | 262,144 | Wrong Answer | 76 | 14,252 | 225 | We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. | N=int(input())
a=list(map(int,input().split()))
o = 0
f = 0
t = 0
for i in a:
if i % 2 == 1:
o += 1
if i % 4 == 0:
f += 1
if i % 4 == 2:
t += 1
if f >= o-1 and t % 2 == 0:
print('Yes')
else:
print('No') | s512793528 | Accepted | 73 | 15,020 | 247 | N=int(input())
a=list(map(int,input().split()))
o = 0
f = 0
t = 0
for i in a:
if i % 2 == 1:
o += 1
if i % 4 == 0:
f += 1
if i % 4 == 2:
t += 1
if f >o-1:
print('Yes')
elif f == o-1 and t==0:
print('Yes')
else:
print('No') |
s814245220 | p03167 | u216928054 | 2,000 | 1,048,576 | Wrong Answer | 375 | 49,648 | 2,580 | There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left. For each i and j (1 \leq i \leq H, 1 \leq j \leq W), Square (i, j) is described by a character a_{i, j}. If a_{i, j} is `.`, Square (i, j) is an empty square; if a_{i, j} is `#`, Square (i, j) is a wall square. It is guaranteed that Squares (1, 1) and (H, W) are empty squares. Taro will start from Square (1, 1) and reach (H, W) by repeatedly moving right or down to an adjacent empty square. Find the number of Taro's paths from Square (1, 1) to (H, W). As the answer can be extremely large, find the count modulo 10^9 + 7. | #!/usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1 # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7
def debug(*x):
print(*x)
def solve(H, W, data):
"void()"
score = [[0] * (W + 1) for i in range(H + 1)]
score[0][1] = 1
for y in range(1, H + 1):
for x in range(1, W + 1):
if data[y - 1][x - 1] == "#":
score[y][x] = 0
else:
score[y][x] = (score[y - 1][x] + score[y][x - 1]) % MOD
# print(score)
return score[H][W]
def main():
H, W = map(int, input().split())
data = [input() for i in range(H)]
print(solve(H, W, data))
T1 = """
3 4
...#
.#..
....
"""
T2 = """
5 5
..#..
.....
#...#
.....
..#..
"""
T3 = """
20 20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
"""
def test_T3():
"""
>>> as_input(T3)
>>> main()
345263555
"""
def test_T2():
"""
>>> as_input(T2)
>>> main()
24
"""
def _test():
"""
>>> as_input(T1)
>>> main()
3
"""
import doctest
doctest.testmod()
def as_input(s):
"use in test, use given string as input file"
import io
global read, input
f = io.StringIO(s.strip())
input = f.readline
read = f.read
USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
print("compiling")
from numba.pycc import CC
cc = CC('my_module')
cc.export('solve', solve.__doc__.strip().split()[0])(solve)
cc.compile()
exit()
else:
input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
# -p: pure python mode
# if not -p, import compiled module
from my_module import solve # pylint: disable=all
elif sys.argv[-1] == "-t":
_test()
sys.exit()
elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
# input given as file
input_as_file = open(sys.argv[1])
input = input_as_file.buffer.readline
read = input_as_file.buffer.read
main()
| s058671880 | Accepted | 392 | 50,092 | 2,771 | #!/usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1 # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7
def debug(*x):
print(*x)
def solve(H, W, data):
"void()"
score = [[0] * (W + 1) for i in range(H + 1)]
score[0][1] = 1
for y in range(1, H + 1):
for x in range(1, W + 1):
if data[y - 1][x - 1] == ord("#"):
score[y][x] = 0
else:
score[y][x] = (score[y - 1][x] + score[y][x - 1]) % MOD
# print(score)
return score[H][W]
def main():
H, W = map(int, input().split())
data = [input() for i in range(H)]
print(solve(H, W, data))
T1 = """
3 4
...#
.#..
....
"""
T2 = """
5 5
..#..
.....
#...#
.....
..#..
"""
T3 = """
20 20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
"""
T4 = """
5 2
..
#.
..
.#
..
"""
def test_T4():
"""
>>> as_input(T4)
>>> main()
0
"""
def test_T3():
"""
>>> as_input(T3)
>>> main()
345263555
"""
def test_T2():
"""
>>> as_input(T2)
>>> main()
24
"""
def _test():
"""
>>> as_input(T1)
>>> main()
3
"""
import doctest
doctest.testmod()
def as_input(s):
"use in test, use given string as input file"
import io
global read, input
f = io.StringIO(s.strip())
def input():
return bytes(f.readline(), "ascii")
def read():
return bytes(f.read(), "ascii")
USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
print("compiling")
from numba.pycc import CC
cc = CC('my_module')
cc.export('solve', solve.__doc__.strip().split()[0])(solve)
cc.compile()
exit()
else:
input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
# -p: pure python mode
# if not -p, import compiled module
from my_module import solve # pylint: disable=all
elif sys.argv[-1] == "-t":
_test()
sys.exit()
elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
# input given as file
input_as_file = open(sys.argv[1])
input = input_as_file.buffer.readline
read = input_as_file.buffer.read
main()
|
s948602375 | p03644 | u368270116 | 2,000 | 262,144 | Wrong Answer | 28 | 8,936 | 66 | Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times. | n=int(input())
for i in range (6):
if n<2**i:
print(i)
quit() | s108698497 | Accepted | 32 | 8,944 | 80 | n=int(input())
for i in reversed(range(7)):
if n>=2**i:
print(2**i)
quit()
|
s961054221 | p02601 | u760961723 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,304 | 237 | M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful. | A,B,C = map(int,input().split())
K = int(input())
import math
x = math.ceil(math.log2(A/B))
if x < 0:
x = 0
y = math.ceil(math.log2((B*(2**x))/C))
if y < 0:
y = 0
if 2*x + y <= K:
print("Yes")
else:
print("No")
| s747339391 | Accepted | 29 | 9,344 | 532 | A,B,C = map(int,input().split())
K = int(input())
import math
x,y = 0,0
if A > B:
if math.modf(math.log2(A/B))[0] != 0:
x = math.ceil(math.log2(A/B))
else:
x = math.ceil(math.log2(A/B))+1
elif A == B:
x = 1
else:
pass
if B*(2**x) > C:
if math.modf(math.log2((B*(2**x))/C))[0] != 0:
y = math.ceil(math.log2((B*(2**x))/C))
else:
y = math.ceil(math.log2((B*(2**x))/C))+1
elif B*(2**x) == C:
y = 1
else:
pass
if x + y <= K:
print("Yes")
else:
print("No")
|
s923318805 | p03369 | u041641933 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 127 | In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen. | s = input()
price = 500
if s[0] == "o":
price += 100
if s[1] == "o":
price += 100
if s[2] == "o":
price += 100
print(price) | s957804575 | Accepted | 17 | 3,060 | 127 | s = input()
price = 700
if s[0] == "o":
price += 100
if s[1] == "o":
price += 100
if s[2] == "o":
price += 100
print(price) |
s228802016 | p03795 | u532099150 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 42 | 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())
a = n%15
print(800*n - a) | s132523322 | Accepted | 17 | 2,940 | 51 | n = int(input())
a = n//15
print((800*n) - (a*200)) |
s520911228 | p03470 | u247043226 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 303 | An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have? | def solve():
N = int(input())
d = [int(input()) for _ in range(N)]
d.sort()
number_of_steps = 0
previous_diameter = 0
for i in range(N):
if d[i] > previous_diameter:
number_of_steps += 1
previous_diameter = d[i]
print(number_of_steps)
# solve() | s797309646 | Accepted | 19 | 3,060 | 301 | def solve():
N = int(input())
d = [int(input()) for _ in range(N)]
d.sort()
number_of_steps = 0
previous_diameter = 0
for i in range(N):
if d[i] > previous_diameter:
number_of_steps += 1
previous_diameter = d[i]
print(number_of_steps)
solve() |
s275244223 | p03774 | u303059352 | 2,000 | 262,144 | Wrong Answer | 23 | 3,064 | 645 | There are N students and M checkpoints on the xy-plane. The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j). When the teacher gives a signal, each student has to go to the nearest checkpoint measured in _Manhattan distance_. The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|. Here, |x| denotes the absolute value of x. If there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index. Which checkpoint will each student go to? | while(True):
try:
n, m = map(int, input().split())
except EOFError:
exit()
a, b = [[0 for _ in range(n)] for i in range(2)]
c, d = [[0 for _ in range(m)] for i in range(2)]
for i in range(n):
a[i], b[i] = map(int, input().split())
for i in range(m):
c[i], d[i] = map(int, input().split())
for i in range(n):
dist = 1 << 9
ans = 0
for j in range(m)[::-1]:
ans = j + 1 if min(dist, abs(a[i] - c[j]) + abs(b[i] - d[j])) == abs(a[i] - c[j]) + abs(b[i] - d[j]) else ans
dist = min(dist, abs(a[i] - c[j]) + abs(b[i] - d[j]))
print(ans) | s026138326 | Accepted | 19 | 3,060 | 347 | while(True):
try:
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]
except EOFError:
exit()
for a, b in ab:
dist = [abs(a - c) + abs(b - d) for c, d in cd]
print(dist.index(min(dist)) + 1)
|
s335812839 | p03845 | u278260569 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 242 | Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. | N = int(input())
T = list(map(int,input().split()))
M = int(input())
P_X = []
for i in range(M):
P_X.append(list(map(int,input().split())))
temp_sum = sum(T)
print(temp_sum)
for i in range(M):
print(temp_sum - T[P_X[i][0] - 1] + P_X[i][1]) | s851011499 | Accepted | 19 | 3,064 | 226 | N = int(input())
T = list(map(int,input().split()))
M = int(input())
P_X = []
for i in range(M):
P_X.append(list(map(int,input().split())))
temp_sum = sum(T)
for i in range(M):
print(temp_sum - T[P_X[i][0] - 1] + P_X[i][1]) |
s470909782 | p02608 | u040660107 | 2,000 | 1,048,576 | Wrong Answer | 2,205 | 9,184 | 545 | 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). | import time
import itertools
N = int(input())
def function(x,y,z,n):
n_tmp = pow(x+y+z,2) - (x*y) - (y*z) -(x*z)
if n == n_tmp:
return True
else:
return False
max = pow(10,4)
count = 0
start = time.time()
p = list(itertools.product(range(1,15), repeat=3))
for n in range(1,N):
count = 0
for p_in in p:
if function(p_in[0],p_in[1],p_in[2],n) == True:
count = count + 1
print(count)
elapsed_time = time.time() - start
# print("elapsed_time:{0}".format(elapsed_time) + "[sec]")
| s810182294 | Accepted | 1,307 | 118,524 | 379 | import time
import itertools
import collections
N = int(input())
start = time.time()
def function(x,y,z):
return pow(x,2) + pow(y,2) + pow(z,2) + (x * y) + (x * z ) + (y * z)
p = list(itertools.product(range(1,100),repeat=3))
a = []
for p_in in p:
a.append(function(p_in[0],p_in[1],p_in[2]))
dict = collections.Counter(a)
for n in range(1,N + 1):
print(dict[n])
|
s940425482 | p03408 | u257449466 | 2,000 | 262,144 | Wrong Answer | 22 | 3,444 | 345 | Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards. | from collections import Counter
arr_b = []
N = int(input())
for i in range(N):
arr_b.append(str(input()))
arr_r = []
N = int(input())
for i in range(N):
arr_r.append(str(input()))
c_b = Counter(arr_b)
c_r = Counter(arr_r)
result = max(c_b[x] for x in c_b) - max(c_r[x] for x in c_r)
if result > 0:
print(result)
else:
print(0)
| s991978593 | Accepted | 22 | 3,316 | 436 | from collections import Counter
arr_b = []
N = int(input())
for i in range(N):
arr_b.append(str(input()))
arr_r = []
N = int(input())
for i in range(N):
arr_r.append(str(input()))
c_b = Counter(arr_b)
c_r = Counter(arr_r)
res = 0
for k_b in c_b.keys():
if k_b in c_r :
if res < c_b[k_b] - c_r[k_b]:
res = c_b[k_b] - c_r[k_b]
else:
if res < c_b[k_b]:
res = c_b[k_b]
print(res)
|
s587568448 | p00045 | u567380442 | 1,000 | 131,072 | Wrong Answer | 30 | 6,732 | 239 | 販売単価と販売数量を読み込んで、販売金額の総合計と販売数量の平均を出力するプログラムを作成してください。 | import sys
f = sys.stdin
sum_price = sum_amount = kind = 0
for line in f:
price, amount = map(int, line.split(','))
sum_price += price * amount
sum_amount += amount
kind += 1
print(sum_price, round(sum_amount / kind)) | s589771312 | Accepted | 30 | 6,748 | 250 | import sys
f = sys.stdin
sum_price = sum_amount = kind = 0
for line in f:
price, amount = map(int, line.split(','))
sum_price += price * amount
sum_amount += amount
kind += 1
print(sum_price)
print(int(sum_amount / kind + 0.5)) |
s299986799 | p03440 | u368796742 | 2,000 | 262,144 | Wrong Answer | 30 | 9,104 | 108 | You are given a forest with N vertices and M edges. The vertices are numbered 0 through N-1. The edges are given in the format (x_i,y_i), which means that Vertex x_i and y_i are connected by an edge. Each vertex i has a value a_i. You want to add edges in the given forest so that the forest becomes connected. To add an edge, you choose two different vertices i and j, then span an edge between i and j. This operation costs a_i + a_j dollars, and afterward neither Vertex i nor j can be selected again. Find the minimum total cost required to make the forest connected, or print `Impossible` if it is impossible. | n,m = map(int,input().split())
if n == 1:
print(0)
exit()
if m*2 < n:
print("Impossible")
exit() | s154437857 | Accepted | 426 | 24,444 | 1,241 | n,m = map(int,input().split())
if m == n-1:
print(0)
exit()
if 2*(n-m-1) > n:
print("Impossible")
exit()
class Unionfind:
def __init__(self,n):
self.uf = [-1]*n
def find(self,x):
if self.uf[x] < 0:
return x
else:
self.uf[x] = self.find(self.uf[x])
return self.uf[x]
def same(self,x,y):
return self.find(x) == self.find(y)
def union(self,x,y):
x = self.find(x)
y = self.find(y)
if x == y:
return False
if self.uf[x] > self.uf[y]:
x,y = y,x
self.uf[x] += self.uf[y]
self.uf[y] = x
return True
def size(self,x):
x = self.find(x)
return -self.uf[x]
u = Unionfind(n)
a = list(map(int,input().split()))
for i in range(m):
x,y = map(int,input().split())
u.union(x,y)
count = 2*(n-m-1)
l = [[] for i in range(n)]
for i in range(n):
x = u.find(i)
if x < 0:
l[i].append(a[i])
else:
l[x].append(a[i])
ans = 0
h = []
for i in range(n):
if l[i]:
l[i].sort()
ans += l[i][0]
count -= 1
for j in l[i][1:]:
h.append(j)
h.sort()
ans += sum(h[:count])
print(ans)
|
s939795018 | p03214 | u503111914 | 2,525 | 1,048,576 | Wrong Answer | 28 | 9,072 | 155 | Niwango-kun is an employee of Dwango Co., Ltd. One day, he is asked to generate a thumbnail from a video a user submitted. To generate a thumbnail, he needs to select a frame of the video according to the following procedure: * Get an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video. * Select t-th frame whose representation a_t is nearest to the average of all frame representations. * If there are multiple such frames, select the frame with the smallest index. Find the index t of the frame he should select to generate a thumbnail. | N = int(input())
A = list(map(int,input().split()))
ave = sum(A) / N
ans = 0
a = 10**10
for i in range(N):
if abs(A[i] - ave) < a:
ans = i
print(ans) | s087964155 | Accepted | 28 | 9,072 | 180 | N = int(input())
A = list(map(int,input().split()))
ave = sum(A) / N
ans = 0
a = 10**10
for i in range(N):
if abs(A[i] - ave) < a:
a = abs(A[i] - ave)
ans = i
print(ans)
|
s811425360 | p03352 | u322185540 | 2,000 | 1,048,576 | Time Limit Exceeded | 2,104 | 2,940 | 141 | You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2. | n = int(input())
ans = 0
for i in range(1,1001):
for j in range(1,1001):
if ans < i**j < n:
ans = i**j
print(ans) | s601130783 | Accepted | 18 | 2,940 | 181 | n = int(input())
ans = 1
for i in range(1,1001):
for j in range(2,1001):
if i**j > n:
break
if ans < i**j <= n:
ans = i**j
print(ans) |
s606865078 | p02972 | u237362582 | 2,000 | 1,048,576 | Wrong Answer | 482 | 8,272 | 606 | There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices. | import sys
input = sys.stdin.readline
def main():
N = int(input())
a = list(map(int, input().strip().split()))
ans = [0] * N
for i, a_r in enumerate(a[::-1]):
j = N - i - 1
count = 0
now = j+1
while now <= N:
count += ans[j-1]
now += j+1
if a_r + count % 2 == 1:
ans[j] = 1
output = ""
count = 0
for i, b in enumerate(ans):
if b == 1:
output += str(a[i]) + " "
count += 1
print(count)
if count != 0:
print(output)
if __name__ == "__main__":
main()
| s142234299 | Accepted | 546 | 10,036 | 712 | import sys
input = sys.stdin.readline
def main():
N = int(input())
a = list(map(int, input().strip().split()))
ans = [0] * N
for i, a_r in enumerate(a[::-1]):
j = N - i - 1
count = 0
now = j+1
while now <= N:
count += ans[now-1]
now += j+1
if a_r == 0:
if count % 2 == 1:
ans[j] = 1
else:
if count % 2 == 0:
ans[j] = 1
output = ""
count = 0
for i, b in enumerate(ans):
if b == 1:
output += str(i+1) + " "
count += 1
print(count)
if count != 0:
print(output[:-1])
if __name__ == "__main__":
main()
|
s009633858 | p02410 | u606989659 | 1,000 | 131,072 | Wrong Answer | 30 | 7,684 | 370 | Write a program which reads a $ n \times m$ matrix $A$ and a $m \times 1$ vector $b$, and prints their product $Ab$. A column vector with m elements is represented by the following equation. \\[ b = \left( \begin{array}{c} b_1 \\\ b_2 \\\ : \\\ b_m \\\ \end{array} \right) \\] A $n \times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation. \\[ A = \left( \begin{array}{cccc} a_{11} & a_{12} & ... & a_{1m} \\\ a_{21} & a_{22} & ... & a_{2m} \\\ : & : & : & : \\\ a_{n1} & a_{n2} & ... & a_{nm} \\\ \end{array} \right) \\] $i$-th element of a $m \times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$). The product of a $n \times m$ matrix $A$ and a $m \times 1$ column vector $b$ is a $n \times 1$ column vector $c$, and $c_i$ is obtained by the following formula: \\[ c_i = \sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m \\] | n,m = map(int,input().split())
a_list = []
b_list = []
c_list = []
for a in range(n):
a_list.append(list(map(int,input().split())))
for b in range(n):
b_list.append(int(input()))
for c in range(n):
c_list.append([])
for d in range(m):
c_list[c].append((a_list[c][d] * b_list[c]))
c_list = list(map(sum,c_list))
for c in c_list:
print(c) | s707862866 | Accepted | 30 | 8,384 | 370 | n,m = map(int,input().split())
a_list = []
b_list = []
c_list = []
for a in range(n):
a_list.append(list(map(int,input().split())))
for b in range(m):
b_list.append(int(input()))
for c in range(n):
c_list.append([])
for d in range(m):
c_list[c].append((a_list[c][d] * b_list[d]))
c_list = list(map(sum,c_list))
for c in c_list:
print(c) |
s195326842 | p03795 | u163320134 | 2,000 | 262,144 | Wrong Answer | 27 | 2,940 | 42 | 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())
print(800*n-int(60/15)*200) | s252104483 | Accepted | 17 | 2,940 | 41 | n=int(input())
print(800*n-int(n/15)*200) |
s360525758 | p03623 | u972892985 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 70 | Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|. | x, a, b = map(int,input().split())
print(min(abs(x - a), abs(x - b))) | s441895897 | Accepted | 17 | 2,940 | 98 | x, a, b = map(int,input().split())
if abs(x - a) > abs(x - b):
print("B")
else:
print("A") |
s173779012 | p03494 | u325119213 | 2,000 | 262,144 | Time Limit Exceeded | 2,205 | 9,172 | 302 | There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform. | def actual(N, A):
count = 0
while True:
is_all_even = all([a % 2 == 0 for a in A])
if is_all_even:
A = [a // 2 for a in A]
count += 1
else:
break
return count
N = int(input())
A = map(int, input().split())
print(actual(N, A)) | s232604317 | Accepted | 31 | 9,164 | 297 | def actual(N, A):
count = 0
while True:
is_all_even = all([a % 2 == 0 for a in A])
if is_all_even:
A = [a // 2 for a in A]
count += 1
else:
return count
N = int(input())
A = list(map(int, input().split()))
print(actual(N, A))
|
s815801105 | p04043 | u118642796 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 100 | 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. | if sorted(list(map(int,input().split()))) == [5,5,7]:
print("Yes")
else:
print("No") | s587401032 | Accepted | 17 | 2,940 | 100 | if sorted(list(map(int,input().split()))) == [5,5,7]:
print("YES")
else:
print("NO") |
s366241887 | p03469 | u482157295 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 37 | On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it. | s = list(input())
s[3] = "8"
print(s) | s772000055 | Accepted | 17 | 2,940 | 47 | s = list(input())
s[3] = "8"
print("".join(s))
|
s550447847 | p03351 | u059684735 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 112 | Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate. | a, b, c, d = map(int, input().split())
print('Yes' if (d > abs(a-b) and d > abs(b-c)) or d > abs(a-c) else 'No') | s316779234 | Accepted | 18 | 2,940 | 115 | a, b, c, d = map(int, input().split())
print('Yes' if (d >= abs(a-b) and d >= abs(b-c)) or d >= abs(a-c) else 'No') |
s437394693 | p02397 | u629874472 | 1,000 | 131,072 | Wrong Answer | 40 | 5,568 | 126 | Write a program which reads two integers x and y, and prints them in ascending order. | while True:
a,b = input().split()
if a =='0' and b =='0':
break
else:
a,b =b,a
print(b,a)
| s588643243 | Accepted | 50 | 5,612 | 193 | while True:
a,b = map(int,input().split())
if a ==0 and b ==0:
break
else:
if a<=b:
print(a,b)
else:
a,b =b,a
print(a,b)
|
s454832706 | p03945 | u556610039 | 2,000 | 262,144 | Wrong Answer | 46 | 3,956 | 172 | Two foxes Jiro and Saburo are playing a game called _1D Reversi_. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa. In the middle of a game, something came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is `B`, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is `W`, it means that the color of the corresponding stone is white. Jiro wants all stones on the board to be of the same color. For this purpose, he will place new stones on the board according to the rules. Find the minimum number of new stones that he needs to place. | s = list(input())
ans = 0
prestr = s[0]
for id in range(len(s) - 1):
if prestr == s[id - 1]: continue
else:
ans += 1
prestr = s[id - 1]
print(ans)
| s612600442 | Accepted | 49 | 3,956 | 172 | s = list(input())
ans = 0
prestr = s[0]
for id in range(len(s) - 1):
if prestr == s[id + 1]: continue
else:
ans += 1
prestr = s[id + 1]
print(ans)
|
s047666583 | p02646 | u954153335 | 2,000 | 1,048,576 | Wrong Answer | 21 | 9,180 | 203 | 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. | import sys
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
dist=b-a
speed=v-w
if speed<=0:
print("No")
sys.exit()
if dist/speed<=t:
print("Yes")
else:
print("No") | s652682478 | Accepted | 22 | 9,184 | 208 | import sys
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
dist=abs(b-a)
speed=v-w
if speed<=0:
print("NO")
sys.exit()
if dist/speed<=t:
print("YES")
else:
print("NO") |
s231589844 | p03488 | u784022244 | 2,000 | 524,288 | Wrong Answer | 1,270 | 4,584 | 879 | A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive x-axis direction. This robot will be given an instruction sequence s. s consists of the following two kinds of letters, and will be executed in order from front to back. * `F` : Move in the current direction by distance 1. * `T` : Turn 90 degrees, either clockwise or counterclockwise. The objective of the robot is to be at coordinates (x, y) after all the instructions are executed. Determine whether this objective is achievable. | S=input()
x,y=map(int, input().split())
N=len(S)
now=0
xs=[]
ys=[]
count=0
for i in range(N):
if S[i]=="F":
now+=1
else:
if count%2==0:
xs.append(now)
else:
ys.append(now)
count+=1
now=0
if S[i]=="F" and i==N-1:
if count%2==0:
xs.append(now)
else:
ys.append(now)
print(xs,ys)
from collections import defaultdict
D=defaultdict(int)
xnow=xs.pop(0)
D[xnow]=1
for i in range(len(xs)):
dx=xs[i]
ds=D.keys()
D=defaultdict(int)
for v in ds:
D[v+dx]=1
D[v-dx]=1
D=dict(D)
#print(D)
xok=x in D
D=defaultdict(int)
D[0]=1
for i in range(len(ys)):
dy=ys[i]
ds=D.keys()
D=defaultdict(int)
for v in ds:
D[v+dy]=1
D[v-dy]=1
D=dict(D)
#print(D)
yok=y in D
if xok and yok:
print("Yes")
else:
print("No") | s153287062 | Accepted | 1,276 | 4,576 | 880 | S=input()
x,y=map(int, input().split())
N=len(S)
now=0
xs=[]
ys=[]
count=0
for i in range(N):
if S[i]=="F":
now+=1
else:
if count%2==0:
xs.append(now)
else:
ys.append(now)
count+=1
now=0
if S[i]=="F" and i==N-1:
if count%2==0:
xs.append(now)
else:
ys.append(now)
#print(xs,ys)
from collections import defaultdict
D=defaultdict(int)
xnow=xs.pop(0)
D[xnow]=1
for i in range(len(xs)):
dx=xs[i]
ds=D.keys()
D=defaultdict(int)
for v in ds:
D[v+dx]=1
D[v-dx]=1
D=dict(D)
#print(D)
xok=x in D
D=defaultdict(int)
D[0]=1
for i in range(len(ys)):
dy=ys[i]
ds=D.keys()
D=defaultdict(int)
for v in ds:
D[v+dy]=1
D[v-dy]=1
D=dict(D)
#print(D)
yok=y in D
if xok and yok:
print("Yes")
else:
print("No") |
s684989815 | p04012 | u075595666 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 169 | Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. | w = list(input())
for i in range(ord('a'),ord('z')):
if int(w.count("chr(i)"))%2 == 1:
print("No")
break
if int(w.count("chr(i)"))%2 == 0:
continue
print("Yes") | s240426484 | Accepted | 17 | 2,940 | 140 | w = list(input())
ans = "Yes"
for i in w:
if int(w.count(i))%2 == 1:
ans = 'No'
break
if int(w.count(i))%2 == 0:
continue
print(ans) |
s146678668 | p02237 | u733945366 | 1,000 | 131,072 | Wrong Answer | 20 | 5,600 | 241 | There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a set of vertices and $E$ is a set of edges; Adjacency list representation and Adjacency matrix representation. An adjacency-list representation consists of an array $Adj[|V|]$ of $|V|$ lists, one for each vertex in $V$. For each $u \in V$, the adjacency list $Adj[u]$ contains all vertices $v$ such that there is an edge $(u, v) \in E$. That is, $Adj[u]$ consists of all vertices adjacent to $u$ in $G$. An adjacency-matrix representation consists of $|V| \times |V|$ matrix $A = a_{ij}$ such that $a_{ij} = 1$ if $(i, j) \in E$, $a_{ij} = 0$ otherwise. Write a program which reads a directed graph $G$ represented by the adjacency list, and prints its adjacency-matrix representation. $G$ consists of $n\; (=|V|)$ vertices identified by their IDs $1, 2,.., n$ respectively. | n=int(input());
G=[[0 for i in range(n)]for j in range(n)]
#print(G)
for i in range(n):
list=[int(m) for m in input().split()]
u=list[0]
k=list[1]
for j in range(2,len(list)):
v=list[j]
G[u-1][v-1]=1
print(G)
| s320210913 | Accepted | 20 | 6,392 | 369 | n=int(input());
G=[[0 for i in range(n)]for j in range(n)]
for i in range(n):
list=[int(m) for m in input().split()]
u=list[0]
k=list[1]
for j in range(2,len(list)):
v=list[j]
G[u-1][v-1]=1
for i in range(n):
for j in range(n):
if j!=n-1:
print(G[i][j],end=" ")
else:
print(G[i][j],end="\n")
|
s608903762 | p03545 | u021763820 | 2,000 | 262,144 | Wrong Answer | 19 | 3,064 | 395 | 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 -*-
n = input()
m = len(n)-1
for i in range(2 ** m):
ops = []
N = [int(n[0]), int(n[1]), int(n[2]), int(n[3])]
for j in range(m):
if (i >> j) & 1:
ops.append("+")
else:
N[j + 1] *= -1
ops.append("-")
if sum(N) == 7:
print(N)
print(n[0]+ops[0]+n[1]+ops[1]+n[2]+ops[2]+n[3]+"=7")
break | s279627840 | Accepted | 18 | 3,060 | 341 | # -*- coding: utf-8 -*-
s = input()
l = [int(i) for i in s]
for i in range(2**3):
ans = l[0]
siki = s[0]
for j in range(3):
if i>>j & 1:
ans += l[j+1]
siki += "+"+s[j+1]
else:
ans -= l[j+1]
siki += "-"+s[j+1]
if ans == 7:
print(siki+"=7")
exit() |
s312291709 | p02390 | u804558166 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 80 | Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively. | x=int(input())
print(x/3600, ':', (x-x/3600)/60, ':', x-(x-x/3600)/60, sep='')
| s092538283 | Accepted | 20 | 5,588 | 93 | x=int(input())
a=x//3600
b=(x-a*3600)//60
c=x-(a*3600+b*60)
print(a, ':', b, ':', c, sep='')
|
s446388522 | p03386 | u404057606 | 2,000 | 262,144 | Wrong Answer | 51 | 3,060 | 233 | 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())
l=[]
for i in range(k+1):
if a+i not in l and a+i<=b:
l.append(a+i)
for i in range(k+1):
if b-k+i not in l and b-k+i>=a:
l.append(b-k+i)
for i in range(len(l)):
print(l[i]) | s992360046 | Accepted | 20 | 3,316 | 247 | a,b,k = map(int,input().split())
l=[]
for i in range(k):
if a+i not in l and a+i<=b:
l.append(a+i)
for i in range(k):
if b-k+1+i not in l and b-k+1+i>=a:
l.append(b-k+1+i)
m=sorted(l)
for i in range(len(m)):
print(m[i]) |
s589112229 | p02646 | u560222605 | 2,000 | 1,048,576 | Wrong Answer | 20 | 9,176 | 137 | 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())
x=a+v*t
y=b+w*t
if x>=y:
print('Yes')
else:
print('No') | s998968580 | Accepted | 22 | 9,136 | 263 |
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if a>b:
x=a-v*t
y=b-w*t
if x<=y:
print('YES')
else:
print('NO')
else:
x=a+v*t
y=b+w*t
if x>=y:
print('YES')
else:
print('NO') |
s666589666 | p03557 | u160414758 | 2,000 | 262,144 | Wrong Answer | 2,105 | 23,104 | 597 | The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. He has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i. To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar. How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different. | import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()
N = I()
A,B,C = sorted(Is()),sorted(Is()),sorted(Is())
Bs = [0]*N
for i in range(N):
b = 0
for j in range(N):
if B[i] < C[-j-1]:
b = j+1
else:
Bs[i] = b
break
sum = 0
for i in range(N):
for j in range(N):
if A[i] < B[-j-1]:
sum += Bs[-j-1]
else:
break
print(sum) | s227832624 | Accepted | 413 | 23,212 | 762 | import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()
N = I()
A,B,C = sorted(Is()),sorted(Is()),sorted(Is())
Bs = [0]*N
b,j = 0,0
for i in range(N):
while j < N:
if B[i] >= C[j]:
b += 1
else:
Bs[i] = N - b
break
if j == N-1:
Bs[i] = N - b
j += 1
all = sum(Bs)
ans,sum,j = 0,0,0
for i in range(N):
while j < N:
if A[i] >= B[j]:
sum += Bs[j]
else:
ans += all - sum
break
if j == N-1:
ans += all - sum
j += 1
print(ans)
|
s400857955 | p03416 | u044964932 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 241 | Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. | def main():
a, b = map(int, input().split())
print(b-a)
ans = (b-a)//100
if int(str(a)[-2:]) <= int(str(a)[:1]) and int(str(b)[-2:]) <= int(str(b)[1:]):
ans += 1
print(ans)
if __name__ == "__main__":
main()
| s820243464 | Accepted | 55 | 2,940 | 202 | def main():
a, b = map(int, input().split())
ans = 0
for i in range(a, b+1):
if str(i) == str(i)[::-1]:
ans += 1
print(ans)
if __name__ == "__main__":
main()
|
s098643860 | p03695 | u853900545 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 506 | In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows: * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : orange * Rating 2800-3199 : red Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not. Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i. Find the minimum and maximum possible numbers of different colors of the users. | n = int(input())
a = list(map(int,input().split()))
for i in range(n):
if a[i] < 400:
a[i] = 0
elif a[i] < 800:
a[i] = 1
elif a[i] < 1200:
a[i] = 2
elif a[i] < 1600:
a[i] = 3
elif a[i] < 2000:
a[i] = 4
elif a[i] < 2400:
a[i] = 5
elif a[i] < 2800:
a[i] = 6
elif a[i] < 3200:
a[i] = 7
else:
a[i] = 8
if a.count(8) > 0:
print(len(set(a)),len(set(a))+2)
else:
print([len(set(a)),len(set(a))]) | s145708012 | Accepted | 17 | 3,064 | 526 | n = int(input())
a = list(map(int,input().split()))
for i in range(n):
if a[i] < 400:
a[i] = 0
elif a[i] < 800:
a[i] = 1
elif a[i] < 1200:
a[i] = 2
elif a[i] < 1600:
a[i] = 3
elif a[i] < 2000:
a[i] = 4
elif a[i] < 2400:
a[i] = 5
elif a[i] < 2800:
a[i] = 6
elif a[i] < 3200:
a[i] = 7
else:
a[i] = 8
if a.count(8) > 0:
print(max(len(set(a))-1,1),len(set(a)) -1 +a.count(8))
else:
print(len(set(a)),len(set(a))) |
s501222705 | p03486 | u076764813 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 131 | 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. | s=input()
t=input()
s_=sorted(s)
t_=sorted(t, reverse=True)
print(s_)
print(t_)
if s_ < t_:
print("Yes")
else:
print("No") | s063887114 | Accepted | 18 | 2,940 | 112 | s=input()
t=input()
s_=sorted(s)
t_=sorted(t, reverse=True)
if s_ < t_:
print("Yes")
else:
print("No") |
s241693776 | p03854 | u101490607 | 2,000 | 262,144 | Wrong Answer | 39 | 4,208 | 777 | You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. | st = input()
sample = ['dream', 'dreamer', 'erase', 'eraser']
sample_edit = ['dream', 'eraser','erase', 'dreamer']
sample_er = ['er']
sample_dr = ['dream']
sample_ase = ['ase', 'aser']
ret = 'No'
reg_len = 0
fd_word = ''
er_flg = False
while( len(st) != 0 ):
if reg_len == len(st):
break
er_flg = False
reg_len = len(st)
for i in range(len(sample_edit)):
fd = st.startswith(sample_edit[i])
#print(st,i)
if fd > 0:
st = ''.join(st[len(sample_edit[i]):len(st)])
if len(st) == 0:
break
#if sample[i] == 'er':
# break
er_flg = True
if er_flg == True:
break
if len(st) == 0:
ret = 'Yes'
#print(st)
#print(len(st))
print( ret ) | s285742056 | Accepted | 113 | 3,188 | 947 | st = input()
sample = ['dream', 'dreamer', 'erase', 'eraser']
sample_edit = ['dream', 'eraser','erase', 'er']
sample_er = ['er']
sample_dr = ['dream']
sample_ase = ['ase', 'aser']
ret = 'NO'
reg_len = 0
fd_word = ''
dream_flg = False
end_flg = False
word = ''
length = len(sample_edit)
#while( len(st) != 0 ):
while( True ):
if reg_len == len(st):
break
reg_len = len(st)
for i in range(length):
word = sample_edit[i]
fd = st.startswith(word)
if fd > 0:
#print(st,i,dream_flg)
#st = ''.join(st[len(word):len(st)])
st = st[len(word):len(st)]
if word == 'dream':
dream_flg = True
elif word == 'er':
if dream_flg == False:
end_flg = True
else:
dream_flg = False
break
if end_flg == True:
break
if len(st) == 0:
ret = 'YES'
break
#print(st)
#print(len(st))
print( ret ) |
s527906073 | p03563 | u634079249 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 257 | Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it. | import sys
import os
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
R = float(sys.stdin.readline().rstrip())
G = float(sys.stdin.readline().rstrip())
print(R+(G-R)*2)
if __name__ == '__main__':
main()
| s703202622 | Accepted | 17 | 2,940 | 250 | import sys
import os
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
R = int(sys.stdin.readline().rstrip())
G = int(sys.stdin.readline().rstrip())
print(2*G-R)
if __name__ == '__main__':
main()
|
s391785066 | p03852 | u544050502 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 80 | Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | c=input()
print("vowel" if ["a","e","i","u","o",c].index(c)==5 else "consonant") | s965344969 | Accepted | 17 | 2,940 | 53 | print("vowel" if input() in "aiueo" else "consonant") |
s715532452 | p02402 | u829107115 | 1,000 | 131,072 | Wrong Answer | 20 | 5,608 | 160 | Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence. | n = int(input())
l = input().split()
mini = min(l)
maxi = max(l)
sums = 0
for i in range(0,n):
sums = sums + int(l[i])
print(f"{mini} {maxi} {sums}")
| s300346472 | Accepted | 20 | 6,608 | 176 | n = int(input())
l = list(map(int,input().split()))
mini = min(l)
maxi = max(l)
sums = 0
for i in range(0,n):
sums = sums + int(l[i])
print(f"{mini} {maxi} {sums}")
|
s133796230 | p03473 | u609255576 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 25 | How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December? | print(int(input()) + 24)
| s851463917 | Accepted | 17 | 2,940 | 30 | print(24 - int(input()) + 24)
|
s096851101 | p02408 | u085472528 | 1,000 | 131,072 | Wrong Answer | 20 | 7,384 | 131 | 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. | data = ["{0} {1}" .format(s, r)
for s in ('S','H','C','D')
for r in range(1, 13 + 1)
]
print(data) | s126970021 | Accepted | 20 | 7,716 | 218 | data = [
"{0} {1}" .format(s, r)
for s in ('S','H','C','D')
for r in range(1, 13 + 1)
]
count = int(input())
for c in range(count):
card = input()
data.remove(card)
for c in data:
print(c) |
s646227710 | p02402 | u192145025 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 225 | Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence. | n = int(input())
s = input().split()
max = s[0]
min = s[0]
for i in range(n):
if max < s[i]:
max = s[i]
if min > s[i]:
min = s[i]
sum = min + max
print(min, end =" ")
print(max, end =" ")
print(sum)
| s619266272 | Accepted | 20 | 6,600 | 266 | n = int(input())
s = list(map(int, input().strip().split(' ')))
max = s[0]
min = s[0]
sum = 0
for i in range(n):
sum = sum + s[i]
if max < s[i]:
max = s[i]
if min > s[i]:
min = s[i]
print(min, end =" ")
print(max, end =" ")
print(sum)
|
s754530761 | p00452 | u797673668 | 1,000 | 131,072 | Time Limit Exceeded | 40,000 | 23,204 | 719 | あなたは以下のルールでダーツゲームをすることになった. あなたは,矢を的(まと)に向かって 4 本まで投げることができる.必ずしも 4 本全てを投げる必要はなく,1 本も投げなくてもかまわない.的は N 個の部分に区切られていて,各々の部分に点数 P1,..., PN が書か れている.矢が刺さった場所の点数の合計 S があなたの得点の基礎となる.S があらかじめ決められたある点数 M 以下の場合は S がそのままあなたの得点となる.しかし,S が M を超えた場合はあなたの得点は 0 点となる. 的に書かれている点数と M の値が与えられたとき,あなたが得ることのできる点数の最大値を求めるプログラムを作成せよ. | while True:
n, m = map(int, input().split())
if not n:
break
ps = {int(input()) for _ in range(n)}
ss = [False] * (m + 1)
min_p, max_p = 1e8, 0
for p in ps:
ss[p] = True
if min_p > p: min_p = p
if max_p < p: max_p = p
max_s = 0
for t in range(1, 4):
new_ss = [False] * (m + 1)
for i in range(min(m, max_p * t), min_p * t - 1, -1):
if ss[i]:
for p in ps:
if i + p <= m:
new_ss[i + p] = True
ss = new_ss
p = m
while p:
if ss[p]:
if max_s < p:
max_s = p
break
print(max_s) | s484812936 | Accepted | 4,750 | 56,332 | 405 | from bisect import bisect_right
while True:
n, m = map(int, input().split())
if not n:
break
ps = [0] + sorted(int(input()) for _ in range(n))
p2 = set()
for i, pi in enumerate(ps):
for pj in ps[i:]:
if pi + pj > m:
break
p2.add(pi + pj)
p2 = sorted(p2)
print(max(pi + p2[bisect_right(p2, m - pi) - 1] for pi in p2)) |
s491479728 | p00208 | u755162050 | 1,000 | 131,072 | Time Limit Exceeded | 40,000 | 7,688 | 290 | ウォーターデブンに住む建築家のデブンキーさんのもとに、古い大病院を改装する仕事の依頼が舞い込んできました。 国によっては忌み数(いみかず)として嫌われる数字を部屋番号に用いたくない人がいます(日本では 4 と 9 が有名です)。しかし、この病院の部屋番号は忌み数に関係なく、1 から順番に付けられていました。 それが気になったデブンキーさんは、機材やベッドの入れ替えが全て終わる前にウォーターデブンの忌み数である「4」と「6」を除いた数字で部屋番号を付けなおしてしまいました。しかし、入れ替え作業は旧部屋番号で計画していたので、残りの作業を確実に行うには旧部屋番号を新部屋番号に変換する必要があります。計算が苦手なデブンキーさんはこのことに気づいて愕然としています。 そんなデブンキーさんのために、旧部屋番号を入力とし対応する新部屋番号を出力するプログラムを作成してください。 15 番目までの部屋番号の対応表は以下のようになります。 旧部屋番号| 1| 2| 3| 4| 5| 6| 7| 8 | 9 | 10 | 11| 12| 13| 14| 15 ---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|--- 新部屋番号| 1| 2| 3| 5 | 7| 8| 9| 10| 11| 12| 13| 15| 17| 18 | 19 | while True:
num = int(input())
index = 1
for n in range(1, num):
index += 1
while True:
str_index = str(index)
if '4' in str_index or '6' in str_index:
index += 1
else:
break
print(index) | s447663136 | Accepted | 250 | 7,580 | 283 | """ Created by Jieyi on 9/20/16. """
def main():
while True:
num = int(input())
if num == 0:
break
num = str(oct(num)[2:])
ans = num.translate(str.maketrans('4567', '5789'))
print(ans)
if __name__ == '__main__':
main() |
s968530070 | p03827 | u693048766 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 153 | You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation). | state = [0]
for c in list(input()):
if c == "D":
a = state[-1]
a -= 1
else:
a = state[-1]
a += 1
state.append(a)
print(max(state))
| s391676844 | Accepted | 21 | 3,316 | 188 | state = [0]
n = int(input())
chars = list(input())
for c in chars:
if c == "D":
a = state[-1]
a -= 1
else:
a = state[-1]
a += 1
state.append(a)
print(max(state))
|
s263730943 | p03679 | u637175065 | 2,000 | 262,144 | Wrong Answer | 41 | 5,456 | 675 | Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache. | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def main():
x,a,b = LI()
if a <= b:
return 'delicious'
if a+x <= b:
return 'safe'
return 'dangerous'
print(main())
| s651910134 | Accepted | 68 | 7,360 | 675 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def main():
x,a,b = LI()
if a >= b:
return 'delicious'
if a+x >= b:
return 'safe'
return 'dangerous'
print(main())
|
s552746005 | p02255 | u520845247 | 1,000 | 131,072 | Wrong Answer | 20 | 7,608 | 249 | Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step. | input()
xs = list(map(int, input().split()))
def insertion_sort(xs):
for i in range(1, len(xs)):
v = xs[i]
j = i - 1
while j >= 0 and xs[j] > v:
xs[j + 1] = xs[j]
j -= 1
xs[j + 1] = v
print(*xs)
insertion_sort(xs) | s033328658 | Accepted | 20 | 8,112 | 260 | input()
xs = list(map(int, input().split()))
def insertion_sort(xs):
for i in range(1, len(xs)):
v = xs[i]
j = i - 1
while j >= 0 and xs[j] > v:
xs[j + 1] = xs[j]
j -= 1
xs[j + 1] = v
print(*xs)
print(*xs)
insertion_sort(xs) |
s745113931 | p03473 | u667024514 | 2,000 | 262,144 | Wrong Answer | 19 | 3,316 | 31 | How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December? | a = int(input())
print(a + 24) | s768702164 | Accepted | 21 | 3,316 | 34 | a = int(input())
print((24-a)+24) |
s131406511 | p02605 | u667024514 | 3,000 | 1,048,576 | Wrong Answer | 2,132 | 111,268 | 1,727 | M-kun is a brilliant air traffic controller. On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all flying at the same altitude. Each of the airplanes flies at a constant speed of 0.1 per second in a constant direction. The current coordinates of the airplane numbered i are (X_i, Y_i), and the direction of the airplane is as follows: * if U_i is `U`, it flies in the positive y direction; * if U_i is `R`, it flies in the positive x direction; * if U_i is `D`, it flies in the negative y direction; * if U_i is `L`, it flies in the negative x direction. To help M-kun in his work, determine whether there is a pair of airplanes that will collide with each other if they keep flying as they are now. If there is such a pair, find the number of seconds after which the first collision will happen. We assume that the airplanes are negligibly small so that two airplanes only collide when they reach the same coordinates simultaneously. | n = int(input())
ans = 10 ** 9
upanddown = [[] for i in range(200001)]
leftandright = [[] for i in range(200001)]
lis = []
for i in range(n):
x,y,r = map(str,input().split())
x,y = int(x),int(y)
lis.append([x+y,x-y,x,y,r])
if r == "U":
upanddown[x].append([y,0])
elif r == "D":
upanddown[x].append([y,1])
elif r == "R":
leftandright[y].append([x,0])
else:
leftandright[y].append([x,1])
# print(upanddown[11])
for li in upanddown:
if len(li) >= 2:
li.sort(key=lambda z:z[1])
li.sort(key=lambda z:z[0])
key = 0
keynum = -1
for num,r in li:
if r == 0:
keynum = num
else:
if keynum != -1:
ans = min(ans,num-keynum)
for li in leftandright:
if len(li) >= 2:
li.sort(key=lambda z:z[1])
li.sort(key=lambda z:z[0])
key = 0
keynum = -1
for num,r in li:
if r == 0:
keynum = num
else:
if keynum != -1:
ans = min(ans,(num-keynum)*5)
# print(ans)
lis.sort(key = lambda z:z[2])
lis.sort(key = lambda z:z[0])
for i in range(n-1):
if lis[i][0] == lis[i+1][0]:
if (lis[i][4] == "R" and lis[i+1][4] == "U") or (lis[i][4] == "D" or lis[i+1][4] == "L"):
ans = min(ans,(lis[i+1][2]-lis[i][2])*10)
lis.sort(key = lambda z:z[2])
lis.sort(key = lambda z:z[1])
for i in range(n-1):
if lis[i][1] == lis[i+1][1]:
if (lis[i][4] == "U" and lis[i+1][4] == "L") or (lis[i][4] == "R" and lis[i+1][4] == "D"):
ans = min(ans,(lis[i+1][2]-lis[i][2])*10)
if ans == 10 ** 9:
print("SAFE")
else:
print(ans) | s953170968 | Accepted | 1,980 | 111,036 | 1,736 | n = int(input())
ans = 10 ** 10
upanddown = [[] for i in range(200001)]
leftandright = [[] for i in range(200001)]
lis = []
for i in range(n):
x,y,r = map(str,input().split())
x,y = int(x),int(y)
lis.append([x+y,x-y,x,y,r])
if r == "U":
upanddown[x].append([y,0])
elif r == "D":
upanddown[x].append([y,1])
elif r == "R":
leftandright[y].append([x,0])
else:
leftandright[y].append([x,1])
# print(upanddown[11])
for li in upanddown:
if len(li) >= 2:
li.sort(key=lambda z:z[1])
li.sort(key=lambda z:z[0])
key = 0
keynum = -1
for num,r in li:
if r == 0:
keynum = num
else:
if keynum != -1:
ans = min(ans,(num-keynum)*5)
for li in leftandright:
if len(li) >= 2:
li.sort(key=lambda z:z[1])
li.sort(key=lambda z:z[0])
key = 0
keynum = -1
for num,r in li:
if r == 0:
keynum = num
else:
if keynum != -1:
ans = min(ans,(num-keynum)*5)
# print(ans)
lis.sort(key = lambda z:z[2])
lis.sort(key = lambda z:z[0])
for i in range(n-1):
if lis[i][0] == lis[i+1][0]:
if (lis[i][4] == "R" and lis[i+1][4] == "U") or (lis[i][4] == "D" and lis[i+1][4] == "L"):
ans = min(ans,(lis[i+1][2]-lis[i][2])*10)
lis.sort(key = lambda z:z[2])
lis.sort(key = lambda z:z[1])
for i in range(n-1):
if lis[i][1] == lis[i+1][1]:
if (lis[i][4] == "U" and lis[i+1][4] == "L") or (lis[i][4] == "R" and lis[i+1][4] == "D"):
ans = min(ans,(lis[i+1][2]-lis[i][2])*10)
if ans == 10 ** 10:
print("SAFE")
else:
print(ans) |
s230609501 | p03434 | u919633157 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 134 | 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())
s=list(map(int,input().split()))
s.sort()
a=[int(i) for i in s[::-2]]
b=[int(j) for j in s[1::-2]]
print(sum(a)-sum(b)) | s942540935 | Accepted | 17 | 2,940 | 93 | n=int(input())
a=sorted(list(map(int,input().split())))
print(sum(a[-1::-2])-sum(a[-2::-2]))
|
s507099804 | p00725 | u420446254 | 1,000 | 131,072 | Wrong Answer | 20 | 5,520 | 186 | On Planet MM-21, after their Olympic games this year, curling is getting popular. But the rules are somewhat different from ours. The game is played on an ice game board on which a square mesh is marked. They use only a single stone. The purpose of the game is to lead the stone from the start to the goal with the minimum number of moves. Fig. D-1 shows an example of a game board. Some squares may be occupied with blocks. There are two special squares namely the start and the goal, which are not occupied with blocks. (These two squares are distinct.) Once the stone begins to move, it will proceed until it hits a block. In order to bring the stone to the goal, you may have to stop the stone by hitting it against a block, and throw again. Fig. D-1: Example of board (S: start, G: goal) The movement of the stone obeys the following rules: * At the beginning, the stone stands still at the start square. * The movements of the stone are restricted to x and y directions. Diagonal moves are prohibited. * When the stone stands still, you can make it moving by throwing it. You may throw it to any direction unless it is blocked immediately(Fig. D-2(a)). * Once thrown, the stone keeps moving to the same direction until one of the following occurs: * The stone hits a block (Fig. D-2(b), (c)). * The stone stops at the square next to the block it hit. * The block disappears. * The stone gets out of the board. * The game ends in failure. * The stone reaches the goal square. * The stone stops there and the game ends in success. * You cannot throw the stone more than 10 times in a game. If the stone does not reach the goal in 10 moves, the game ends in failure. Fig. D-2: Stone movements Under the rules, we would like to know whether the stone at the start can reach the goal and, if yes, the minimum number of moves required. With the initial configuration shown in Fig. D-1, 4 moves are required to bring the stone from the start to the goal. The route is shown in Fig. D-3(a). Notice when the stone reaches the goal, the board configuration has changed as in Fig. D-3(b). Fig. D-3: The solution for Fig. D-1 and the final board configuration | while():
w, h = map(int, input().split())
if w == 0 or h == 0:
break
field = []
for y in range(h):
field.append(map(int, input().split()))
print(-1)
| s282896739 | Accepted | 4,470 | 5,624 | 2,074 | dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
N_MOVE = 4
EMPTY = 0
ROCK = 1
START = 2
GOAL = 3
INF = 100000
def in_field(field, x, y):
return y >=0 and y < len(field) and x >= 0 and x< len(field[0])
def move_to_rock(field, x, y, direction):
while(True):
x += dx[direction]
y += dy[direction]
if not in_field(field, x, y):
return None
elif field[y][x] == ROCK:
x -= dx[direction]
y -= dy[direction]
break
elif field[y][x] == GOAL:
break
return x, y
def dfs(depth, field, x, y):
if depth > 10:
return None
cost = INF
for r in range(N_MOVE):
if cost <= depth:
return cost
nx, ny = x + dx[r], y + dy[r]
if not in_field(field, nx, ny):
continue
if field[ny][nx] == ROCK:
continue
next_pos = move_to_rock(field, x, y, r)
if next_pos is None:
continue
nx, ny = next_pos
if field[ny][nx] == GOAL:
return depth
rock_pos_x, rock_pos_y = nx+dx[r], ny+dy[r]
assert field[rock_pos_y][rock_pos_x] == ROCK
field[rock_pos_y][rock_pos_x] = EMPTY
result = dfs(depth+1, field, nx, ny)
if result is not None:
cost = min(cost, result)
field[rock_pos_y][rock_pos_x] = ROCK
return cost
def find_start_pos(field):
h = len(field)
w = len(field[0])
for y in range(h):
for x in range(w):
if field[y][x] == START:
return x, y
return None # ?
def solve():
w, h = map(int, input().split())
if w == 0 or h == 0:
return None
field = []
for y in range(h):
field.append(list(map(int, input().split())))
x, y = find_start_pos(field)
res = dfs(1, field, x, y)
return res
if __name__ == '__main__':
while(True):
answer = solve()
if answer is None:
break
elif answer == INF:
print(-1)
else:
print(answer)
|