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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s776358364 | p03456 | u516079286 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 179 | AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number. | a,b = map(int, input().split())
ab = str(a)+str(b)
import math
s = math.sqrt(int(ab))
if (s.is_integer() == True or isinstance(s, int) == True):
print("yes")
else:
print("no") | s589492960 | Accepted | 17 | 2,940 | 151 | a,b = input().split()
import math
s = math.sqrt(int(a+b))
if (s.is_integer() == True or isinstance(s, int) == True):
print("Yes")
else:
print("No") |
s457952002 | p04011 | u318661636 | 2,000 | 262,144 | Wrong Answer | 25 | 9,120 | 158 | 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. | n = int(input())
k = int(input())
x = int(input())
y = int(input())
ans = 0
for i in range(n):
if i <= k:
ans += x
else:
ans += y
print(ans) | s454986058 | Accepted | 26 | 9,000 | 157 | n = int(input())
k = int(input())
x = int(input())
y = int(input())
ans = 0
for i in range(n):
if i < k:
ans += x
else:
ans += y
print(ans) |
s005649513 | p03759 | u867826040 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 86 | Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful. | a,b,c = map(int,input().split())
if b-a == c-b:
print("Yes")
else:
print("No") | s777313927 | Accepted | 18 | 2,940 | 86 | a,b,c = map(int,input().split())
if b-a == c-b:
print("YES")
else:
print("NO") |
s635883799 | p03434 | u892308039 | 2,000 | 262,144 | Wrong Answer | 25 | 3,604 | 396 | We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score. | N = int(input())
a = list(map(int,input().split()))
for i in range(N):
for j in reversed(range(i+1,N)):
print(i,j)
if a[j] > a[j-1]:
temp = a[j]
a[j] = a[j-1]
a[j-1] = temp
Alice = 0
Bob = 0
k = 0
count =1
while k < N:
if count % 2 == 0:
Bob += a[k]
else:
Alice += a[k]
k += 1
count += 1
print(Alice-Bob) | s395476358 | Accepted | 19 | 3,064 | 397 | N = int(input())
a = list(map(int,input().split()))
for i in range(N):
for j in reversed(range(i+1,N)):
#print(i,j)
if a[j] > a[j-1]:
temp = a[j]
a[j] = a[j-1]
a[j-1] = temp
Alice = 0
Bob = 0
k = 0
count =1
while k < N:
if count % 2 == 0:
Bob += a[k]
else:
Alice += a[k]
k += 1
count += 1
print(Alice-Bob) |
s437715668 | p02406 | u744114948 | 1,000 | 131,072 | Wrong Answer | 30 | 6,716 | 90 | In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; } | for i in range(3,int(input())+1,3):
if i % 3 == 0: print(" "+str(i), end="")
print("") | s010541480 | Accepted | 50 | 6,736 | 272 | for i in range(1,int(input())+1):
x=i
if x % 3 == 0:
print(" "+str(i), end="")
else:
while x != 0:
if x % 10 == 3:
print(" "+str(i), end="")
break
else:
x = x//10
print("") |
s635867242 | p03501 | u390958150 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 50 | You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours. | n,a,b = map(int,input().split())
print(max(n*a,b)) | s463261756 | Accepted | 19 | 3,060 | 50 | n,a,b = map(int,input().split())
print(min(n*a,b)) |
s145047936 | p03352 | u739843002 | 2,000 | 1,048,576 | Wrong Answer | 31 | 9,340 | 352 | 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. | p = []
p.extend([i ** 2 for i in range(int(1000**(1/2)) + 1)])
p.extend([i ** 3 for i in range(int(1000**(1/3)) + 1)])
p.extend([i ** 5 for i in range(int(1000**(1/5)) + 1)])
p.extend([i ** 7 for i in range(int(1000**(1/7)) + 1)])
p.sort()
p.append(1000)
print(p)
N = int(input())
for i in range(len(p) - 1):
if p[i] <= N < p[i + 1]:
print(p[i]) | s471092222 | Accepted | 26 | 9,388 | 361 | p = []
p.extend([i ** 2 for i in range(int(1000**(1/2)) + 1)])
p.extend([i ** 3 for i in range(int(1000**(1/3)) + 1)])
p.extend([i ** 5 for i in range(int(1000**(1/5)) + 1)])
p.extend([i ** 7 for i in range(int(1000**(1/7)) + 1)])
p.sort()
p.append(1000)
p.append(1001)
N = int(input())
for j in range(len(p) - 1):
if p[j] <= N < p[j + 1]:
print(p[j]) |
s640789356 | p03729 | u202570162 | 2,000 | 262,144 | Wrong Answer | 20 | 2,940 | 104 | 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`. | l = input().split()
if all(l[i][-1] == l[i+1][0] for i in [0,1]):
print('Yes')
else:
print('No') | s844883521 | Accepted | 17 | 2,940 | 130 | l = input().split()
a = l[0][-1] == l[1][0]
b = l[1][-1] == l[2][0]
flag = a and b
if flag:
print('YES')
else:
print('NO') |
s660991145 | p02936 | u798260206 | 2,000 | 1,048,576 | Time Limit Exceeded | 2,208 | 105,308 | 588 | Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations. | import collections
n,q=map(int,input().split())
cnt=[0]*(n+1)
g=[[] for _ in range(n+1)]
for _ in range(n-1):
a,b=map(int,input().split())
g[a].append(b)
g[b].append(a)
for _ in range(q):
v,val=map(int,input().split())
cnt[v]+=val
q=collections.deque()
q.append(1)
while q:
v=q.pop()
for u in g[v]:
cnt[u]+=cnt[v]
q.append(u)
print(*cnt[1:]) | s462965709 | Accepted | 1,103 | 58,196 | 895 | import collections
n,q=map(int,input().split())
cnt=[0]*(n+1)
g=[[] for _ in range(n+1)]
for _ in range(n-1):
a,b=map(int,input().split())
g[a].append(b)
g[b].append(a)
for _ in range(q):
v,val=map(int,input().split())
cnt[v]+=val
q=collections.deque()
q.append(1)
checked=[0]*(n+1)
while q:
v=q.pop()
checked[v]=1
for u in g[v]:
if checked[u]==1:
continue
cnt[u]+=cnt[v]
q.append(u)
print(*cnt[1:]) |
s861939062 | p03861 | u923659712 | 2,000 | 262,144 | Wrong Answer | 2,104 | 2,940 | 125 | You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x? | a,b,x = map(int,input().split())
num= range(a,b)
d =0
for c in num:
if c%x == 0:
d+=1
else:
continue
print(d) | s925825833 | Accepted | 17 | 2,940 | 55 | a,b,x = map(int,input().split())
print(b//x-(a-1)//x) |
s719130988 | p03354 | u075595666 | 2,000 | 1,048,576 | Wrong Answer | 278 | 32,880 | 444 | We have a permutation of the integers from 1 through N, p_1, p_2, .., p_N. We also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M). AtCoDeer the deer is going to perform the following operation on p as many times as desired so that the number of i (1 ≤ i ≤ N) such that p_i = i is maximized: * Choose j such that 1 ≤ j ≤ M, and swap p_{x_j} and p_{y_j}. Find the maximum possible number of i such that p_i = i after operations. | import sys
input = sys.stdin.readline
n,m = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
p = tuple(p)
uni = set()
num = set()
chk = [int(i)+1 for i in range(n)]
chk = set(chk)
for i in range(m):
x,y = [int(i) for i in input().split()]
uni.add(p[x-1])
uni.add(p[y-1])
num.add(x)
num.add(y)
ans = len(uni & num)
diff = chk-num
diff = list(diff)
for i in diff:
if i == p[i-1]:
ans += 1
print(ans) | s980729902 | Accepted | 701 | 64,124 | 722 | import sys
input = sys.stdin.readline
n,m = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
p = tuple(p)
chk = [[set(),set()] for i in range(n)]
def find(x):
if par[x] < 0:
return x
else:
par[x] = find(par[x])
return par[x]
def unite(x,y):
x = find(x)
y = find(y)
if x == y:
return False
else:
if par[x] > par[y]:
x,y = y,x
par[x] += par[y]
par[y] = x
return True
def same(x,y):
return find(x) == find(y)
par = [-1]*n
ans = 0
for i in range(m):
x,y = [int(i) for i in input().split()]
unite(x-1,y-1)
for i,pi in enumerate(p):
if same(i,pi-1):
ans += 1
print(ans) |
s848104310 | p03730 | u013373291 | 2,000 | 262,144 | Wrong Answer | 25 | 9,052 | 221 | 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`. | #!/usr/bin/env python3
A,B,C = [int(i) for i in input().split()]
M = []
for i in range(1,100+1):
if (A*i)%B in M:
break
else:
M.append((A*i)%B)
if C in M:
print("Yes")
else:
print("No")
| s513814293 | Accepted | 26 | 9,144 | 221 | #!/usr/bin/env python3
A,B,C = [int(i) for i in input().split()]
M = []
for i in range(1,100+1):
if (A*i)%B in M:
break
else:
M.append((A*i)%B)
if C in M:
print("YES")
else:
print("NO")
|
s414536719 | p03478 | u562935282 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 253 | Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). | n, a, b = map(int, input().split())
sum = 0
for ia in range(10):
for ib in range(10):
if a<=(ia + ib)<=b:
v = 10*ia + ib
if v<=n:
print('{}{}'.format(ia, ib))
sum += v
print(sum)
| s514726756 | Accepted | 27 | 2,940 | 348 | def main():
N, A, B = map(int, input().split())
ans = 0
for x in range(1, N + 1):
if A <= sum(map(int, str(x))) <= B:
ans += x
print(ans)
if __name__ == '__main__':
main()
# import sys
#
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())
|
s114701208 | p03228 | u127499732 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 146 | In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person. Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total. | a,b,k=map(int,input().split())
for _ in range(k):
if a%2==1:
a-=1
b+=a/2
a=a/2
if b%2==1:
b-=1
a+=b/2
b=b/2
print(a,b) | s088019983 | Accepted | 17 | 3,064 | 178 | a,b,k=map(int,input().split())
s=[a,b]
for i in range(k):
x,y=int((1-(-1)**i)/2),int((1+(-1)**i)/2)
if s[x]%2==1:
s[x]-=1
s[y]+=s[x]//2
s[x]-=s[x]//2
print(s[0],s[1]) |
s918145612 | p04045 | u738341948 | 2,000 | 262,144 | Wrong Answer | 99 | 3,700 | 202 | Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier. | n,k = map(int,input().strip().split())
d = list(input().split())
for x in range(n,100000):
for y in d:
if y in str(x):
break
else:
print(x)
break
| s855337982 | Accepted | 67 | 2,940 | 190 | n,k = map(int,input().strip().split())
d = list(input().split())
for x in range(n,100000):
for y in d:
if y in str(x):
break
else:
print(x)
break
|
s568343484 | p03836 | u753803401 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 243 | Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him. | x1, y1, x2, y2 = map(int, input().split())
x = abs(x1 - x2)
y = abs(y1 - y2)
print(x, y)
a = ""
a += ("U" * y + "R" * x + "D" * y + "L" * x)
a += ("L" + "U" * (y + 1) + "R" * (x + 1) + "D" + "R" + "D" * (y + 1) + "L" * (x + 1) + "U")
print(a)
| s077430548 | Accepted | 20 | 3,188 | 231 | x1, y1, x2, y2 = map(int, input().split())
x = abs(x1 - x2)
y = abs(y1 - y2)
a = ""
a += ("U" * y + "R" * x + "D" * y + "L" * x)
a += ("L" + "U" * (y + 1) + "R" * (x + 1) + "D" + "R" + "D" * (y + 1) + "L" * (x + 1) + "U")
print(a)
|
s745165045 | p02645 | u923010184 | 2,000 | 1,048,576 | Wrong Answer | 25 | 8,976 | 30 | When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him. | A = str(input())
print(A[0:2]) | s019229230 | Accepted | 22 | 9,016 | 31 | A = str(input())
print(A[0:3])
|
s690102674 | p04011 | u106342872 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 124 | 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. | n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n <= k:
print(n*x)
else:
print(n*x + (n-k)*y) | s745552459 | Accepted | 18 | 2,940 | 125 | n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n <= k:
print(n*x)
else:
print(k*x + (n-k)*y)
|
s197788085 | p02637 | u340781749 | 2,000 | 1,048,576 | Wrong Answer | 30 | 9,136 | 701 | Given are an integer K and integers a_1,\dots, a_K. Determine whether a sequence P satisfying below exists. If it exists, find the lexicographically smallest such sequence. * Every term in P is an integer between 1 and K (inclusive). * For each i=1,\dots, K, P contains a_i occurrences of i. * For each term in P, there is a contiguous subsequence of length K that contains that term and is a permutation of 1,\dots, K. | import sys
def solve(k, aaa):
aaa_idx = [[a, i] for i, a in enumerate(aaa, start=1)]
aaa_idx.sort()
min_a = aaa_idx[0][0]
if min_a * 2 < aaa_idx[-1][1]:
return [-1]
ans = []
for _ in range(min_a):
double = []
single = []
for j in range(k):
a, i = aaa_idx[j]
if a > min_a:
double.append(i)
aaa_idx[j][0] -= 2
else:
single.append(i)
aaa_idx[j][0] -= 1
ans.extend(double)
ans.extend(single)
ans.extend(double)
min_a -= 1
return ans
k, *aaa = map(int, sys.stdin.buffer.read().split())
print(*solve(k, aaa))
| s902919271 | Accepted | 971 | 9,372 | 2,307 | import sys
def find_permutation(aaa, use):
max_a = -1
min_a = 1005
max_fixed = -1
for i in range(k):
a = aaa[i]
if i + 1 in use:
min_a = min(min_a, a)
max_a = max(max_a, a)
else:
max_fixed = max(max_fixed, a)
if max(max_a, max_fixed + 1) > 2 * min_a:
return None
if max_a < 2 * min_a:
return sorted(use)
front = []
rear = []
either = []
for i in use:
if aaa[i - 1] == max_a:
front.append(i)
elif aaa[i - 1] == min_a:
rear.append(i)
else:
either.append(i)
max_front = front[-1]
for i in either:
if i < max_front:
front.append(i)
else:
rear.append(i)
front.sort()
rear.sort()
front.extend(rear)
return front
def solve(k, aaa):
if k == 1:
return [1] * aaa[0]
min_a = min(aaa)
max_a = max(aaa)
if min_a * 2 < max_a:
return [-1]
ans = []
ans.extend(find_permutation(aaa, set(range(1, k + 1))))
for i in range(k):
aaa[i] -= 1
remaining = sum(aaa)
while remaining:
use = set(range(1, k + 1))
candidates = []
for r in range(k):
result = find_permutation(aaa, use)
if result is not None:
candidates.append(result)
use.remove(ans[-r - 1])
adopted = min(candidates)
ans.extend(adopted)
for i in adopted:
aaa[i - 1] -= 1
remaining -= len(adopted)
return ans
k, *aaa = map(int, sys.stdin.buffer.read().split())
print(*solve(k, aaa))
|
s057861444 | p03854 | u943004959 | 2,000 | 262,144 | Wrong Answer | 19 | 3,956 | 690 | 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`. | def solve():
while 1:
try:
s = list(input())
s.reverse()
s = "".join(s)
if len(s) < 5:
raise EndLoop
l = 0
r = 5
while r <= len(s):
if s[l:r] == "maerd" or s[l:r] == "esare":
l += 5
r += 5
elif s[l:r] == "remae" or s[l:r] == "resar":
l += 7
r += 7
else:
raise EndLoop
print(l, r)
print(len(s))
print("YES")
break
except:
print("NO")
break
solve() | s269679345 | Accepted | 31 | 3,956 | 952 | def solve():
while 1:
try:
s = list(input())
s.reverse()
s = "".join(s)
if len(s) < 5:
raise EndLoop
l = 0
r = 5
while r <= len(s):
if s[l:r] == "maerd" or s[l:r] == "esare":
l += 5
r += 5
elif s[l:r] == "remae":
if s[l:r + 2] == "remaerd":
l += 7
r += 7
else:
raise EndLoop
elif s[l:r] == "resar":
if s[l:r + 1] == "resare":
l += 6
r += 6
else:
raise EndLoop
else:
raise EndLoop
print("YES")
break
except:
print("NO")
break
solve() |
s474693892 | p00710 | u489876484 | 1,000 | 131,072 | Wrong Answer | 110 | 5,624 | 377 | There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. There is a deck of _n_ cards. Starting from the _p_ -th card from the top of the deck, _c_ cards are pulled out and put on the top of the deck, as shown in Figure 1. This operation, called a cutting operation, is repeated. Write a program that simulates Hanafuda shuffling and answers which card will be finally placed on the top of the deck. --- Figure 1: Cutting operation | while True:
n, r = list(map(lambda x: int(x), input().split(" ")))
if n == 0 and r == 0:
break
cards = [i for i in range(1,n+1)]
cards = cards[::-1]
for i in range(r):
print(cards)
p, c = list(map(lambda x: int(x), input().split(" ")))
p -= 1
cards = cards[p:p+c] + cards[0:p] + cards[p+c:]
print(cards[0])
| s562379527 | Accepted | 60 | 5,628 | 356 | while True:
n, r = list(map(lambda x: int(x), input().split(" ")))
if n == 0 and r == 0:
break
cards = [i for i in range(1,n+1)]
cards = cards[::-1]
for i in range(r):
p, c = list(map(lambda x: int(x), input().split(" ")))
p -= 1
cards = cards[p:p+c] + cards[0:p] + cards[p+c:]
print(cards[0])
|
s287048739 | p03456 | u375500286 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 80 | AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number. | import math
a,b=input().split()
n=int(a+b)
"Yes" if math.sqrt(n)%1==0 else "No"
| s220372753 | Accepted | 17 | 2,940 | 94 | import math
a,b=input().split()
n=int(a+b)
print("Yes" if math.sqrt(n).is_integer() else "No") |
s430786700 | p03303 | u377867256 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 131 | You are given a string S consisting of lowercase English letters. We will write down this string, starting a new line after every w letters. Print the string obtained by concatenating the letters at the beginnings of these lines from top to bottom. | S = input()
w = int(input())
L = (len(S) // w)
moji = str()
for i in range(L):
moji = moji + S[(i + 1)* w - 2]
print(moji) | s310554723 | Accepted | 17 | 3,060 | 178 | S = str(input())
w = int(input())
if len(S) % w == 0:
L = len(S) // w
else:
L = len(S) // w + 1
moji = str()
for i in range(L):
moji = moji + S[i* w]
print(moji) |
s427841079 | p03457 | u476124554 | 2,000 | 262,144 | Wrong Answer | 374 | 11,744 | 344 | 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())
t = []
x = []
y = []
ans = "Yes"
tmpx = 0
tmpy = 0
for i in range(n):
v1,v2,v3 = map(int,input().split())
t.append(v1)
x.append(v2)
y.append(v3)
for i in range(n):
if abs(tmpx-x[i]) + abs(tmpy-y[i]) <= t[i]:
tmpx = x[i]
tmpy = y[i]
continue
else:
flg = "No"
break | s287127226 | Accepted | 427 | 11,840 | 454 | n = int(input())
t = []
x = []
y = []
ans = "Yes"
tmpx = 0
tmpy = 0
tmpt = 0
for i in range(n):
v1,v2,v3 = map(int,input().split())
t.append(v1)
x.append(v2)
y.append(v3)
for i in range(n):
if abs(tmpx-x[i]) + abs(tmpy-y[i]) <= t[i] - tmpt and (abs(tmpx-x[i]) + abs(tmpy-y[i])) % 2 == (t[i] - tmpt) % 2:
tmpx = x[i]
tmpy = y[i]
tmpt = t[i]
continue
else:
ans = "No"
break
print(ans) |
s293504851 | p02844 | u903082918 | 2,000 | 1,048,576 | Wrong Answer | 397 | 9,592 | 908 | AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code. The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code. How many different PIN codes can he set this way? Both the lucky number and the PIN code may begin with a 0. |
import sys
import math
from functools import reduce
def readString():
return sys.stdin.readline()
def readInteger():
return int(readString())
def main(N, S):
""" main
"""
count = 0
skip1 = []
skip2 = []
skip3 = []
for i in range(0, N):
if S[i] in skip1:
continue
skip1.append(S[i])
for j in range(i+1, N):
if S[j] in skip2:
continue
skip2.append(S[j])
for k in range(j+1, N):
if S[k] in skip3:
continue
skip3.append(S[k])
print(S[i]+S[j]+S[k])
count += 1
skip3 = []
skip2 = []
return count
if __name__ == "__main__":
_N = readInteger()
_S = readString()
print(main(_N, _S)) | s249021682 | Accepted | 398 | 9,632 | 870 |
import sys
import math
from functools import reduce
def readString():
return sys.stdin.readline()
def readInteger():
return int(readString())
def main(N, S):
""" main
"""
count = 0
skip1 = []
skip2 = []
skip3 = []
for i in range(0, N):
if S[i] in skip1:
continue
skip1.append(S[i])
for j in range(i+1, N):
if S[j] in skip2:
continue
skip2.append(S[j])
for k in range(j+1, N):
if S[k] in skip3:
continue
skip3.append(S[k])
count += 1
skip3 = []
skip2 = []
return count
if __name__ == "__main__":
_N = readInteger()
_S = readString()
print(main(_N, _S)) |
s800933143 | p03455 | u667749493 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 132 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | tmp = input()
a = int(tmp.split(" ")[0])
b = int(tmp.split(" ")[1])
x = a * b
if x % 2 == 0:
print('Odd')
else:
print('Even') | s030139909 | Accepted | 17 | 2,940 | 132 | tmp = input()
a = int(tmp.split(" ")[0])
b = int(tmp.split(" ")[1])
x = a * b
if x % 2 == 0:
print('Even')
else:
print('Odd') |
s340432180 | p03387 | u140251125 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 192 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | # input
X = list(map(int, input().split()))
X.sort()
if (2 * X[2] - X[1] - X[0]) % 2 == 0:
ans = (2 * X[2] - X[1] - X[0]) / 2
else:
ans = (2 * X[2] - X[1] - X[0] + 1) / 2
print(ans) | s101971121 | Accepted | 17 | 3,060 | 193 | # input
X = list(map(int, input().split()))
X.sort()
if (X[1] - X[0]) % 2 == 0:
ans = X[2] - X[1] + (X[1] - X[0]) // 2
else:
ans = X[2] - X[1] + 1 + (X[1] - X[0] + 1) //2
print(ans) |
s652469088 | p02678 | u586662847 | 2,000 | 1,048,576 | Wrong Answer | 23 | 8,992 | 523 | There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists. | def resolve():
n, m = map(int, input().split())
ab = [list(map(int, input().split()))for i in range(m)]
ans = [0] * n
edge = [[]for _ in range(n)]
for a, b in ab:
edge[a - 1].append(b - 1)
edge[b - 1].append(a - 1)
visited = {0}
stack = [0]
for i in stack:
for j in edge[i]:
if j in visited:
continue
stack.append(j)
visited.add(j)
ans[j] = i + 1
print("Yes")
print('\n'.join(map(str, ans[1:]))) | s309637510 | Accepted | 633 | 85,436 | 535 | def resolve():
n, m = map(int, input().split())
ab = [list(map(int, input().split()))for i in range(m)]
ans = [0] * n
edge = [[]for _ in range(n)]
for a, b in ab:
edge[a - 1].append(b - 1)
edge[b - 1].append(a - 1)
visited = {0}
stack = [0]
for i in stack:
for j in edge[i]:
if j in visited:
continue
stack.append(j)
visited.add(j)
ans[j] = i + 1
print("Yes")
print('\n'.join(map(str, ans[1:])))
resolve() |
s532484157 | p03555 | u847033024 | 2,000 | 262,144 | Wrong Answer | 27 | 9,096 | 74 | You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise. | a = input()
b = input()
if a == b[--1]:
print('YES')
else:
print('NO') | s015210978 | Accepted | 26 | 9,088 | 76 | a = input()
b = input()
if a == b[::-1]:
print('YES')
else:
print('NO')
|
s563446278 | p03380 | u143051858 | 2,000 | 262,144 | Wrong Answer | 2,206 | 20,468 | 523 | 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. | N = int(input())
a = list(map(int,input().split()))
m = 0
st_n = a[0]
st_r = a[1]
for n in range(N-1):
for r in range(n+1,N):
if a[r] != 0:
if m < a[n]*(a[n]-1)//a[r]:
st_n = a[n]
st_r = a[r]
m = a[n]*(a[n]-1)//a[r]
a.reverse()
for n in range(N-1):
for r in range(n+1,N):
if a[r] != 0:
if m < a[n]*(a[n]-1)//a[r]:
st_n = a[n]
st_r = a[r]
m = a[n]*(a[n]-1)//a[r]
print(st_n,st_r) | s605806202 | Accepted | 88 | 20,100 | 231 | N = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
st_n = a[0]
st_r = a[1]
m = st_r*(st_n-st_r)
for r in range(2,N):
cn = a[r]*(st_n-a[r])
if m < cn:
st_r = a[r]
m = cn
print(st_n,st_r) |
s361016873 | p03563 | u525117558 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 32 | 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=input()
G=input()
print(2*G+R) | s981003844 | Accepted | 17 | 2,940 | 42 | R=int(input())
G=int(input())
print(2*G-R) |
s866027136 | p02255 | u193453446 | 1,000 | 131,072 | Wrong Answer | 30 | 7,764 | 1,081 | 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. | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def iSort(A,N):
""" ?????\????????? """
# print(" ".join(map(str,A)))
for i in range(1, N):
v = A[i]
j = i - 1
while j >=0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(" ".join(map(str,A)))
# ?????????
num = int(input().strip())
arr = list(map(int,input().strip().split()))
iSort(arr,num) | s893270499 | Accepted | 20 | 7,772 | 1,080 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def iSort(A,N):
""" ?????\????????? """
print(" ".join(map(str,A)))
for i in range(1, N):
v = A[i]
j = i - 1
while j >=0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(" ".join(map(str,A)))
# ?????????
num = int(input().strip())
arr = list(map(int,input().strip().split()))
iSort(arr,num) |
s598949905 | p02936 | u798818115 | 2,000 | 1,048,576 | Wrong Answer | 2,108 | 79,088 | 497 | Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations. | N,Q=map(int,input().split())
side=[[0 for i in range(2)]for j in range(N-1)]
yobun=[[0 for i in range(2)]for j in range(Q)]
l=[0]*N
for i in range(N-1):
side[i][0],side[i][1]=map(int,input().split())
for i in range(Q):
yobun[i][0],yobun[i][1]=map(int,input().split())
def kyusyu(p,x):
l[p-1]+=x
for i in range(N-1):
if p==side[i][0]:
kyusyu(side[i][1],x)
for i in range(Q):
kyusyu(yobun[i][0],yobun[i][1])
print(l)
| s155692831 | Accepted | 1,576 | 230,992 | 659 | # coding: utf-8
# Your code here!
import sys
input=sys.stdin.readline
sys.setrecursionlimit(100000000)
N,Q=map(int,input().split())
l=[[i] for i in range(N)]
#print(l)
def dfs(num,point,visited):
visited[num]=1
point+=plus[num]
ans[num]=point
while l[num][-1]!=num:
temp=l[num].pop(-1)
if visited[temp]==0:
dfs(temp,point,visited)
return 0
for _ in range(N-1):
a,b=map(int,input().split())
l[a-1].append(b-1)
l[b-1].append(a-1)
ans=[0]*N
plus=[0]*N
for _ in range(Q):
p,x=map(int,input().split())
plus[p-1]+=x
dfs(0,0,[0]*N)
print(*ans)
|
s394881131 | p00013 | u150984829 | 1,000 | 131,072 | Wrong Answer | 20 | 5,572 | 84 | This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top- right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. We can simulate the movement (comings and goings) of the cars as follow: * An entry of a car is represented by its number. * An exit of a car is represented by 0 For example, a sequence 1 6 0 8 10 demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. | a=[]
while 1:
try:n=int(input());a.append(e)if e else print(a.pop())
except:break
| s958340043 | Accepted | 20 | 5,592 | 80 | import sys
a=[]
for e in map(int,sys.stdin):a.append(e)if e else print(a.pop())
|
s761308676 | p03543 | u813450984 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 64 | We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**? | N = input()
if N[1] == N[2]:
print('YES')
else:
print('NO') | s267349780 | Accepted | 17 | 2,940 | 162 | N = input()
nums = ["000", "111", "222", "333", "444", "555", "666", "777", "888", "999"]
if N[:3] in nums or N[1:] in nums:
print('Yes')
else:
print('No') |
s534078646 | p03435 | u752508211 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 282 | We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct. | rows = []
for _ in range(3):
rows.append(list(map(int, input().split())))
for i in range(3):
for j in range(3):
rows[i][j] -= rows[i][0]
ok = True
for j in range(3):
for i in range(3):
if rows[i][j] != rows[0][j]:
ok = False
if ok: print("Yes")
else: print("No") | s074995677 | Accepted | 17 | 3,064 | 290 | rows = []
for _ in range(3):
rows.append(list(map(int, input().split())))
for i in range(3):
for j in range(2, -1, -1):
rows[i][j] -= rows[i][0]
ok = True
for j in range(3):
for i in range(3):
if rows[i][j] != rows[0][j]:
ok = False
if ok: print("Yes")
else: print("No") |
s480652455 | p03625 | u503228842 | 2,000 | 262,144 | Wrong Answer | 158 | 21,384 | 339 | We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle. | N = int(input())
a = list(map(int,input().split()))
from collections import Counter
c = Counter(a)
#print(c.most_common())
if c.most_common()[0][1] >= 4:
print((c.most_common()[1][1])**2)
elif c.most_common()[0][1] == 1:
print(0)
elif c.most_common()[1][1] >= 2:
print(c.most_common()[0][1]*c.most_common()[1][1])
else:print(0) | s008881273 | Accepted | 107 | 14,252 | 427 | N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
#print(A)
cnt = 0
prev = 0
candidates = []
for i in A:
if i == prev:
cnt += 1
prev = i
elif i != prev:
prev = i
cnt = 0
if cnt >= 3:
print(i**2)
exit()
if cnt == 1:
candidates.append(i)
if len(candidates) == 2:
print(candidates[0]*candidates[1])
exit()
print(0) |
s423156346 | p03624 | u823044869 | 2,000 | 262,144 | Wrong Answer | 20 | 3,956 | 155 | You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead. | sList = sorted(list(set(list(input()))))
chI = ord('a')
for i in sList:
if chI == ord(i):
chI += 1
else:
print(chI)
exit(0)
print("None")
| s522196151 | Accepted | 20 | 3,956 | 206 | sList = sorted(list(set(list(input()))))
chI = ord('a')
for i in sList:
if chI == ord(i):
chI += 1
else:
print(chr(chI))
exit(0)
if len(sList) != 26:
print(chr(chI))
else:
print("None")
|
s616926543 | p03779 | u743164083 | 2,000 | 262,144 | Wrong Answer | 35 | 9,116 | 162 | There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X. | n = int(input())
if n == 1:
print(1)
elif n == 2:
print(2)
else:
for i in range(n):
if n <= i // 2 * (i + 1):
break
print(i)
| s675223336 | Accepted | 37 | 8,988 | 122 | n = int(input())
ans = 0
for i in range(1, n + 1):
if n <= i * (i + 1) // 2:
ans = i
break
print(ans)
|
s149844074 | p03730 | u463655976 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 142 | 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`. | def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a%b)
A, B, C = map(int, input().split())
print(["YES","NO"][gcd(A,B)<=C]) | s505237203 | Accepted | 17 | 2,940 | 152 | def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a%b)
A, B, C = map(int, input().split())
print(["NO","YES"][B>C and C%gcd(A,B)==0]) |
s912258658 | p02414 | u105694406 | 1,000 | 131,072 | Wrong Answer | 20 | 7,648 | 501 | Write a program which reads a $n \times m$ matrix $A$ and a $m \times l$ matrix $B$, and prints their product, a $n \times l$ matrix $C$. An element of matrix $C$ is obtained by the following formula: \\[ c_{ij} = \sum_{k=1}^m a_{ik}b_{kj} \\] where $a_{ij}$, $b_{ij}$ and $c_{ij}$ are elements of $A$, $B$ and $C$ respectively. | n, m, l = map(int, input().split())
nm = []
ml = []
for _ in range(n):
lista = list(map(int, input().split()))
nm.append(lista)
for _ in range(m):
lista = list(map(int, input().split()))
ml.append(lista)
matrix = []
print(nm)
print(ml)
for i in range(n):
lista = []
for j in range(l):
sum = 0
for k in range(m):
sum += nm[i][k]*ml[k][j]
lista.append(sum)
matrix.append(lista)
for i in range(n):
text = ""
for j in range(l):
text += str(matrix[i][j]) + " "
print(text[:-1]) | s917320683 | Accepted | 420 | 8,772 | 480 | n, m, l = map(int, input().split())
nm = []
ml = []
for _ in range(n):
lista = list(map(int, input().split()))
nm.append(lista)
for _ in range(m):
lista = list(map(int, input().split()))
ml.append(lista)
matrix = []
for i in range(n):
lista = []
for j in range(l):
sum = 0
for k in range(m):
sum += nm[i][k]*ml[k][j]
lista.append(sum)
matrix.append(lista)
for i in range(n):
text = ""
for j in range(l):
text += str(matrix[i][j]) + " "
print(text[:-1]) |
s904709330 | p02262 | u662418022 | 6,000 | 131,072 | Wrong Answer | 30 | 5,612 | 736 | Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m − 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$ | # -*- coding: utf-8 -*-
def insertionSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j -= g
cnt += 1
A[j+g] = v
def func(m):
if m == 0:
return 1
else:
return func(m-1)*3 + 1
def shellSort(A, n):
G = [func(i) for i in range(5)]
for g in G[::-1]:
insertionSort(A, n , g)
if __name__ == '__main__':
n = int(input())
A = [int(input()) for i in range(n)]
cnt = 0
shellSort(A, n)
print(5)
G = [func(i) for i in range(5)]
print(" ".join(map(str, G[::-1])))
print(cnt)
for i in range(n):
print(A[i])
| s813884557 | Accepted | 19,480 | 45,532 | 885 | # -*- coding: utf-8 -*-
def insertionSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j -= g
cnt += 1
A[j+g] = v
def shellSort(A, n):
def func(m):
if m == 0:
return 1
else:
return func(m-1)*3 + 1
G = []
i = 0
while True:
gi = func(i)
if gi <= n:
G.append(gi)
i += 1
else:
break
G = G[::-1]
for g in G:
insertionSort(A, n , g)
return A, G
if __name__ == '__main__':
n = int(input())
A = [int(input()) for i in range(n)]
cnt = 0
A, G = shellSort(A, n)
print(len(G))
print(" ".join(map(str, G)))
print(cnt)
for i in range(n):
print(A[i])
|
s297181983 | p04044 | u057308539 | 2,000 | 262,144 | Wrong Answer | 2,207 | 1,636,864 | 235 | Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m. | import itertools
N,L=map(int,input().split())
S=[]
S_list=[]
for i in range(N):
S.append(input())
list(itertools.permutations(S)).sort()
for i in list(itertools.permutations(S)):
S_list.append("".join(i))
print(list(S_list)[0]) | s830874713 | Accepted | 17 | 3,060 | 111 | N,L=map(int,input().split())
S=[]
S_list=[]
for i in range(N):
S.append(input())
S.sort()
print(''.join(S)) |
s728056532 | p03150 | u970308980 | 2,000 | 1,048,576 | Wrong Answer | 18 | 3,064 | 280 | A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string. | S = input().rstrip()
if S[:7] == 'keyence':
print('YES')
exit()
if S[-7:] == 'keyence':
print('YES')
exit()
for i in range(1, len(S)):
for j in range(i, len(S)):
if S[0:i]+S[j+1:] == 'keyence':
print('Yes')
exit()
print('No')
| s084679031 | Accepted | 18 | 3,060 | 280 | S = input().rstrip()
if S[:7] == 'keyence':
print('YES')
exit()
if S[-7:] == 'keyence':
print('YES')
exit()
for i in range(1, len(S)):
for j in range(i, len(S)):
if S[0:i]+S[j+1:] == 'keyence':
print('YES')
exit()
print('NO')
|
s133915117 | p02536 | u699522269 | 2,000 | 1,048,576 | Wrong Answer | 302 | 11,004 | 449 | There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: * Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal? | N,M = map(int,input().split())
par = [0]+[-1 for i in range(N)]
def find(x):
if par[x] == -1:
return x
else:
par[x] = find(par[x])
return par[x]
def same(x,y):
return find(x) == find(y)
def unite(x,y):
x = find(x)
y = find(y)
if x == y:
return 0
par[x] = y
for i in range(M):
a,b = map(int,input().split())
unite(a,b)
print(len([i for i in par if i == -1])) | s717557381 | Accepted | 302 | 11,004 | 451 | N,M = map(int,input().split())
par = [0]+[-1 for i in range(N)]
def find(x):
if par[x] == -1:
return x
else:
par[x] = find(par[x])
return par[x]
def same(x,y):
return find(x) == find(y)
def unite(x,y):
x = find(x)
y = find(y)
if x == y:
return 0
par[x] = y
for i in range(M):
a,b = map(int,input().split())
unite(a,b)
print(len([i for i in par if i == -1])-1) |
s013860853 | p03545 | u397496203 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 245 | 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. | l = list(input())
for i in range(1<<(len(l)-1)):
s = l[0]
for j in range(len(l)-1):
if (i>>j) & 1:
s += "+"
else:
s += "-"
s += l[j+1]
print(s)
if eval(s) == 7:
print(s+"=7")
quit()
print("wrong input.") | s272192570 | Accepted | 26 | 9,168 | 458 | S = input().strip()
for i in range(2**3):
ans = S[0]
_sum = int(S[0])
for j in range(3):
if (i>>j)&1:
ans += "+" + S[j+1]
_sum += int(S[j+1])
else:
ans += "-" + S[j+1]
_sum -= int(S[j+1])
if _sum == 7:
ans += "=7"
print(ans)
quit()
|
s036649813 | p03387 | u922416423 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 222 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | a,b,c = map(int, input().split())
A = [a,b,c]
A.sort()
if ((A[2]-A[1]%2==0) and (A[2]-A[0]%2==0)) or ((A[2]-A[1]%2==1) and (A[2]-A[0]%2==1)):
print(int(A[2]-(A[0]+A[1])/2))
else:
print(int(A[2]-(A[0]+A[1])/2+3/2)) | s730061958 | Accepted | 17 | 3,064 | 230 | a,b,c = map(int, input().split())
A = [a,b,c]
A.sort()
if (((A[2]-A[1])%2==0) and ((A[2]-A[0])%2==0)) or (((A[2]-A[1])%2==1) and ((A[2]-A[0])%2==1)):
print(int(A[2]-(A[0]+A[1])/2))
else:
print(int(A[2]-(A[0]+A[1])/2+3/2)) |
s443459990 | p03696 | u375616706 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 182 | You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of `(`, X and `)` in this order is also a correct bracket sequence. * If X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence. * Every correct bracket sequence can be derived from the rules above. Find the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one. | s = input()
l = len(s)
d_l = [0]*(l+1)
for i in range(1, l+1):
d = s[:i]
n_open = d.count('(')
d_l[i] = 2*n_open - i
x = min(d_l)
print('('*(-x) + s + ')'*(d_l[-1]-x))
| s350580612 | Accepted | 18 | 3,060 | 201 | n = (int)(input())
s = input()
l = len(s)
d_l = [0]*(l+1)
for i in range(1, l+1):
d = s[:i]
n_open = d.count('(')
d_l[i] = 2*n_open - i
x = min(d_l)
print('('*(-x) + s + ')'*(d_l[-1]-x))
|
s456955427 | p03501 | u970197315 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 50 | You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours. | n,b,a = map(int,input().split())
print(min(a*n,b)) | s909613043 | Accepted | 17 | 2,940 | 50 | n,a,b = map(int,input().split())
print(min(a*n,b)) |
s756457262 | p03469 | u633914031 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 58 | 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. | Sin=str(input())
Sout='2017/01/'+Sin[8]+Sin[9]
print(Sout) | s748237206 | Accepted | 17 | 2,940 | 58 | Sin=str(input())
Sout='2018/01/'+Sin[8]+Sin[9]
print(Sout) |
s111968184 | p02237 | u648595404 | 1,000 | 131,072 | Wrong Answer | 20 | 7,684 | 204 | 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())
for i in range(n):
node = list(map(int,input().split()))
node_list = node[2:]
matrix = [0] * n
for j in node_list:
matrix[j -1] = 1
print("".join(str(matrix))) | s552062559 | Accepted | 20 | 7,660 | 204 | n = int(input())
for i in range(n):
node = list(map(int,input().split()))
node_list = node[2:]
matrix = ["0"]* n
for j in node_list:
matrix[j -1] = "1"
print(" ".join(matrix)) |
s330429823 | p02853 | u667024514 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 201 | 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. | a,b = map(int,input().split())
ans = 0
if a == 1:ans += 300000
elif a == 2:ans += 200000
elif a == 2:ans += 100000
if b == 1:ans += 300000
elif b == 2:ans += 200000
elif b == 2:ans += 100000
print(ans) | s684803280 | Accepted | 17 | 3,064 | 232 | a,b = map(int,input().split())
ans = 0
if a == 1:ans += 300000
elif a == 2:ans += 200000
elif a == 3:ans += 100000
if b == 1:ans += 300000
elif b == 2:ans += 200000
elif b == 3:ans += 100000
if ans == 600000:ans += 400000
print(ans) |
s328317909 | p03338 | u973108807 | 2,000 | 1,048,576 | Wrong Answer | 24 | 2,940 | 124 | You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position. | n = int(input())
s = input()
ans = 0
for i in range(1,len(s)-1):
ans = max(ans, len(set(s[:i]) & set(s[i+1:])))
print(ans) | s547654194 | Accepted | 18 | 2,940 | 122 | n = int(input())
s = input()
ans = 0
for i in range(1,len(s)-1):
ans = max(ans, len(set(s[:i]) & set(s[i:])))
print(ans) |
s632654543 | p02399 | u910432023 | 1,000 | 131,072 | Wrong Answer | 20 | 7,632 | 54 | Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number) | a, b = map(int, input().split())
print(a//b, a%b, a/b) | s686279397 | Accepted | 20 | 7,632 | 72 | a, b = map(int, input().split())
print(a//b, a%b, "{0:.5f}".format(a/b)) |
s831679452 | p03636 | u730710086 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 99 | The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way. | # -*- coding: <encoding name> -*-
s = input()
S = 's[0]' + 'len(s - 2)' + 's[len(s) + 1]'
print(S) | s165227294 | Accepted | 17 | 2,940 | 90 | # -*- coding: <encoding name> -*-
s = input()
S = s[0] + str(len(s) - 2) + s[-1]
print(S) |
s078992441 | p03493 | u455533363 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 101 | Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble. | a= input()
count=0
if a[0]==1:
count+=1
if a[1]==1:
count+=1
if a[2]==1:
count+=1
print(count) | s712231529 | Accepted | 17 | 2,940 | 110 | a= input()
count=0
if a[0]=="1":
count+=1
if a[1]=="1":
count+=1
if a[2]=="1":
count+=1
print(count) |
s780918733 | p03407 | u591295155 | 2,000 | 262,144 | Wrong Answer | 19 | 2,940 | 68 | An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan. | A, B, C = map(int, input().split())
print(["NO", "YES"][A + B >= C]) | s298998574 | Accepted | 22 | 3,316 | 68 | A, B, C = map(int, input().split())
print(["No", "Yes"][A + B >= C]) |
s522906083 | p02415 | u966110132 | 1,000 | 131,072 | Wrong Answer | 20 | 5,452 | 1 | Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string. | s463690919 | Accepted | 20 | 5,548 | 46 | str = input()
str = str.swapcase()
print(str)
|
|
s163535612 | p03672 | u444856278 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 140 | We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input. | s = list(input())
while True:
s.pop()
s.pop()
if s[:len(s)//2] == s[len(s)//2+1:]:
print(len(s))
break
| s862684676 | Accepted | 17 | 2,940 | 138 | s = list(input())
while True:
s.pop()
s.pop()
if s[:len(s)//2] == s[len(s)//2:]:
print(len(s))
break
|
s373236404 | p02401 | u650790815 | 1,000 | 131,072 | Wrong Answer | 20 | 7,348 | 50 | 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. | data = input()
print(eval(data.replace('/','//'))) | s987702779 | Accepted | 30 | 7,428 | 101 | while 1:
data = input()
if '?' in data:
break
print(eval(data.replace('/','//'))) |
s079847124 | p03761 | u466105944 | 2,000 | 262,144 | Wrong Answer | 19 | 3,064 | 429 | Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains. Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains. If there are multiple such strings, find the lexicographically smallest one among them. | n = int(input())
cnt_dict = []
for _ in range(n):
input_str = input()
chr_dict = {chr(i):0 for i in range(97,97+26)}
for s in input_str:
chr_dict[s] += 1
cnt_dict.append(chr_dict)
common = {chr(i):100 for i in range(97,97+26)}
for c in cnt_dict:
for k,v in c.items():
common[k] = min(common[k],v)
result = ''
for k,v in sorted(common.items()):
print(k,v)
result += k*v
print(result)
| s497655383 | Accepted | 20 | 3,064 | 414 | n = int(input())
dict_lst = []
for _ in range(n):
input_str = input()
chr_dict = {chr(i):0 for i in range(97,97+26)}
for s in input_str:
chr_dict[s] += 1
dict_lst.append(chr_dict)
ans_dict = {chr(i):100 for i in range(97,97+26)}
for d in dict_lst:
for k,v in d.items():
ans_dict[k] = min(ans_dict[k],v)
ans = ''
for k,v in sorted(ans_dict.items()):
ans += k*v
print(ans)
|
s520896816 | p02612 | u645568816 | 2,000 | 1,048,576 | Wrong Answer | 27 | 9,104 | 86 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | import math
N = int(input())
A = (math.floor(N/1000))
B=N- A*1000
print(B)
| s069879117 | Accepted | 27 | 9,016 | 74 | import math
N = int(input())
A = (math.ceil(N/1000))
B=A*1000 - N
print(B) |
s851666812 | p03909 | u091051505 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 192 | There is a grid with H rows and W columns. The square at the i-th row and j-th column contains a string S_{i,j} of length 5. The rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `A` through the W-th letter of the alphabet. Exactly one of the squares in the grid contains the string `snuke`. Find this square and report its location. For example, the square at the 6-th row and 8-th column should be reported as `H6`. | a, b = map(int, input().split())
A = 'ABCDEFGHIJKLMN'
ans = ""
for i in range(a):
t = list(input().split())
if 'snuke' in t:
ans += A[i]
ans += str(t.index("snuke") + 1)
print(ans) | s031273203 | Accepted | 17 | 2,940 | 204 | a, b = map(int, input().split())
A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ans = ""
for i in range(a):
t = list(input().split())
if 'snuke' in t:
ans += A[t.index("snuke")]
ans += str(i + 1)
print(ans) |
s333397864 | p02608 | u664884522 | 2,000 | 1,048,576 | Wrong Answer | 2,206 | 9,088 | 247 | 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())
a = [0 for x in range(N)]
for i in range(1,N+1):
for j in range(1,N+1):
for k in range(1,N+1):
n = i*i+j*j+k*k+i*j+j*k+i*k
if n < N:
a[n] += 1
for i in range(N):
print(a[i])
| s594902922 | Accepted | 444 | 9,384 | 260 | N = int(input())
a = [0 for x in range(N)]
L = int(N**0.5)
for i in range(1,L):
for j in range(1,L):
for k in range(1,L):
n = i*i+j*j+k*k+i*j+j*k+i*k
if n <= N:
a[n-1] += 1
for i in range(N):
print(a[i])
|
s423661503 | p03160 | u063703408 | 2,000 | 1,048,576 | Wrong Answer | 128 | 14,664 | 227 | There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. | n = int(input())
h = list(map(int,input().split()))
dp = [10**4] * (n+1)
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]))
print(dp)
print(dp[n-1]) | s037997322 | Accepted | 127 | 13,796 | 229 | n = int(input())
h = list(map(int,input().split()))
dp = [10**4] * (n+1)
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]))
# print(dp)
print(dp[n-1]) |
s034206726 | p03598 | u331997680 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 137 | There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N. When activated, each type of robot will operate as follows. * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots. | N = int(input())
K = int(input())
X = list(map(int, input().split()))
Z = 0
for i in range(N):
Z += max(X[i]*2, abs(K-X[i])*2)
print(Z) | s122688287 | Accepted | 17 | 2,940 | 138 | N = int(input())
K = int(input())
X = list(map(int, input().split()))
Z = 0
for i in range(N):
Z += min(X[i]*2, abs(K-X[i])*2)
print(Z)
|
s468549768 | p03068 | u478266845 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 188 | You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`. |
N = int(input())
S = str(input())
K =int(input())
K_char = S[K-1]
ans = ''
for i in S:
if i != K_char:
ans += i
elif i == K_char:
ans += '*'
print(ans) | s539799235 | Accepted | 17 | 3,064 | 188 |
N = int(input())
S = str(input())
K =int(input())
K_char = S[K-1]
ans = ''
for i in S:
if i == K_char:
ans += i
elif i != K_char:
ans += '*'
print(ans) |
s456181734 | p02694 | u218757284 | 2,000 | 1,048,576 | Wrong Answer | 21 | 9,092 | 87 | Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time? | x = int(input())
y = 0
v = 100
while v <= x:
v = int(v * 1.01)
y = y + 1
print(y) | s906436652 | Accepted | 24 | 9,160 | 88 | x = int(input())
y = 0
v = 100
while v < x:
v = int(v * 1.01)
y = y + 1
print(y) |
s538202570 | p02407 | u589139267 | 1,000 | 131,072 | Wrong Answer | 20 | 5,584 | 179 | Write a program which reads a sequence and prints it in the reverse order. | n = int(input())
x = list(map(int, input().split()))
offset = x
for i in range(1, n+1):
if i < n:
print("offset[-i]", end=" ")
else:
print("offset[-i]", end="")
| s801467076 | Accepted | 20 | 5,592 | 198 | n = int(input())
ori = list(map(str, input().split(" ")))
rev = list(reversed(ori))
ans = ""
for i in range(n):
if i != n-1:
ans += (rev[i]) + " "
else:
ans += (rev[i])
print(ans)
|
s954091091 | p03161 | u597455618 | 2,000 | 1,048,576 | Wrong Answer | 2,108 | 22,848 | 339 | There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to one of the following: Stone i + 1, i + 2, \ldots, i + K. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. | import sys
import numpy as np
n, k = map(int, input().split())
h = list(map(int, sys.stdin.readline().split()))
h = np.array(h, dtype=np.int)
ans = np.full(n, 10**4, dtype=np.int)
ans[0] = 0
for i in range(n):
for j in range(1, k+1):
if i+j < n:
ans[i+j] = min(ans[i+j], abs(h[i] - h[i+j]) + ans[i])
print(ans[-1]) | s373109728 | Accepted | 1,386 | 22,852 | 401 | def main():
import sys
import numpy as np
n, k = map(int, input().split())
h = list(map(int, sys.stdin.readline().split()))
h = np.array(h, dtype=np.int32)
ans = np.array([10**9] * n, dtype=np.int32)
ans[0] = 0
for i in range(n):
ans[i:i+k+1] = np.minimum(ans[i:i+k+1], ans[i]+np.abs(h[i:i+k+1]-h[i]))
print(ans[n-1])
if __name__ == '__main__':
main() |
s744041333 | p03761 | u440975163 | 2,000 | 262,144 | Wrong Answer | 32 | 9,344 | 366 | Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains. Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains. If there are multiple such strings, find the lexicographically smallest one among them. | n = int(input())
p = [list(str(input())) for _ in range(n)]
from collections import Counter
ln = []
for i in p:
ln.append(Counter(i))
dic = ln[0]
for i in ln:
for key in i:
if key in dic and dic[key] > i[key]:
dic[key] = i[key]
ans = []
for key in dic:
for j in range(dic[key]):
ans.append(key)
ans.sort()
print(''.join(ans)) | s951405152 | Accepted | 29 | 9,420 | 307 | import collections
n = int(input())
S = []
for i in range(n):
s = collections.Counter(input())
S.append(s)
ans = ''
for key in S[0].keys():
cnt = S[0][key]
for i in range(1,n):
cnt = min(cnt,S[i][key])
for i in range(cnt):
ans += key
ans = sorted(ans)
print(''.join(ans)) |
s363352402 | p04011 | u604412462 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 127 | 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. | N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N <= K:
print(X*N)
else:
print(X*N + (N - K)*Y) | s667111069 | Accepted | 20 | 2,940 | 127 | N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N <= K:
print(X*N)
else:
print(X*K + (N - K)*Y) |
s713376538 | p02258 | u072053884 | 1,000 | 131,072 | Wrong Answer | 20 | 7,536 | 306 | You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen. Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ . | n = input()
n = int(n)
price_list = []
x = input()
x = int(x)
price_list.append(x)
max_profit_candidate = x - 10**9
for i in range(n - 1):
x = input()
x = int(x)
diff = x - min(price_list)
if diff > max_profit_candidate:
max_profit_candidate = diff
print(max_profit_candidate) | s692145775 | Accepted | 470 | 7,624 | 351 | n = input()
n = int(n)
x = input()
x = int(x)
present_min_value = x
max_profit_candidate = 1 - 10**9
for i in range(n - 1):
a = input()
a = int(a)
diff = a - present_min_value
if diff > max_profit_candidate:
max_profit_candidate = diff
if a < present_min_value:
present_min_value = a
print(max_profit_candidate) |
s118830812 | p04011 | u121732701 | 2,000 | 262,144 | Wrong Answer | 20 | 2,940 | 171 | 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. | N = int(input())
K = int(input())
X = int(input())
Y = int(input())
sum1 = 0
for i in range(N):
if K>=N+1:
sum1 += X
else:
sum1 += Y
print(sum1) | s417305635 | Accepted | 19 | 3,064 | 174 | N = int(input())
K = int(input())
X = int(input())
Y = int(input())
sum1 = 0
for i in range(N):
if K>=i+1:
sum1 += X
else:
sum1 += Y
print(sum1) |
s662822235 | p03737 | u858436319 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 64 | You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. | S1, S2, S3 = map(str, input().split())
print(S1[0]+S2[0]+S3[0]) | s113941262 | Accepted | 17 | 2,940 | 75 | S1, S2, S3 = map(str, input().split())
print(str.upper(S1[0]+S2[0]+S3[0])) |
s948206455 | p03385 | u156383602 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 69 | You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. | a=sorted(input())
if a=="abc":
print("Yes")
else:
print("No") | s343536170 | Accepted | 17 | 2,940 | 83 | a=sorted(list(input()))
if a==["a","b","c"]:
print("Yes")
else:
print("No") |
s448315100 | p00101 | u546285759 | 1,000 | 131,072 | Wrong Answer | 30 | 7,480 | 253 | An English booklet has been created for publicizing Aizu to the world. When you read it carefully, you found a misnomer (an error in writing) on the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet says "Hoshino" not "Hoshina". Your task is to write a program which replace all the words "Hoshino" with "Hoshina". You can assume that the number of characters in a text is less than or equal to 1000. | N = int(input())
ans = ""
for i in range(N):
inp = list(map(str, input().split()))
tmp = ""
for j in range(len(inp)):
if inp[j] == "Hoshino":
inp[j] = "Hoshina"
tmp += inp[j] + " "
ans += tmp + "\n"
print(ans) | s805370628 | Accepted | 20 | 5,604 | 112 | n = int(input())
dataset = [input().replace("Hoshino", "Hoshina") for _ in range(n)]
print(*dataset, sep="\n")
|
s474219839 | p03672 | u619819312 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 135 | We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input. | n=input()
c=0
for i in range(len(n)):
p=n[:len(n)-i]
if p[:len(p)//2]==p[len(p)//2:]:
c=len(n)-i
break
print(c) | s461442139 | Accepted | 18 | 2,940 | 137 | n=input()
c=0
for i in range(1,len(n)):
p=n[:len(n)-i]
if p[:len(p)//2]==p[len(p)//2:]:
c=len(n)-i
break
print(c) |
s709775131 | p03545 | u707124227 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 461 | 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. | a,b,c,d=map(int,list(input()))
n=3
ans=''
for i in range(n**2):
op=[]
for j in range(n):
if (i>>j & 1):
op.append(True)
else:
op.append(False)
tmp=a
tmp=tmp+b if op[0] else tmp-b
tmp=tmp+c if op[1] else tmp-c
tmp=tmp+d if op[2] else tmp-d
if tmp==7:
ans=str(a)
ans+='+' if op[0] else '-'
ans+=str(b)
ans+='+' if op[1] else '-'
ans+=str(c)
ans+='+' if op[2] else '-'
ans+=str(d)
break
print(ans)
| s602736284 | Accepted | 17 | 3,064 | 466 | a,b,c,d=map(int,list(input()))
n=3
ans=''
for i in range(n**2):
op=[]
for j in range(n):
if (i>>j & 1):
op.append(True)
else:
op.append(False)
tmp=a
tmp=tmp+b if op[0] else tmp-b
tmp=tmp+c if op[1] else tmp-c
tmp=tmp+d if op[2] else tmp-d
if tmp==7:
ans=str(a)
ans+='+' if op[0] else '-'
ans+=str(b)
ans+='+' if op[1] else '-'
ans+=str(c)
ans+='+' if op[2] else '-'
ans+=str(d)
break
print(ans+'=7')
|
s889163017 | p03796 | u143903328 | 2,000 | 262,144 | Wrong Answer | 31 | 2,940 | 102 | Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7. | N = int(input())
ans = 1
for i in range(1, N+1):
ans = ans * i
ans = ans // 1000000007
print(ans) | s245012011 | Accepted | 42 | 2,940 | 102 | N = int(input())
ans = 1
for i in range(1, N+1):
ans = ans * i
ans = ans % 1000000007
print(ans) |
s730660775 | p03474 | u727787724 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 426 | The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom. | # coding: utf-8
# Your code here!
a,b=map(int,input().split())
S=list(input())
ans='Yes'
for i in range(a+b):
if i==a:
if S[i]!='-':
ans='No'
break
else:
continue
if S[i]=='0'or S[i]=='1' or S[i]=='2'or S[i]=='3' or S[i]=='4'or S[i]=='5' or S[i]=='6'or S[i]=='7' or S[i]=='8'or S[i]=='9':
continue
else:
ans='No'
break
print(ans)
print(S) | s400921977 | Accepted | 17 | 3,064 | 427 | # coding: utf-8
# Your code here!
a,b=map(int,input().split())
S=list(input())
ans='Yes'
for i in range(a+b):
if i==a:
if S[i]!='-':
ans='No'
break
else:
continue
if S[i]=='0'or S[i]=='1' or S[i]=='2'or S[i]=='3' or S[i]=='4'or S[i]=='5' or S[i]=='6'or S[i]=='7' or S[i]=='8'or S[i]=='9':
continue
else:
ans='No'
break
print(ans)
#print(S) |
s927661745 | p03845 | u023229441 | 2,000 | 262,144 | Wrong Answer | 19 | 3,064 | 139 | 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())
A=list(map(int,input().split()))
m=int(input())
for i in range(m):
a,b=map(int,input().split())
A[a-1]=b
print(sum(A)) | s025410083 | Accepted | 18 | 2,940 | 142 | n=int(input())
A=list(map(int,input().split()))
B=A
m=int(input())
for i in range(m):
a,b=map(int,input().split())
print(sum(A)-A[a-1]+b)
|
s746712693 | p02409 | u775586391 | 1,000 | 131,072 | Wrong Answer | 30 | 7,632 | 267 | You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building. | l = [[[0 for z in range(10)] for y in range(3)] for x in range(4)]
n = int(input())
while n > 0:
b,f,r,v = map(int,input().split())
l[b-1][f-1][r-1] += v
n -= 1
for b in l:
for f in b:
r_l = [str(r) for r in f]
print(' '+' '.join(r_l))
print('#'*20) | s836321956 | Accepted | 20 | 7,748 | 303 | l = [[[0 for z in range(10)] for y in range(3)] for x in range(4)]
n = int(input())
while n > 0:
b,f,r,v = map(int,input().split())
l[b-1][f-1][r-1] += v
n -= 1
c = 0
for b in l:
c += 1
for f in b:
r_l = [str(r) for r in f]
print(' '+' '.join(r_l))
if c < len(l):
print('#'*20) |
s449236453 | p03129 | u404561212 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 189 | Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1. | N, K = list(map(int, input().split()))
if N%2==0:
if N/2>=K:
print("Yes")
else:
print("No")
else:
if N/2+1>=K:
print("Yes")
else:
print("No") | s871899883 | Accepted | 19 | 3,060 | 176 | N, K = list(map(int, input().split()))
num = 0
for n in range(1,N+1):
if n%2!=0:
num += 1
if num<K:
print("NO")
else:
print("YES") |
s983266147 | p03385 | u371763408 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 79 | You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. | s = sorted("".join(input()))
if s == 'abc':
print('Yes')
else:
print('No') | s846501250 | Accepted | 17 | 2,940 | 85 | s = input()
if ''.join(sorted(list(s))) == 'abc':
print('Yes')
else:
print('No') |
s599221765 | p03478 | u754022296 | 2,000 | 262,144 | Wrong Answer | 34 | 3,060 | 165 | Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). | n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
c = 0
s = str(i)
for j in s:
c += int(j)
if a <= c <= b:
ans += 1
print(ans) | s909332232 | Accepted | 28 | 3,060 | 168 | n, a, b = map(int, input().split())
ans = 0
for i in range(n):
t = i+1
cnt = 0
while t:
cnt += t%10
t //= 10
if a <= cnt <= b:
ans += i+1
print(ans) |
s361182994 | p03643 | u185806788 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 31 | This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer. | N=str(input())
print("ABC"+"N") | s275519224 | Accepted | 19 | 3,060 | 24 | N=input()
print("ABC"+N) |
s520076701 | p03854 | u379716238 | 2,000 | 262,144 | Wrong Answer | 1,152 | 3,572 | 401 | 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()
s = s[::-1]
Word = ["dream","dreamer","erase","eraser"]
m = ""
for i in s:
m += i
for i in range(len(Word)):
Word[i] = Word[i][::-1]
print(s,m)
can = False
for i in range(len(s)+1):
for j in Word:
if j in s[:i]:
can = True
i = i + len(j)
if can == True:
print("YES")
else:
print("NO")
| s471291863 | Accepted | 71 | 3,188 | 482 |
def main():
S = input()
while len(S) >= 5:
if len(S) >= 7 and S[-7:] == "dreamer":
S = S[:-7]
continue
if len(S) >= 6 and S[-6:] == "eraser":
S = S[:-6]
continue
elif S[-5:] == "dream" or S[-5:] == "erase":
S = S[:-5]
continue
else:
break
if len(S) == 0:
print("YES")
else:
print("NO")
main() |
s656867134 | p00002 | u144068724 | 1,000 | 131,072 | Wrong Answer | 20 | 7,480 | 137 | Write a program which computes the digit number of sum of two integers a and b. | # coding: utf-8
# Here your code !
while 1:
try:
a,b = map(int,input().split())
print(a+b)
except:
break | s221118145 | Accepted | 20 | 7,524 | 163 | # coding: utf-8
# Here your code !
while 1:
try:
a,b = map(int,input().split())
su = a+b
print(len(str(su)))
except:
break |
s100394717 | p03777 | u328755070 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 126 | Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or Dishonest_. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either `H` or `D`, and carries the following information: If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`, AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that TopCoDeer is dishonest. Given this information, determine whether TopCoDeer is honest. | a, b = input().split()
a = 1 if a == 'H' else -1
b = 1 if a == 'H' else -1
if a * b == 1:
print('H')
else:
print('D')
| s863708268 | Accepted | 17 | 2,940 | 126 | a, b = input().split()
a = 1 if a == 'H' else -1
b = 1 if b == 'H' else -1
if a * b == 1:
print('H')
else:
print('D')
|
s824052319 | p02613 | u657786757 | 2,000 | 1,048,576 | Wrong Answer | 72 | 16,856 | 588 | Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. | import sys
import math
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache
def main():
n = int(input())
s = [input() for _ in range(n)]
print('AC × {:}'.format(s.count('AC')))
print('WA × {:}'.format(s.count('WA')))
print('TLE × {:}'.format(s.count('TLE')))
print('RE × {:}'.format(s.count('RE')))
return 0
if __name__ == "__main__":
main() | s229314389 | Accepted | 69 | 16,860 | 584 | import sys
import math
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache
def main():
n = int(input())
s = [input() for _ in range(n)]
print('AC x {:}'.format(s.count('AC')))
print('WA x {:}'.format(s.count('WA')))
print('TLE x {:}'.format(s.count('TLE')))
print('RE x {:}'.format(s.count('RE')))
return 0
if __name__ == "__main__":
main() |
s300265373 | p03693 | u602863587 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 90 | AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4? | r,g,b=map(int,input().split())
if 10*g+b % 4 == 0:
print("YES")
else:
print("NO") | s976425721 | Accepted | 17 | 2,940 | 90 | r,g,b=map(int,input().split())
if ((10*g)+b) % 4 == 0:
print('YES')
else:
print('NO') |
s793291800 | p02678 | u822662438 | 2,000 | 1,048,576 | Wrong Answer | 2,207 | 51,040 | 888 | 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. | n , m = map(int, input().split())
root = []
for i in range(m):
root.append(list(map(int, input().split())))
#room_li = list(range(1,n+1))
answer_li = [0]*n
now_li = [1]
next_now = []
delete_li = []
while True:
for n in now_li:
for i, r in enumerate(root):
if n in r:
#root.pop(i)
delete_li.append(i)
r.remove(n)
dest = r[0]
if answer_li[dest-1] == 0:
answer_li[dest-1] = n
next_now.append(dest)
cnt = 0
for d in delete_li:
root.pop(d-cnt)
cnt += 1
delete_li = []
now_li = next_now
next_now = []
if len(root) <=1:
break
answer_li = answer_li[1:]
print(answer_li)
if 0 not in answer_li:
print('Yes')
for i in answer_li:
print(i)
else:
print('No')
| s380477431 | Accepted | 1,141 | 34,168 | 524 | import sys
input = sys.stdin.readline
n , m = map(int, input().split())
root = [[] for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
root[a-1].append(b)
root[b-1].append(a)
kakutei = [1]
answer_li = [0]*n
while kakutei:
k = kakutei.pop(0)
for r in root[k-1]:
if answer_li[r-1] == 0:
kakutei.append(r)
answer_li[r-1] = k
answer_li = answer_li[1:]
if 0 in answer_li:
print('No')
else:
print('Yes')
for i in answer_li:
print(i)
|
s467678461 | p03719 | u558528117 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 277 | You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. | import sys
def main():
line = sys.stdin.readline()
lst = line.split()
a = int(lst[0])
b = int(lst[1])
c = int(lst[2])
if a <= c and c <=b:
print("YES")
else:
print("NO")
return 0
if __name__ == '__main__':
sys.exit(main())
| s807335143 | Accepted | 17 | 3,060 | 277 | import sys
def main():
line = sys.stdin.readline()
lst = line.split()
a = int(lst[0])
b = int(lst[1])
c = int(lst[2])
if a <= c and c <=b:
print("Yes")
else:
print("No")
return 0
if __name__ == '__main__':
sys.exit(main())
|
s771842583 | p03861 | u037221289 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 53 | You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x? | A,B,X = map(int,input().split(' '))
print((B-A) // X) | s226260351 | Accepted | 18 | 2,940 | 57 | a,b,x = map(int,input().split())
print(b//x-((a-1)//x))
|
s648737329 | p03555 | u226108478 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 309 | You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise. | # -*- coding: utf-8 -*-
if __name__ == '__main__':
c = [list(map(str, list((input().split())))) for _ in range(2)]
if (c[0][0][0] == c[1][0][2]) and (c[1][0][0] == c[0][0][2]) and (c[0][0][1] == c[1][0][1]):
print('Yes')
else:
print('No')
| s013263197 | Accepted | 17 | 2,940 | 259 | # -*- coding: utf-8 -*-
if __name__ == '__main__':
c = [input() for _ in range(2)]
if (c[0][0] == c[1][2]) and (c[1][0] == c[0][2]) and (c[0][1] == c[1][1]):
print('YES')
else:
print('NO')
|
s161435471 | p03090 | u945181840 | 2,000 | 1,048,576 | Wrong Answer | 24 | 3,612 | 178 | 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())
if N % 2:
s = N
else:
s = 1 + N
for i in range(1, N):
for j in range(i + 1, N + 1):
if i + j == s:
continue
print(i, j) | s008246818 | Accepted | 30 | 4,100 | 470 | from operator import mul
from functools import reduce
def cmb(n, r):
r = min(n - r, r)
if r == 0:
return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1, r + 1))
return over // under
N = int(input())
if N % 2:
s = N
print(cmb(N - 1, 2) - N // 2 + N - 1)
else:
s = 1 + N
print(cmb(N, 2) - N // 2)
for i in range(1, N):
for j in range(i + 1, N + 1):
if i + j != s:
print(i, j) |
s624785006 | p03658 | u821432765 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 105 | Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy. | N, K = [int(i) for i in input().split()]
l = sorted([int(i) for i in input().split()])
print(sum(l[:K]))
| s547350131 | Accepted | 17 | 2,940 | 119 | N, K = [int(i) for i in input().split()]
l = sorted([int(i) for i in input().split()], reverse=True)
print(sum(l[:K]))
|
s196664843 | p04011 | u244836567 | 2,000 | 262,144 | Wrong Answer | 25 | 9,020 | 85 | 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())
print(int((c*a)+d*(b-a))) | s902188481 | Accepted | 29 | 9,120 | 120 | a=int(input())
b=int(input())
c=int(input())
d=int(input())
if a>=b:
print(int((c*b+d*(a-b))))
else:
print(int(c*a)) |
s300394265 | p03494 | u972652761 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 315 | 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 = int(input())
a_list = []
a_list = list(map(int,input().split()))
counter = 0
while True:
i = 0
for w in a_list:
a_list[i] = w / 2
if a_list[i] % 2 == 1:
break
else :
i += 1
if len(a_list) != i + 1:
break
counter += 1
print(counter)
| s372175234 | Accepted | 20 | 2,940 | 322 | N = int(input())
a_list = list(map(int,input().split()))
counter = 0
i = 0
while True:
i = 0
for w in a_list:
if a_list[i] % 2 == 1:
break
else :
a_list[i] = w / 2
i += 1
if N != i:
break
else:
counter += 1
print(counter)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.