output_description
stringlengths
15
956
submission_id
stringlengths
10
10
status
stringclasses
3 values
problem_id
stringlengths
6
6
input_description
stringlengths
9
2.55k
attempt
stringlengths
1
13.7k
problem_description
stringlengths
7
5.24k
samples
stringlengths
2
2.72k
Print the maximum possible score. * * *
s193231432
Accepted
p03839
The input is given from Standard Input in the following format: N K a_1 a_2 ... a_N
import sys import heapq from operator import itemgetter from collections import deque, defaultdict from bisect import bisect_left, bisect_right input = sys.stdin.readline sys.setrecursionlimit(10**7) def sol(): N, K = map(int, input().split()) A = list(map(int, input().split())) sumPlus = [0] * (N + 1) sumA = [0] * (N + 1) for i, a in enumerate(A): sumA[i + 1] = sumA[i] + a if a > 0: sumPlus[i + 1] = sumPlus[i] + a else: sumPlus[i + 1] = sumPlus[i] ans = 0 for left in range(N - K + 1): # []left - left + K) を捨てる or 加える leftSum = sumPlus[left] rightSum = sumPlus[N] - sumPlus[left + K] midSum = sumA[left + K] - sumA[left] if midSum > 0: ans = max(ans, leftSum + rightSum + midSum) else: ans = max(ans, leftSum + rightSum) print(ans) sol()
Statement There are N squares aligned in a row. The i-th square from the left contains an integer a_i. Initially, all the squares are white. Snuke will perform the following operation some number of times: * Select K consecutive squares. Then, paint all of them white, or paint all of them black. Here, the colors of the squares are overwritten. After Snuke finishes performing the operation, the score will be calculated as the sum of the integers contained in the black squares. Find the maximum possible score.
[{"input": "5 3\n -10 10 -10 10 -10", "output": "10\n \n\nPaint the following squares black: the second, third and fourth squares from\nthe left.\n\n* * *"}, {"input": "4 2\n 10 -10 -10 10", "output": "20\n \n\nOne possible way to obtain the maximum score is as follows:\n\n * Paint the following squares black: the first and second squares from the left.\n * Paint the following squares black: the third and fourth squares from the left.\n * Paint the following squares white: the second and third squares from the left.\n\n* * *"}, {"input": "1 1\n -10", "output": "0\n \n\n* * *"}, {"input": "10 5\n 5 -4 -5 -8 -4 7 2 -4 0 7", "output": "17"}]
Print the maximum possible score. * * *
s934750764
Accepted
p03839
The input is given from Standard Input in the following format: N K a_1 a_2 ... a_N
N, K = [int(_) for _ in input().split()] A = [int(_) for _ in input().split()] w = sum(x for x in A[K:] if x > 0) b = sum(A[:K]) + w result = max(w, b) for i in range(N - K): j = i + K Ai = A[i] Aj = A[j] if Ai > 0: w += Ai if Ai < 0: b -= Ai if Aj > 0: w -= Aj if Aj < 0: b += Aj result = max(result, w, b) print(result)
Statement There are N squares aligned in a row. The i-th square from the left contains an integer a_i. Initially, all the squares are white. Snuke will perform the following operation some number of times: * Select K consecutive squares. Then, paint all of them white, or paint all of them black. Here, the colors of the squares are overwritten. After Snuke finishes performing the operation, the score will be calculated as the sum of the integers contained in the black squares. Find the maximum possible score.
[{"input": "5 3\n -10 10 -10 10 -10", "output": "10\n \n\nPaint the following squares black: the second, third and fourth squares from\nthe left.\n\n* * *"}, {"input": "4 2\n 10 -10 -10 10", "output": "20\n \n\nOne possible way to obtain the maximum score is as follows:\n\n * Paint the following squares black: the first and second squares from the left.\n * Paint the following squares black: the third and fourth squares from the left.\n * Paint the following squares white: the second and third squares from the left.\n\n* * *"}, {"input": "1 1\n -10", "output": "0\n \n\n* * *"}, {"input": "10 5\n 5 -4 -5 -8 -4 7 2 -4 0 7", "output": "17"}]
Print the maximum possible score. * * *
s433479080
Runtime Error
p03839
The input is given from Standard Input in the following format: N K a_1 a_2 ... a_N
N, K = map(int, input().split()) a = list(map(int, input().split())) sa = [0] sb = [0] for i in range(N): sa.append(sa[-1] + a[i]) sb.append(sb[-1] + max(0, a[i])) ans = 0 for i in range(N - K + 1): a = sa[i + K] - sa[i] b = sb[i + K] - sb[i] ans = max(ans, sb[N] - b + max(a, 0)) print(ans)
Statement There are N squares aligned in a row. The i-th square from the left contains an integer a_i. Initially, all the squares are white. Snuke will perform the following operation some number of times: * Select K consecutive squares. Then, paint all of them white, or paint all of them black. Here, the colors of the squares are overwritten. After Snuke finishes performing the operation, the score will be calculated as the sum of the integers contained in the black squares. Find the maximum possible score.
[{"input": "5 3\n -10 10 -10 10 -10", "output": "10\n \n\nPaint the following squares black: the second, third and fourth squares from\nthe left.\n\n* * *"}, {"input": "4 2\n 10 -10 -10 10", "output": "20\n \n\nOne possible way to obtain the maximum score is as follows:\n\n * Paint the following squares black: the first and second squares from the left.\n * Paint the following squares black: the third and fourth squares from the left.\n * Paint the following squares white: the second and third squares from the left.\n\n* * *"}, {"input": "1 1\n -10", "output": "0\n \n\n* * *"}, {"input": "10 5\n 5 -4 -5 -8 -4 7 2 -4 0 7", "output": "17"}]
Print the maximum possible score. * * *
s176894516
Accepted
p03839
The input is given from Standard Input in the following format: N K a_1 a_2 ... a_N
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) import numpy as np # どこかの長さKは最後に単色で残る # そこを残すと決めると他は自由に設定できる N, K = map(int, input().split()) A = np.array(input().split(), dtype=np.int64) Acum = A.cumsum() range_sum = Acum[K - 1 :] - Acum[: N - (K - 1)] + A[: N - (K - 1)] # 各地点を左端として、長さKの区間の合計を求める Acum = A.cumsum() range_sum = Acum[K - 1 :] - Acum[: N - (K - 1)] + A[: N - (K - 1)] best = np.maximum(A, 0) best_cum = best.cumsum() best_range_sum = best_cum[K - 1 :] - best_cum[: N - (K - 1)] + best[: N - (K - 1)] min_loss = (best_range_sum - np.maximum(range_sum, 0)).min() answer = best.sum() - min_loss print(answer)
Statement There are N squares aligned in a row. The i-th square from the left contains an integer a_i. Initially, all the squares are white. Snuke will perform the following operation some number of times: * Select K consecutive squares. Then, paint all of them white, or paint all of them black. Here, the colors of the squares are overwritten. After Snuke finishes performing the operation, the score will be calculated as the sum of the integers contained in the black squares. Find the maximum possible score.
[{"input": "5 3\n -10 10 -10 10 -10", "output": "10\n \n\nPaint the following squares black: the second, third and fourth squares from\nthe left.\n\n* * *"}, {"input": "4 2\n 10 -10 -10 10", "output": "20\n \n\nOne possible way to obtain the maximum score is as follows:\n\n * Paint the following squares black: the first and second squares from the left.\n * Paint the following squares black: the third and fourth squares from the left.\n * Paint the following squares white: the second and third squares from the left.\n\n* * *"}, {"input": "1 1\n -10", "output": "0\n \n\n* * *"}, {"input": "10 5\n 5 -4 -5 -8 -4 7 2 -4 0 7", "output": "17"}]
Print the maximum possible score. * * *
s066659236
Wrong Answer
p03839
The input is given from Standard Input in the following format: N K a_1 a_2 ... a_N
N, K = list(map(int, input().split(" "))) As = list(map(int, input().split(" "))) left = max_left = 0 right = max_right = K temp = ma = sum(As[0:right]) anss = [0] for i in range(N - K): # K 個を黒で塗る left += 1 right += 1 temp = temp - As[left - 1] + As[right - 1] if ma < temp: max_left = left max_right = right ma = temp for i in range(N): if not (max_left <= i <= max_right): if As[i] > 0: ma += As[i] anss.append(ma) left = min_left = 0 right = min_right = K temp = mi = sum(As[0:right]) for i in range(N - K - 1): # K 個を白で塗る left += 1 right += 1 temp = mi - As[left - 1] + As[right - 1] if mi > temp: max_left = left max_right = right mi = temp temp = 0 for i in range(N): if not (max_left <= i <= max_right): if As[i] > 0: temp += As[i] anss.append(ma) print(max(anss))
Statement There are N squares aligned in a row. The i-th square from the left contains an integer a_i. Initially, all the squares are white. Snuke will perform the following operation some number of times: * Select K consecutive squares. Then, paint all of them white, or paint all of them black. Here, the colors of the squares are overwritten. After Snuke finishes performing the operation, the score will be calculated as the sum of the integers contained in the black squares. Find the maximum possible score.
[{"input": "5 3\n -10 10 -10 10 -10", "output": "10\n \n\nPaint the following squares black: the second, third and fourth squares from\nthe left.\n\n* * *"}, {"input": "4 2\n 10 -10 -10 10", "output": "20\n \n\nOne possible way to obtain the maximum score is as follows:\n\n * Paint the following squares black: the first and second squares from the left.\n * Paint the following squares black: the third and fourth squares from the left.\n * Paint the following squares white: the second and third squares from the left.\n\n* * *"}, {"input": "1 1\n -10", "output": "0\n \n\n* * *"}, {"input": "10 5\n 5 -4 -5 -8 -4 7 2 -4 0 7", "output": "17"}]
Print the number of the friendly pairs. * * *
s834770836
Wrong Answer
p03993
The input is given from Standard Input in the following format: N a_1 a_2 ... a_N
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10000000) INF = 1 << 32 from bisect import bisect_left, bisect_right def solve(N: int, a: "List[int]"): x = [[i + 1, a[i]] for i in range(N)] x = sorted(x, key=lambda x: x[1]) x1 = [i for i, j in x] x2 = [j for i, j in x] ans = 0 for i in range(N): p = bisect_left(x2, x1[i]) if not (0 <= p < N): continue if x1[i] == x2[p] and x2[i] == x1[p]: ans += 1 print(ans // 2) return def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int a = [int(next(tokens)) for _ in range(N)] # type: "List[int]" solve(N, a) if __name__ == "__main__": main()
Statement There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculate the number of the friendly pairs.
[{"input": "4\n 2 1 4 3", "output": "2\n \n\nThere are two friendly pairs: (1\uff0c2) and (3\uff0c4).\n\n* * *"}, {"input": "3\n 2 3 1", "output": "0\n \n\nThere are no friendly pairs.\n\n* * *"}, {"input": "5\n 5 5 5 5 1", "output": "1\n \n\nThere is one friendly pair: (1\uff0c5)."}]
Print the number of the friendly pairs. * * *
s034898556
Accepted
p03993
The input is given from Standard Input in the following format: N a_1 a_2 ... a_N
n = int(input()) s = input().split() print(n - len(set(tuple(sorted([i + 1, int(s[i])])) for i in range(n))))
Statement There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculate the number of the friendly pairs.
[{"input": "4\n 2 1 4 3", "output": "2\n \n\nThere are two friendly pairs: (1\uff0c2) and (3\uff0c4).\n\n* * *"}, {"input": "3\n 2 3 1", "output": "0\n \n\nThere are no friendly pairs.\n\n* * *"}, {"input": "5\n 5 5 5 5 1", "output": "1\n \n\nThere is one friendly pair: (1\uff0c5)."}]
Print the number of the friendly pairs. * * *
s778905811
Accepted
p03993
The input is given from Standard Input in the following format: N a_1 a_2 ... a_N
N = int(input()) aa = input() b = [] b = aa.split(" ") output = 0 a = [] flag = [] for i in range(len(b)): a.append(int(b[i])) flag.append(False) for i in range(len(a)): if i + 1 == a[a[i] - 1]: output = output + 1 print(output // 2)
Statement There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculate the number of the friendly pairs.
[{"input": "4\n 2 1 4 3", "output": "2\n \n\nThere are two friendly pairs: (1\uff0c2) and (3\uff0c4).\n\n* * *"}, {"input": "3\n 2 3 1", "output": "0\n \n\nThere are no friendly pairs.\n\n* * *"}, {"input": "5\n 5 5 5 5 1", "output": "1\n \n\nThere is one friendly pair: (1\uff0c5)."}]
Print the number of the friendly pairs. * * *
s377161279
Accepted
p03993
The input is given from Standard Input in the following format: N a_1 a_2 ... a_N
n = int(input()) a = [0] * (n + 1) a[1:] = map(int, input().split()) ans = set() for i in a[1:]: if i == a[a[i]]: j, k = sorted([i, a[i]]) ans |= {(j, k)} print(len(ans))
Statement There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculate the number of the friendly pairs.
[{"input": "4\n 2 1 4 3", "output": "2\n \n\nThere are two friendly pairs: (1\uff0c2) and (3\uff0c4).\n\n* * *"}, {"input": "3\n 2 3 1", "output": "0\n \n\nThere are no friendly pairs.\n\n* * *"}, {"input": "5\n 5 5 5 5 1", "output": "1\n \n\nThere is one friendly pair: (1\uff0c5)."}]
Print the number of the friendly pairs. * * *
s757940181
Wrong Answer
p03993
The input is given from Standard Input in the following format: N a_1 a_2 ... a_N
N = int(input()) a_1 = [] a_1 = input().split() a_2 = [] A = 0 a_2 = a_1 for n in a_1: # print(int(n)) if int(n) == int(a_2[int(n) - 1]): A = A + 1 a_2[int(n) - 1] = 0 else: pass print(A)
Statement There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculate the number of the friendly pairs.
[{"input": "4\n 2 1 4 3", "output": "2\n \n\nThere are two friendly pairs: (1\uff0c2) and (3\uff0c4).\n\n* * *"}, {"input": "3\n 2 3 1", "output": "0\n \n\nThere are no friendly pairs.\n\n* * *"}, {"input": "5\n 5 5 5 5 1", "output": "1\n \n\nThere is one friendly pair: (1\uff0c5)."}]
Print the number of the friendly pairs. * * *
s069431040
Wrong Answer
p03993
The input is given from Standard Input in the following format: N a_1 a_2 ... a_N
p = int(input()) A = list(map(int, input().split())) a = list(range(1, p + 1)) count = 0 for j, i in zip(a, A): if A.count(j) != 0: A.pop(A.index(j)) count += 1 print(count)
Statement There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculate the number of the friendly pairs.
[{"input": "4\n 2 1 4 3", "output": "2\n \n\nThere are two friendly pairs: (1\uff0c2) and (3\uff0c4).\n\n* * *"}, {"input": "3\n 2 3 1", "output": "0\n \n\nThere are no friendly pairs.\n\n* * *"}, {"input": "5\n 5 5 5 5 1", "output": "1\n \n\nThere is one friendly pair: (1\uff0c5)."}]
If T satisfies the property in Problem Statement, print `Yes`; otherwise, print `No`. * * *
s354062993
Runtime Error
p02681
Input is given from Standard Input in the following format: S T
i = input() s = i() t = i() print(["No", "Yes"][t[:-1] == s])
Statement Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above.
[{"input": "chokudai\n chokudaiz", "output": "Yes\n \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n snekee", "output": "No\n \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n aa", "output": "Yes"}]
If T satisfies the property in Problem Statement, print `Yes`; otherwise, print `No`. * * *
s075301420
Wrong Answer
p02681
Input is given from Standard Input in the following format: S T
print(input() + "a")
Statement Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above.
[{"input": "chokudai\n chokudaiz", "output": "Yes\n \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n snekee", "output": "No\n \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n aa", "output": "Yes"}]
If T satisfies the property in Problem Statement, print `Yes`; otherwise, print `No`. * * *
s981281233
Runtime Error
p02681
Input is given from Standard Input in the following format: S T
def parse(): N, K = map(int, input().split(" ")) A = [] for a in input().split(" "): A.append(int(a) - 1) return N, K, A def fast_pow(x, n): """ O(log n) """ if n == 0: return 1 K = 1 while n > 1: if n % 2 != 0: K *= x x *= x n //= 2 return K * x def fast_mod(x, N): if N % 2 == 0: return x & (fast_pow(2, N) - 1) else: return x % N def main(): N, K, A = parse() # print(N, K, A) # 経路の計算 route = [] next_town = A[0] town = 0 while not (next_town in route): # 既出の町に行く場合 route.append(town) next_town = A[town] town = next_town once_route = route[: route.index(next_town)] loop_route = route[route.index(next_town) :] # print("once_route:", once_route) # print("loop_route:", loop_route) # print([town + 1 for town in route]) # print("K %% len(loop_route):", K % len(loop_route)) # print(route[K % len(loop_route) + len(once_route)] + 1) if K > len(route) and len(once_route) > 0: # print("loop") loop_K = K - len(route) print(loop_route[fast_mod(loop_K, len(loop_route))] + 1) # print(loop_route[loop_K % len(loop_route)] + 1) else: # print("normal") # print(route[fast_mod(K, len(loop_route))] + 1) # print("K:", K) # print("K %% len(route):", K % len(route)) print(route[fast_mod(K, len(route))] + 1) # print(route[K % len(route)] + 1) if __name__ == "__main__": main()
Statement Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above.
[{"input": "chokudai\n chokudaiz", "output": "Yes\n \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n snekee", "output": "No\n \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n aa", "output": "Yes"}]
If T satisfies the property in Problem Statement, print `Yes`; otherwise, print `No`. * * *
s864874689
Runtime Error
p02681
Input is given from Standard Input in the following format: S T
[n, k], [*a] = [[*map(int, t.split())] for t in open(0)] count = 0 visited = dict() tmp = 1 while count <= k and tmp not in visited: visited[tmp] = count tmp = a[tmp - 1] count += 1 if count <= k: k = (k - count) % (count - visited[tmp]) for _ in range(k): tmp = a[tmp - 1] print(tmp)
Statement Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above.
[{"input": "chokudai\n chokudaiz", "output": "Yes\n \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n snekee", "output": "No\n \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n aa", "output": "Yes"}]
If T satisfies the property in Problem Statement, print `Yes`; otherwise, print `No`. * * *
s545213886
Runtime Error
p02681
Input is given from Standard Input in the following format: S T
# 4つの入力 a = input() # スペースで区切り処理 inputs = a.split(" ") # A,B,C,Kに代入 A = int(inputs[0]) B = int(inputs[1]) C = int(inputs[2]) K = int(inputs[3]) # 最終的結果の数字 i = int(0) # 残りの変数 left = int(0) # パターン1-1 # K(取る枚数)がA(1のカード)より多い時、A(1のカード)枚取り、 # left(残りの取る枚数)に代入する if K >= A: left = K - A i = i + A # print(f'1-1,残り枚数 {left}') # print(f'1-1,結果数 {i}') # パターン2-1 # left(残り枚数)がB(0のカード)より多い時B(0のカード)枚取る # leftに残りの枚数を代入する if left >= B: left = left - B # print(f'2-1残り枚数 {left}') # print(f'2-1結果数 {i}') # パターン3-1 # left(残り枚数)より多い時C(-1のカード)をleft(残り枚数)枚取る if left > 0: for a in range(left): i -= 1 # print(f'3-1結果数{i}') print(i) # パターン3-2 # C(-1)のカードをleft(残り枚数)枚とる(終了) else: left = left - left # print(f'3-2結果数{i}') print(left) # パターン2-2 # B(0のカード)がleft(残り枚数)より多い時B(0のカード)をleft(残り枚数)枚取る(終了) elif B > left: # print(f'2-2結果数{i}') print(i) # パターン1-2 # A(1のカード)がK(取る枚数)より多い時K枚取る(終了) elif A > K: i = i + A # print(f'1-2結果数{i}') print(i)
Statement Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above.
[{"input": "chokudai\n chokudaiz", "output": "Yes\n \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n snekee", "output": "No\n \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n aa", "output": "Yes"}]
If T satisfies the property in Problem Statement, print `Yes`; otherwise, print `No`. * * *
s576480909
Wrong Answer
p02681
Input is given from Standard Input in the following format: S T
print(("No", "Yes")[input() in input()])
Statement Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above.
[{"input": "chokudai\n chokudaiz", "output": "Yes\n \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n snekee", "output": "No\n \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n aa", "output": "Yes"}]
If T satisfies the property in Problem Statement, print `Yes`; otherwise, print `No`. * * *
s185619411
Accepted
p02681
Input is given from Standard Input in the following format: S T
print("YNeos"[input() != input()[:-1] :: 2])
Statement Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above.
[{"input": "chokudai\n chokudaiz", "output": "Yes\n \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n snekee", "output": "No\n \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n aa", "output": "Yes"}]
If T satisfies the property in Problem Statement, print `Yes`; otherwise, print `No`. * * *
s276235103
Wrong Answer
p02681
Input is given from Standard Input in the following format: S T
print("YES" if input() == input()[:-1] else "NO")
Statement Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above.
[{"input": "chokudai\n chokudaiz", "output": "Yes\n \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n snekee", "output": "No\n \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n aa", "output": "Yes"}]
If T satisfies the property in Problem Statement, print `Yes`; otherwise, print `No`. * * *
s619684805
Runtime Error
p02681
Input is given from Standard Input in the following format: S T
s, t = map(int, input().split()) print("No" if t >= s else "Yes")
Statement Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above.
[{"input": "chokudai\n chokudaiz", "output": "Yes\n \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n snekee", "output": "No\n \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n aa", "output": "Yes"}]
If T satisfies the property in Problem Statement, print `Yes`; otherwise, print `No`. * * *
s784741378
Runtime Error
p02681
Input is given from Standard Input in the following format: S T
print("YNeos"[input()[1] == "n" :: 2])
Statement Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above.
[{"input": "chokudai\n chokudaiz", "output": "Yes\n \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n snekee", "output": "No\n \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n aa", "output": "Yes"}]
If T satisfies the property in Problem Statement, print `Yes`; otherwise, print `No`. * * *
s451223914
Accepted
p02681
Input is given from Standard Input in the following format: S T
s = input() t = input() ss = [ s + "a", s + "b", s + "c", s + "d", s + "e", s + "f", s + "g", s + "h", s + "i", s + "j", s + "k", s + "l", s + "m", s + "n", s + "o", s + "p", s + "q", s + "r", s + "s", s + "t", s + "u", s + "v", s + "w", s + "x", s + "y", s + "z", ] if t in ss: print("Yes") else: print("No")
Statement Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above.
[{"input": "chokudai\n chokudaiz", "output": "Yes\n \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n snekee", "output": "No\n \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n aa", "output": "Yes"}]
If T satisfies the property in Problem Statement, print `Yes`; otherwise, print `No`. * * *
s996728390
Runtime Error
p02681
Input is given from Standard Input in the following format: S T
#!/usr/bin/env python """AtCoder Beginner Contest 167: C https://atcoder.jp/contests/abc167/tasks/abc167_c """ import sys import itertools __author__ = "bugttle <bugttle@gmail.com>" def main(): [N, M, X] = list(map(int, input().split())) l = [] for n in range(N): l.append(list(map(int, input().split()))) # print(l) status = [0] * M for n in range(N): for m in range(M): status[m] += l[n][m + 1] for v in status: if v < X: print(-1) return min_cost = sys.maxsize for p in itertools.permutations(range(N)): # print(p) cost = 0 status = [0] * M for n in p: cost += l[n][0] if min_cost < cost: break isCompleted = True for m in range(M): status[m] += l[n][m + 1] if status[m] < X: isCompleted = False # print(status) if isCompleted: # print('fin') # print(cost) if cost < min_cost: min_cost = cost break if min_cost == sys.maxsize: print(-1) else: print(min_cost) # status[m] += l[n][m] # for n in range(N): # for m in range(M): # print([n, m]) # cost = 0 # status = [[0]*M]*N # for n in range(N): # for m in range(M): # print(l[n][m + 1]) # # status[n][m] = l[n][m + 1] # print(status) if __name__ == "__main__": main()
Statement Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above.
[{"input": "chokudai\n chokudaiz", "output": "Yes\n \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n snekee", "output": "No\n \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n aa", "output": "Yes"}]
If T satisfies the property in Problem Statement, print `Yes`; otherwise, print `No`. * * *
s045970706
Runtime Error
p02681
Input is given from Standard Input in the following format: S T
string, string2 = map(str, input().split()) string2 = string2[0 : len(string2) - 1] print("Yes" if string == string2 else "No")
Statement Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above.
[{"input": "chokudai\n chokudaiz", "output": "Yes\n \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n snekee", "output": "No\n \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n aa", "output": "Yes"}]
If T satisfies the property in Problem Statement, print `Yes`; otherwise, print `No`. * * *
s840058773
Accepted
p02681
Input is given from Standard Input in the following format: S T
s, t = input(), input() print("YNeos"[s != t[: len(t) - 1] :: 2])
Statement Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above.
[{"input": "chokudai\n chokudaiz", "output": "Yes\n \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n snekee", "output": "No\n \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n aa", "output": "Yes"}]
If T satisfies the property in Problem Statement, print `Yes`; otherwise, print `No`. * * *
s676120154
Wrong Answer
p02681
Input is given from Standard Input in the following format: S T
s = input().strip() t = input().strip() print(s == t[:-1])
Statement Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above.
[{"input": "chokudai\n chokudaiz", "output": "Yes\n \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n snekee", "output": "No\n \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n aa", "output": "Yes"}]
If T satisfies the property in Problem Statement, print `Yes`; otherwise, print `No`. * * *
s552981863
Runtime Error
p02681
Input is given from Standard Input in the following format: S T
a = [int(x) for x in input().split()] count1 = 0 count0 = 0 count2 = 0 if a[3] > a[1]: count1 = a[0] if a[3] <= a[1]: count1 = a[3] if a[3] - a[1] - a[0] > 0: count2 = -(a[3] - a[1] - a[0]) print(count1 + count2)
Statement Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above.
[{"input": "chokudai\n chokudaiz", "output": "Yes\n \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n snekee", "output": "No\n \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n aa", "output": "Yes"}]
If T satisfies the property in Problem Statement, print `Yes`; otherwise, print `No`. * * *
s666360894
Runtime Error
p02681
Input is given from Standard Input in the following format: S T
n, m, k = map(int, input().split()) mod = 998244353 if m == 1: print(0 if k != n - 1 else 1) exit() fact = [1] * (n - 1 + 1) inv = [1] * (n - 1 + 1) for i in range(2, n - 1 + 1): fact[i] = i * fact[i - 1] % mod inv[-1] = pow(fact[-1], mod - 2, mod) for i in range(n - 1, 1, -1): inv[i - 1] = inv[i] * i % mod ans = 0 po = pow(m - 1, n - 1, mod) * m % mod ue = fact[n - 1] iii = pow(m - 1, mod - 2, mod) % mod for i in range(k + 1): ans += ue * inv[n - 1 - i] % mod * inv[i] % mod * po % mod po *= iii print(ans % mod)
Statement Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his ID. He is now trying to register with the ID T. Determine whether this string satisfies the property above.
[{"input": "chokudai\n chokudaiz", "output": "Yes\n \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n snekee", "output": "No\n \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n aa", "output": "Yes"}]
Print "Yes" if the circle is placed inside the rectangle, otherwise "No" in a line.
s098315811
Accepted
p02394
Five integers $W$, $H$, $x$, $y$ and $r$ separated by a single space are given in a line.
input = input().split() # input = '5 4 2 2 1'.split() W = int(input[0]) H = int(input[1]) x = int(input[2]) y = int(input[3]) r = int(input[4]) circlePoints = [[x - r, y], [x + r, y], [x, y - r], [x, y + r]] isInRect = "Yes" for point in circlePoints: dx = point[0] dy = point[1] if dx > W or dx < 0 or dy > H or dy < 0: isInRect = "No" print(isInRect)
Circle in a Rectangle Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given. ![Circle inside a rectangle](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_circle_and_rectangle)
[{"input": "5 4 2 2 1", "output": "Yes"}, {"input": "5 4 2 4 1", "output": "No"}]
Print "Yes" if the circle is placed inside the rectangle, otherwise "No" in a line.
s008982118
Accepted
p02394
Five integers $W$, $H$, $x$, $y$ and $r$ separated by a single space are given in a line.
w, h, x, y, r = [int(arg) for arg in input().split()] print("Yes" if (r <= x <= w - r) and (r <= y <= h - r) else "No")
Circle in a Rectangle Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given. ![Circle inside a rectangle](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_circle_and_rectangle)
[{"input": "5 4 2 2 1", "output": "Yes"}, {"input": "5 4 2 4 1", "output": "No"}]
Print "Yes" if the circle is placed inside the rectangle, otherwise "No" in a line.
s620143682
Accepted
p02394
Five integers $W$, $H$, $x$, $y$ and $r$ separated by a single space are given in a line.
w, h, x, y, r = eval(input().replace(" ", ",")) print("Yes" if 0 + r <= x <= w - r and 0 + r <= y <= h - r else "No")
Circle in a Rectangle Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given. ![Circle inside a rectangle](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_circle_and_rectangle)
[{"input": "5 4 2 2 1", "output": "Yes"}, {"input": "5 4 2 4 1", "output": "No"}]
Print "Yes" if the circle is placed inside the rectangle, otherwise "No" in a line.
s443675610
Accepted
p02394
Five integers $W$, $H$, $x$, $y$ and $r$ separated by a single space are given in a line.
[w, h, x, y, r] = map(int, input().split()) print("Yes" if r <= x and x <= w - r and r <= y and y <= h - r else "No")
Circle in a Rectangle Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given. ![Circle inside a rectangle](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_circle_and_rectangle)
[{"input": "5 4 2 2 1", "output": "Yes"}, {"input": "5 4 2 4 1", "output": "No"}]
Print "Yes" if the circle is placed inside the rectangle, otherwise "No" in a line.
s248653183
Wrong Answer
p02394
Five integers $W$, $H$, $x$, $y$ and $r$ separated by a single space are given in a line.
(W, H, x, y, r) = [int(i) for i in input().split()]
Circle in a Rectangle Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given. ![Circle inside a rectangle](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_circle_and_rectangle)
[{"input": "5 4 2 2 1", "output": "Yes"}, {"input": "5 4 2 4 1", "output": "No"}]
Print "Yes" if the circle is placed inside the rectangle, otherwise "No" in a line.
s847760807
Accepted
p02394
Five integers $W$, $H$, $x$, $y$ and $r$ separated by a single space are given in a line.
w, h, x, y, r = map(int, input().split()) print( "{0}".format( "Yes" if 0 <= x - r and 0 <= w - x - r and 0 <= y - r and 0 <= h - y - r else "No" ) )
Circle in a Rectangle Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given. ![Circle inside a rectangle](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_circle_and_rectangle)
[{"input": "5 4 2 2 1", "output": "Yes"}, {"input": "5 4 2 4 1", "output": "No"}]
Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. * * *
s484995384
Wrong Answer
p02547
Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2}
a = int(input()) _number = 0 _kaerichi = "No" for i in range(a): b, c = map(int, input().split()) if b == c: _number += 1 if _number == 3: _kaerichi = "Yes" print(_kaerichi)
Statement Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.
[{"input": "5\n 1 2\n 6 6\n 4 4\n 3 3\n 3 2", "output": "Yes\n \n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\n* * *"}, {"input": "5\n 1 1\n 2 2\n 3 4\n 5 5\n 6 6", "output": "No\n \n\n* * *"}, {"input": "6\n 1 1\n 2 2\n 3 3\n 4 4\n 5 5\n 6 6", "output": "Yes"}]
Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. * * *
s154199999
Accepted
p02547
Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2}
a = [len(set(input().split())) == 1 for _ in range(int(input()))] print("NYoe s"[any(map(all, zip(a, a[1:], a[2:]))) :: 2])
Statement Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.
[{"input": "5\n 1 2\n 6 6\n 4 4\n 3 3\n 3 2", "output": "Yes\n \n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\n* * *"}, {"input": "5\n 1 1\n 2 2\n 3 4\n 5 5\n 6 6", "output": "No\n \n\n* * *"}, {"input": "6\n 1 1\n 2 2\n 3 3\n 4 4\n 5 5\n 6 6", "output": "Yes"}]
Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. * * *
s382778045
Wrong Answer
p02547
Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2}
print("NYoe s"[[*"000"] in [str(eval(t.replace(*" -"))) for t in open(0)] :: 2])
Statement Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.
[{"input": "5\n 1 2\n 6 6\n 4 4\n 3 3\n 3 2", "output": "Yes\n \n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\n* * *"}, {"input": "5\n 1 1\n 2 2\n 3 4\n 5 5\n 6 6", "output": "No\n \n\n* * *"}, {"input": "6\n 1 1\n 2 2\n 3 3\n 4 4\n 5 5\n 6 6", "output": "Yes"}]
Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. * * *
s249223306
Wrong Answer
p02547
Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2}
print("NYoe s"["111" in "".join(str(len({*t.split()})) for t in open(0)) :: 2])
Statement Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.
[{"input": "5\n 1 2\n 6 6\n 4 4\n 3 3\n 3 2", "output": "Yes\n \n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\n* * *"}, {"input": "5\n 1 1\n 2 2\n 3 4\n 5 5\n 6 6", "output": "No\n \n\n* * *"}, {"input": "6\n 1 1\n 2 2\n 3 3\n 4 4\n 5 5\n 6 6", "output": "Yes"}]
Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. * * *
s210558384
Wrong Answer
p02547
Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2}
print( "YNEOS"[ "000" not in "".join( [str(eval(input().replace(" ", "-"))) for _ in "_" * int(input())] ) :: 2 ] )
Statement Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.
[{"input": "5\n 1 2\n 6 6\n 4 4\n 3 3\n 3 2", "output": "Yes\n \n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\n* * *"}, {"input": "5\n 1 1\n 2 2\n 3 4\n 5 5\n 6 6", "output": "No\n \n\n* * *"}, {"input": "6\n 1 1\n 2 2\n 3 3\n 4 4\n 5 5\n 6 6", "output": "Yes"}]
Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. * * *
s192222409
Wrong Answer
p02547
Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2}
print("NYoe s"[[*"111"] in [str(len({*t.split()})) for t in open(0)][1:] :: 2])
Statement Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.
[{"input": "5\n 1 2\n 6 6\n 4 4\n 3 3\n 3 2", "output": "Yes\n \n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\n* * *"}, {"input": "5\n 1 1\n 2 2\n 3 4\n 5 5\n 6 6", "output": "No\n \n\n* * *"}, {"input": "6\n 1 1\n 2 2\n 3 3\n 4 4\n 5 5\n 6 6", "output": "Yes"}]
Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. * * *
s955741049
Accepted
p02547
Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2}
def isSameThree(num_of_indices): same_count = 0 for d1,d2 in num_of_indices: if(d1 == d2): same_count += 1 if(same_count == 3): return "Yes" else: same_count = 0 return "No" N = int(input()) num_of_indices = [list(map(int,input().split())) for i in range(N)] print(isSameThree(num_of_indices))
Statement Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.
[{"input": "5\n 1 2\n 6 6\n 4 4\n 3 3\n 3 2", "output": "Yes\n \n\nFrom the second roll to the fourth roll, three doublets occurred in a row.\n\n* * *"}, {"input": "5\n 1 1\n 2 2\n 3 4\n 5 5\n 6 6", "output": "No\n \n\n* * *"}, {"input": "6\n 1 1\n 2 2\n 3 3\n 4 4\n 5 5\n 6 6", "output": "Yes"}]
Print the maximum possible number of i such that p_i = i after operations. * * *
s406448552
Accepted
p03356
Input is given from Standard Input in the following format: N M p_1 p_2 .. p_N x_1 y_1 x_2 y_2 : x_M y_M
def main(): from collections import deque import sys input = sys.stdin.readline N, M = map(int, input().split()) p = [int(x) - 1 for x in input().split()] g = tuple(set() for _ in range(N)) for _ in range(M): x, y = (int(x) - 1 for x in input().split()) g[x].add(y) g[y].add(x) roots = [-1] * N for r in range(N): if ~roots[r]: continue dq = deque() dq.append(r) roots[r] = r while dq: v = dq.popleft() for u in g[v]: if ~roots[u]: continue roots[u] = r dq.append(u) cnt = sum(1 for i, pi in enumerate(p) if roots[i] == roots[pi]) print(cnt) if __name__ == "__main__": main() # import sys # input = sys.stdin.readline # # sys.setrecursionlimit(10 ** 7) # # (int(x)-1 for x in input().split()) # rstrip() # # def binary_search(*, ok, ng, func): # while abs(ok - ng) > 1: # mid = (ok + ng) // 2 # if func(mid): # ok = mid # else: # ng = mid # return ok
Statement 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.
[{"input": "5 2\n 5 3 1 4 2\n 1 3\n 5 4", "output": "2\n \n\nIf we perform the operation by choosing j=1, p becomes `1 3 5 4 2`, which is\noptimal, so the answer is 2.\n\n* * *"}, {"input": "3 2\n 3 2 1\n 1 2\n 2 3", "output": "3\n \n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this\norder, p becomes `1 2 3`, which is obviously optimal. Note that we may choose\nthe same j any number of times.\n\n* * *"}, {"input": "10 8\n 5 3 6 8 7 10 9 1 2 4\n 3 1\n 4 1\n 5 9\n 2 5\n 6 5\n 3 5\n 8 9\n 7 9", "output": "8\n \n\n* * *"}, {"input": "5 1\n 1 2 3 4 5\n 1 5", "output": "5\n \n\nWe do not have to perform the operation."}]
Print the maximum possible number of i such that p_i = i after operations. * * *
s799221886
Runtime Error
p03356
Input is given from Standard Input in the following format: N M p_1 p_2 .. p_N x_1 y_1 x_2 y_2 : x_M y_M
def read_values(): return map(int, input().split()) def read_index(): return map(lambda x: int(x) - 1, input().split()) def read_list(): return list(read_values()) def read_lists(N): return [read_list() for n in range(N)] class UF: def __init__(self, N): self.state = [-1] * N self.rank = [0] * N self.num_group = N def get_parent(self, a): p = self.state[a] if p < 0: return a q = self.get_parent(p) self.state[a] = q return q def make_pair(self, a, b): pa = self.get_parent(a) pb = self.get_parent(b) if pa == pb: return if self.rank[pa] > self.rank[pb]: pa, pb = pb, pa a, b = b, a elif self.rank[pa] == self.rank[pb]: self.rank[pb] += 1 self.state[pb] += self.state[pa] self.state[pa] = pb self.state[a] = pb self.num_group -= 1 def is_pair(self, a, b): return self.get_parent(a) == self.get_parent(b) def get_size(self, a): return -self.state[self.get_parent(a)] N, M = read_values() A = read_list() uf = UF(N) for _ in range(M): i, j = read_index() uf.make_pair(A[i] - 1, A[j] - 1) res = 0 for i, a in enumerate(A): if uf.is_pair(i, A[i] - 1) print(res)
Statement 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.
[{"input": "5 2\n 5 3 1 4 2\n 1 3\n 5 4", "output": "2\n \n\nIf we perform the operation by choosing j=1, p becomes `1 3 5 4 2`, which is\noptimal, so the answer is 2.\n\n* * *"}, {"input": "3 2\n 3 2 1\n 1 2\n 2 3", "output": "3\n \n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this\norder, p becomes `1 2 3`, which is obviously optimal. Note that we may choose\nthe same j any number of times.\n\n* * *"}, {"input": "10 8\n 5 3 6 8 7 10 9 1 2 4\n 3 1\n 4 1\n 5 9\n 2 5\n 6 5\n 3 5\n 8 9\n 7 9", "output": "8\n \n\n* * *"}, {"input": "5 1\n 1 2 3 4 5\n 1 5", "output": "5\n \n\nWe do not have to perform the operation."}]
Print the maximum possible number of i such that p_i = i after operations. * * *
s384670839
Runtime Error
p03356
Input is given from Standard Input in the following format: N M p_1 p_2 .. p_N x_1 y_1 x_2 y_2 : x_M y_M
import sys def create_dict(N): d = {} for i in range(N): d[i + 1] = set([i + 1]) return d N, M = map(int, input().split(" ")) d = create_dict(N) p_list = list(map(int, input().split(" "))) x_list = [] y_list = [] for line in sys.stdin: x, y = map(int, line.strip().split(" ")) d[min(x, y)].add(max(x, y)) del d[max(x, y)] score = 0 for i in d: for x in d[i]: if p_list[x - 1] in d[i]: score += 1 print(score)
Statement 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.
[{"input": "5 2\n 5 3 1 4 2\n 1 3\n 5 4", "output": "2\n \n\nIf we perform the operation by choosing j=1, p becomes `1 3 5 4 2`, which is\noptimal, so the answer is 2.\n\n* * *"}, {"input": "3 2\n 3 2 1\n 1 2\n 2 3", "output": "3\n \n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this\norder, p becomes `1 2 3`, which is obviously optimal. Note that we may choose\nthe same j any number of times.\n\n* * *"}, {"input": "10 8\n 5 3 6 8 7 10 9 1 2 4\n 3 1\n 4 1\n 5 9\n 2 5\n 6 5\n 3 5\n 8 9\n 7 9", "output": "8\n \n\n* * *"}, {"input": "5 1\n 1 2 3 4 5\n 1 5", "output": "5\n \n\nWe do not have to perform the operation."}]
Print the maximum possible number of i such that p_i = i after operations. * * *
s831915465
Runtime Error
p03356
Input is given from Standard Input in the following format: N M p_1 p_2 .. p_N x_1 y_1 x_2 y_2 : x_M y_M
class UnionFind(): def __init__(self, size): self.table = [-1 for _ in range(size)] def find(self, x): if self.table[x] < 0: return x else: self.table[x] = self.find(self.table[x]) #xをxの根に直接つなぐ return self.table[x] def union(self, x, y): s1 = self.find(x) s2 = self.find(y) if s1 == s2: return else: st1 = self.table[s1] st2 = self.table[s2] if st1 > st2: self.table[s2] = s1 elif st1 < st2: self.table[s1] = s2 else: self.table[s1] = s2 self.table[s2] -= 1 n, m = map(int, input().split()) p = list(map(int, input().split())) uf = UnionFind(n) for i in range(m): x, y = map(int, input().split()) uf.union(x - 1, y - 1) ans = 0 for i, pp in enumerate(p): if pp - 1 == i: ans += 1 elif uf.find(pp - 1) == uf.find(i): ans += 1 print(ans)
Statement 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.
[{"input": "5 2\n 5 3 1 4 2\n 1 3\n 5 4", "output": "2\n \n\nIf we perform the operation by choosing j=1, p becomes `1 3 5 4 2`, which is\noptimal, so the answer is 2.\n\n* * *"}, {"input": "3 2\n 3 2 1\n 1 2\n 2 3", "output": "3\n \n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this\norder, p becomes `1 2 3`, which is obviously optimal. Note that we may choose\nthe same j any number of times.\n\n* * *"}, {"input": "10 8\n 5 3 6 8 7 10 9 1 2 4\n 3 1\n 4 1\n 5 9\n 2 5\n 6 5\n 3 5\n 8 9\n 7 9", "output": "8\n \n\n* * *"}, {"input": "5 1\n 1 2 3 4 5\n 1 5", "output": "5\n \n\nWe do not have to perform the operation."}]
Print the maximum possible number of i such that p_i = i after operations. * * *
s775606431
Accepted
p03356
Input is given from Standard Input in the following format: N M p_1 p_2 .. p_N x_1 y_1 x_2 y_2 : x_M y_M
# ARC097D import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) n, m = map(int, input().split()) p = list(map(lambda x: int(x) - 1, input().split())) from collections import defaultdict es = defaultdict(set) for i in range(m): u, v = map(int, input().split()) es[u - 1].add(v - 1) es[v - 1].add(u - 1) count = 0 seen = [False] * n for u in range(n): index = set() values = set() if seen[u]: continue index.add(u) values.add(p[u]) q = [u] seen[u] = True while q: u = q.pop() for v in es[u]: if not seen[v]: q.append(v) seen[v] = True index.add(v) values.add(p[v]) count += len(index & values) print(count)
Statement 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.
[{"input": "5 2\n 5 3 1 4 2\n 1 3\n 5 4", "output": "2\n \n\nIf we perform the operation by choosing j=1, p becomes `1 3 5 4 2`, which is\noptimal, so the answer is 2.\n\n* * *"}, {"input": "3 2\n 3 2 1\n 1 2\n 2 3", "output": "3\n \n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this\norder, p becomes `1 2 3`, which is obviously optimal. Note that we may choose\nthe same j any number of times.\n\n* * *"}, {"input": "10 8\n 5 3 6 8 7 10 9 1 2 4\n 3 1\n 4 1\n 5 9\n 2 5\n 6 5\n 3 5\n 8 9\n 7 9", "output": "8\n \n\n* * *"}, {"input": "5 1\n 1 2 3 4 5\n 1 5", "output": "5\n \n\nWe do not have to perform the operation."}]
Print the maximum possible number of i such that p_i = i after operations. * * *
s114543222
Runtime Error
p03356
Input is given from Standard Input in the following format: N M p_1 p_2 .. p_N x_1 y_1 x_2 y_2 : x_M y_M
#ifndef BZ #pragma GCC optimize "-O3" #endif #include <bits/stdc++.h> #define FASTIO #ifdef FASTIO #define scanf abacaba #define printf abacaba #endif typedef long long ll; typedef long double ld; typedef unsigned long long ull; using namespace std; /* ll pw(ll a, ll b) { ll ans = 1; while (b) { while (!(b & 1)) b >>= 1, a = (a * a) % MOD; ans = (ans * a) % MOD, --b; } return ans; } */ const int MAXN = 120000; int n, m; vector<int> eds[MAXN]; int was[MAXN]; set<int> v1, v2; int p[MAXN]; void dfs1(int v) { v1.insert(v); v2.insert(p[v]); was[v] = 1; for (int u: eds[v]) if (!was[u]) dfs1(u); } int main() { #ifdef FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); #endif cin >> n >> m; for (int i = 0; i < n; ++i) { cin >> p[i], --p[i]; } for (int i = 0; i < m; ++i) { int a, b; cin >> a >> b; --a, --b; eds[a].push_back(b); eds[b].push_back(a); } int ans = 0; for (int i = 0; i < n; ++i) { if (was[i]) continue; v1.clear(); v2.clear(); dfs1(i); for (int j: v1) if (v2.count(j)) ans += 1; } cout << ans << "\n"; return 0; }
Statement 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.
[{"input": "5 2\n 5 3 1 4 2\n 1 3\n 5 4", "output": "2\n \n\nIf we perform the operation by choosing j=1, p becomes `1 3 5 4 2`, which is\noptimal, so the answer is 2.\n\n* * *"}, {"input": "3 2\n 3 2 1\n 1 2\n 2 3", "output": "3\n \n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this\norder, p becomes `1 2 3`, which is obviously optimal. Note that we may choose\nthe same j any number of times.\n\n* * *"}, {"input": "10 8\n 5 3 6 8 7 10 9 1 2 4\n 3 1\n 4 1\n 5 9\n 2 5\n 6 5\n 3 5\n 8 9\n 7 9", "output": "8\n \n\n* * *"}, {"input": "5 1\n 1 2 3 4 5\n 1 5", "output": "5\n \n\nWe do not have to perform the operation."}]
Print the maximum possible number of i such that p_i = i after operations. * * *
s305666754
Runtime Error
p03356
Input is given from Standard Input in the following format: N M p_1 p_2 .. p_N x_1 y_1 x_2 y_2 : x_M y_M
class UnionFind(): def __init__(self, size): self.table = [-1 for _ in range(size)] def find(self, x): while self.table[x] >= 0: x = self.table[x] return x def union(self, x, y): s1 = self.find(x) s2 = self.find(y) if s1 == s2: return elif: if self.table[s1] > self.table[s2]: self.table[s2] = s1 elif self.table[s1] < self.table[s2]: self.table[s1] = s2 else: self.table[s1] = s2 self.table[s2] -= 1 n, m = map(int, input().split()) p = list(map(int, input().split())) uf = UnionFind(n) for i in range(m): x, y = map(int, input().split()) uf.union(x - 1, y - 1) ans = 0 for i, pp in enumerate(p): if pp - 1 == i: ans += 1 elif uf.find(pp - 1) == uf.find(i): ans += 1 print(ans)
Statement 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.
[{"input": "5 2\n 5 3 1 4 2\n 1 3\n 5 4", "output": "2\n \n\nIf we perform the operation by choosing j=1, p becomes `1 3 5 4 2`, which is\noptimal, so the answer is 2.\n\n* * *"}, {"input": "3 2\n 3 2 1\n 1 2\n 2 3", "output": "3\n \n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this\norder, p becomes `1 2 3`, which is obviously optimal. Note that we may choose\nthe same j any number of times.\n\n* * *"}, {"input": "10 8\n 5 3 6 8 7 10 9 1 2 4\n 3 1\n 4 1\n 5 9\n 2 5\n 6 5\n 3 5\n 8 9\n 7 9", "output": "8\n \n\n* * *"}, {"input": "5 1\n 1 2 3 4 5\n 1 5", "output": "5\n \n\nWe do not have to perform the operation."}]
Print the maximum possible number of i such that p_i = i after operations. * * *
s441792606
Runtime Error
p03356
Input is given from Standard Input in the following format: N M p_1 p_2 .. p_N x_1 y_1 x_2 y_2 : x_M y_M
N, M = list(map(int, input().split())) p = list(map(int, input().split())) x = [] y = [] for _ in range(M): xi, yi = list(map(int, input().split())) x.append(xi) y.append(yi) def count(l): out = 0 for i, v in enumerate(l): if i + 1 == v: out += 1 return out def swap(l, a, b): va = l[a] vb = l[b] l1 = l.copy() l1[a] = vb l1[b] = va return l1 depth = 0 max_count = count(p) max_d = M**(N*np.log(N)) children = [p] next_children = [] while depth <= max_d: for child in children: for i in range(M): pi = swap(child) ci = count(pi) if ci > max_count: max_count = ci next_children.append(pi) depth += 1 children = next_children next_chldren = [] if max_count = len(p): break print(max_count)
Statement 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.
[{"input": "5 2\n 5 3 1 4 2\n 1 3\n 5 4", "output": "2\n \n\nIf we perform the operation by choosing j=1, p becomes `1 3 5 4 2`, which is\noptimal, so the answer is 2.\n\n* * *"}, {"input": "3 2\n 3 2 1\n 1 2\n 2 3", "output": "3\n \n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this\norder, p becomes `1 2 3`, which is obviously optimal. Note that we may choose\nthe same j any number of times.\n\n* * *"}, {"input": "10 8\n 5 3 6 8 7 10 9 1 2 4\n 3 1\n 4 1\n 5 9\n 2 5\n 6 5\n 3 5\n 8 9\n 7 9", "output": "8\n \n\n* * *"}, {"input": "5 1\n 1 2 3 4 5\n 1 5", "output": "5\n \n\nWe do not have to perform the operation."}]
Print the maximum possible number of i such that p_i = i after operations. * * *
s380760967
Accepted
p03356
Input is given from Standard Input in the following format: N M p_1 p_2 .. p_N x_1 y_1 x_2 y_2 : x_M y_M
printn = lambda x: print(x, end="") inn = lambda: int(input()) inl = lambda: list(map(int, input().split())) inm = lambda: map(int, input().split()) ins = lambda: input().strip() DBG = True # and False BIG = 10**18 R = 10**9 + 7 def ddprint(x): if DBG: print(x) def ufinit(n): global ufsz, ufances ufsz = [1] * n ufances = [0] * n for i in range(n): ufances[i] = i def ufroot(x): global ufances a = [] y = x while ufances[y] != y: a.append(y) y = ufances[y] for z in a: ufances[z] = y return y def ufconn(x, y): global ufsz, ufances i = ufroot(x) j = ufroot(y) if i == j: return # k = [i,j].min k = j if (ufsz[i] < ufsz[j]) else i if k == j: ufances[i] = j else: ufances[j] = i ufsz[k] = ufsz[i] + ufsz[j] n, m = inm() p = inl() p[0:0] = [0] x = [] y = [] for i in range(m): xx, yy = inm() x.append(xx) y.append(yy) ufinit(n + 1) for i in range(m): ufconn(x[i], y[i]) ga = [0] * (n + 1) gb = [0] * (n + 1) for i in range(1, n + 1): r = ufroot(i) ga[i] = gb[p[i]] = r sm = 0 for i in range(1, n + 1): if ga[i] == gb[i]: sm += 1 print(sm)
Statement 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.
[{"input": "5 2\n 5 3 1 4 2\n 1 3\n 5 4", "output": "2\n \n\nIf we perform the operation by choosing j=1, p becomes `1 3 5 4 2`, which is\noptimal, so the answer is 2.\n\n* * *"}, {"input": "3 2\n 3 2 1\n 1 2\n 2 3", "output": "3\n \n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this\norder, p becomes `1 2 3`, which is obviously optimal. Note that we may choose\nthe same j any number of times.\n\n* * *"}, {"input": "10 8\n 5 3 6 8 7 10 9 1 2 4\n 3 1\n 4 1\n 5 9\n 2 5\n 6 5\n 3 5\n 8 9\n 7 9", "output": "8\n \n\n* * *"}, {"input": "5 1\n 1 2 3 4 5\n 1 5", "output": "5\n \n\nWe do not have to perform the operation."}]
Print the maximum possible number of i such that p_i = i after operations. * * *
s110157398
Accepted
p03356
Input is given from Standard Input in the following format: N M p_1 p_2 .. p_N x_1 y_1 x_2 y_2 : x_M y_M
n, m = map(int, input().split()) ps = [int(x) for x in input().split()] xs = [tuple(map(int, input().split())) for _ in range(m)] union = {x: x for x in range(1, n + 1)} def root(n): if union[n] == n: return n union[n] = root(union[n]) return union[n] for x, y in xs: union[root(x)] = root(y) print(sum(root(i + 1) == root(ps[i]) for i in range(n)))
Statement 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.
[{"input": "5 2\n 5 3 1 4 2\n 1 3\n 5 4", "output": "2\n \n\nIf we perform the operation by choosing j=1, p becomes `1 3 5 4 2`, which is\noptimal, so the answer is 2.\n\n* * *"}, {"input": "3 2\n 3 2 1\n 1 2\n 2 3", "output": "3\n \n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this\norder, p becomes `1 2 3`, which is obviously optimal. Note that we may choose\nthe same j any number of times.\n\n* * *"}, {"input": "10 8\n 5 3 6 8 7 10 9 1 2 4\n 3 1\n 4 1\n 5 9\n 2 5\n 6 5\n 3 5\n 8 9\n 7 9", "output": "8\n \n\n* * *"}, {"input": "5 1\n 1 2 3 4 5\n 1 5", "output": "5\n \n\nWe do not have to perform the operation."}]
Print the maximum possible number of i such that p_i = i after operations. * * *
s507327531
Accepted
p03356
Input is given from Standard Input in the following format: N M p_1 p_2 .. p_N x_1 y_1 x_2 y_2 : x_M y_M
import sys def key2rep_iter(key, key2rep, temp_list): if key2rep[key] == key: for i in temp_list: key2rep[i] = key2rep[key] return key temp_list.append(key) return key2rep_iter(key2rep[key], key2rep, temp_list) def add_x2y(x, y, key2rep): rep = key2rep_iter(y, key2rep, []) big_rep = key2rep_iter(x, key2rep, []) if rep == big_rep: return key2rep[big_rep] = rep N, M = map(int, input().split(" ")) p_list = [int(i) for i in input().split(" ")] key2rep = {i + 1: i + 1 for i in range(N)} for line in sys.stdin: x, y = map(int, line.strip().split(" ")) add_x2y(max(x, y), min(x, y), key2rep) print( len( [ 1 for i in range(N) if key2rep_iter(p_list[i], key2rep, []) == key2rep_iter(i + 1, key2rep, []) ] ) )
Statement 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.
[{"input": "5 2\n 5 3 1 4 2\n 1 3\n 5 4", "output": "2\n \n\nIf we perform the operation by choosing j=1, p becomes `1 3 5 4 2`, which is\noptimal, so the answer is 2.\n\n* * *"}, {"input": "3 2\n 3 2 1\n 1 2\n 2 3", "output": "3\n \n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this\norder, p becomes `1 2 3`, which is obviously optimal. Note that we may choose\nthe same j any number of times.\n\n* * *"}, {"input": "10 8\n 5 3 6 8 7 10 9 1 2 4\n 3 1\n 4 1\n 5 9\n 2 5\n 6 5\n 3 5\n 8 9\n 7 9", "output": "8\n \n\n* * *"}, {"input": "5 1\n 1 2 3 4 5\n 1 5", "output": "5\n \n\nWe do not have to perform the operation."}]
Print the maximum possible number of i such that p_i = i after operations. * * *
s241539462
Accepted
p03356
Input is given from Standard Input in the following format: N M p_1 p_2 .. p_N x_1 y_1 x_2 y_2 : x_M y_M
N, M = map(int, input().split()) P = [int(p) for p in input().split()] Par = [int(i) for i in range(N + 1)] Rank = [0 for i in range(N + 1)] def find(i, Par): if Par[i] == i: return i else: Par[i] = find(Par[i], Par) return Par[i] def Unite(x, y): rx, ry = find(x, Par), find(y, Par) if rx == ry: return if Rank[rx] < Rank[ry]: Par[rx] = ry else: Par[ry] = rx if Rank[rx] == Rank[ry]: Rank[rx] += 1 def Same(x, y): return find(x, Par) == find(y, Par) for i in range(M): x, y = map(int, input().split()) x, y = min(x, y), max(x, y) Unite(x, y) Count = 0 for i in range(N): Count += 1 if Same(P[i], i + 1) else 0 print(Count)
Statement 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.
[{"input": "5 2\n 5 3 1 4 2\n 1 3\n 5 4", "output": "2\n \n\nIf we perform the operation by choosing j=1, p becomes `1 3 5 4 2`, which is\noptimal, so the answer is 2.\n\n* * *"}, {"input": "3 2\n 3 2 1\n 1 2\n 2 3", "output": "3\n \n\nIf we perform the operation by, for example, choosing j=1, j=2, j=1 in this\norder, p becomes `1 2 3`, which is obviously optimal. Note that we may choose\nthe same j any number of times.\n\n* * *"}, {"input": "10 8\n 5 3 6 8 7 10 9 1 2 4\n 3 1\n 4 1\n 5 9\n 2 5\n 6 5\n 3 5\n 8 9\n 7 9", "output": "8\n \n\n* * *"}, {"input": "5 1\n 1 2 3 4 5\n 1 5", "output": "5\n \n\nWe do not have to perform the operation."}]
Print the abbreviation for the N-th round of ABC. * * *
s427842887
Runtime Error
p03643
Input is given from Standard Input in the following format: N
in=input() print("ABC{}".format(in))
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s253373545
Runtime Error
p03643
Input is given from Standard Input in the following format: N
print("ABC{}".format(int(input()))
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s167905189
Accepted
p03643
Input is given from Standard Input in the following format: N
N = list(input()) if len(N) == 1: N = ["0", "0"] + N if len(N) == 2: N = ["0"] + N print("ABC" + "".join(N))
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s625404443
Wrong Answer
p03643
Input is given from Standard Input in the following format: N
n = int(input()) nums = [0, 2, 4, 8, 16, 32, 64] maxi = 0 for i in nums: if i <= n: maxi = i print(maxi)
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s299767778
Runtime Error
p03643
Input is given from Standard Input in the following format: N
n, m = map(int, input().split()) a = [[int(i) for i in input().split()] for j in range(m)] a.sort(key=lambda x: x[1]) a.sort(key=lambda x: x[0]) cc = 0 for i in range(m): if a[i][0] == 1: for j in range(i, m): if a[i][1] == a[j][0] and a[j][1] == n: cc = 1 break if cc == 1: break print("POSSIBLE" if cc == 1 else "IMPOSSIBLE")
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s612880204
Runtime Error
p03643
Input is given from Standard Input in the following format: N
import math from math import gcd, pi, sqrt INF = float("inf") import sys sys.setrecursionlimit(10**6) import itertools from collections import Counter, deque def i_input(): return int(input()) def i_map(): return map(int, input().split()) def i_list(): return list(i_map()) def i_row(N): return [i_input() for _ in range(N)] def i_row_list(N): return [i_list() for _ in range(N)] def s_input(): return input() def s_map(): return input().split() def s_list(): return list(s_map()) def s_row(N): return [s_input for _ in range(N)] def s_row_str(N): return [s_list() for _ in range(N)] def s_row_list(N): return [list(s_input()) for _ in range(N)] import string def main(): n, m = i_map() c = [[INF] * n for _ in range(n)] for i in range(n): c[i][i] = 0 for _ in range(m): a, b = i_map() c[a - 1][b - 1] = 1 c[b - 1][a - 1] = 1 for i, k in enumerate(c[0]): if k == 1: if c[i][-1] == 1: print("POSSIBLE") exit() print("IMPOSSIBLE") if __name__ == "__main__": main()
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s953851058
Accepted
p03643
Input is given from Standard Input in the following format: N
print(f"ABC{input()}")
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s581497349
Runtime Error
p03643
Input is given from Standard Input in the following format: N
print(ABC + input())
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s277139422
Runtime Error
p03643
Input is given from Standard Input in the following format: N
n, m = map(int, input().split()) print((n - 1) * (m - 1))
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s049668113
Accepted
p03643
Input is given from Standard Input in the following format: N
print("ABC{}".format(int(input())))
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s740640824
Wrong Answer
p03643
Input is given from Standard Input in the following format: N
print(2 ** (len(bin(int(input()))) - 3))
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s039913279
Runtime Error
p03643
Input is given from Standard Input in the following format: N
print("ABC" + int(input()))
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s119628424
Runtime Error
p03643
Input is given from Standard Input in the following format: N
n = (input() print('ABC'+n)
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s817517647
Runtime Error
p03643
Input is given from Standard Input in the following format: N
N = readline() print("ABC" * N)
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s270748743
Accepted
p03643
Input is given from Standard Input in the following format: N
n = int(input().strip()) print("ABC" + "{:0>3}".format(str(n)))
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s956971108
Accepted
p03643
Input is given from Standard Input in the following format: N
print("".join(map(str, ["ABC", int(input())])))
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s996829051
Accepted
p03643
Input is given from Standard Input in the following format: N
a = int(input()) print("ABC" + str(a))
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s346802835
Runtime Error
p03643
Input is given from Standard Input in the following format: N
ソースコード 拡げる Copy Copy N = int(input()) count = 0 for i in range(N): c = 2**count if c > N: print(c//2) exit() else: count +=1
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s051200136
Wrong Answer
p03643
Input is given from Standard Input in the following format: N
K = int(input()) print(2) print(0, K + 1)
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s466988572
Wrong Answer
p03643
Input is given from Standard Input in the following format: N
use = int(input()) best_number = 0 maximum = 0 t = 0 for i in range(2, use + 1, 2): n = i while n % 2 == 0: n /= 2 t += 1 if t > maximum: maximum = t best_number = i t = 0 print(best_number)
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s295453138
Wrong Answer
p03643
Input is given from Standard Input in the following format: N
number = input("a") print("ABC" + str(number))
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s149639817
Runtime Error
p03643
Input is given from Standard Input in the following format: N
print("ABC" + inpit())
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s513424687
Wrong Answer
p03643
Input is given from Standard Input in the following format: N
k = int(input()) if k == 0: for i in range(50): print(49 - i, end=" ") print() else: a = (k - 1) // 50 b = k % 50 if b == 0: for i in range(50): print(50 + a - i) print() else: for i in range(50): b = b - 1 if b >= 0: print(50 + a - i) else: print(50 + a - i - 1) if i == 49: print()
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s726320556
Wrong Answer
p03643
Input is given from Standard Input in the following format: N
print("abc" + input())
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s701318096
Runtime Error
p03643
Input is given from Standard Input in the following format: N
uk3zdbr9
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s971289976
Accepted
p03643
Input is given from Standard Input in the following format: N
a = (str)(input()) print("ABC" + a, "\n")
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s663554762
Runtime Error
p03643
Input is given from Standard Input in the following format: N
print("ABC{0}".format(input())
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s126289302
Runtime Error
p03643
Input is given from Standard Input in the following format: N
a=input() print('ABC' +a)
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s713308567
Runtime Error
p03643
Input is given from Standard Input in the following format: N
i = int(input()) print("ABC"i)
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s491669126
Runtime Error
p03643
Input is given from Standard Input in the following format: N
print("ABC{0}".format(intput()))
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s988562948
Runtime Error
p03643
Input is given from Standard Input in the following format: N
print("ABC"+str(input())
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s273116628
Runtime Error
p03643
Input is given from Standard Input in the following format: N
n=input() print('ABC'+n)
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s186335225
Runtime Error
p03643
Input is given from Standard Input in the following format: N
print("ABC"+str(input())
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s341216740
Accepted
p03643
Input is given from Standard Input in the following format: N
num = int(input()) print("ABC{}".format(num))
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s126719880
Accepted
p03643
Input is given from Standard Input in the following format: N
str = input().split() print("ABC" + str[0])
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s300116974
Accepted
p03643
Input is given from Standard Input in the following format: N
#!/usr/bin/python print("ABC" + input().zfill(3))
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s243277493
Accepted
p03643
Input is given from Standard Input in the following format: N
stdin = int(input()) print("ABC" + str(stdin))
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s009083414
Runtime Error
p03643
Input is given from Standard Input in the following format: N
input_N = input() if 100>input_N and 900<input_N; sys.exit() print ('ABC') + input_N
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s893020027
Runtime Error
p03643
Input is given from Standard Input in the following format: N
d = {} n, m = map(int, input().split()) for _ in range(m): i, j = map(int, input().split()) if j in d: d[j].append(i) else: d[j] = [i] flag = 0 if n in d: for item in d[n]: if item in d and 1 in d[item]: flag = 1 break print("POSSIBLE" if flag else "IMPOSSIBLE")
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s661041921
Runtime Error
p03643
Input is given from Standard Input in the following format: N
fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); println!("ABC{}", s.trim()) }
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s244314516
Wrong Answer
p03643
Input is given from Standard Input in the following format: N
#!/usr/bin # -*- coding="utf-8" -*- n = int(input()) if n >= 64: a = 64 elif n >= 32: a = 32 elif n >= 16: a = 16 elif n >= 8: a = 8 elif n >= 4: a = 4 elif n >= 2: a = 2 else: a = 1 print(a)
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s890218588
Runtime Error
p03643
Input is given from Standard Input in the following format: N
N,M = list(map(int,input().split())) path = [[False,False] for i in range(N)] flag=False for i in range(M): a,b = list(map(int,input().split())) if a=N-1: if path[b-1][0]: flag=True path[b-1][1]=True if a=0: if path[b-1][1]: flag=True path[b-1][0]=True if b=N-1: if path[a-1][0]: flag=True path[a-1][1]=True if b=0: if path[a-1][1]: flag=True path[a-1][0]=True if flag: print("POSSIBLE") else: print("IMPOSSIBLE")
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s402254579
Runtime Error
p03643
Input is given from Standard Input in the following format: N
N = int(input()) # res = [x for x in range(1, N + 1)] result = {} # for i in res: for i in range(1, N + 1): result[i] = 0 tmp = i while True: if tmp % 2 == 0: tmp = tmp / 2 result[i] += 1 else: break print(sorted(result.items(), key=lambda x: -x[1])[0][0]
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s407654084
Runtime Error
p03643
Input is given from Standard Input in the following format: N
print('ABC' + input())print('ABC' + input())
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s916616952
Wrong Answer
p03643
Input is given from Standard Input in the following format: N
print("ABC" if 1 <= int(input()) <= 999 else "ABD")
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s052646969
Runtime Error
p03643
Input is given from Standard Input in the following format: N
l = list(map(int, input().split())) print("ABC" + l[0])
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]
Print the abbreviation for the N-th round of ABC. * * *
s429929886
Wrong Answer
p03643
Input is given from Standard Input in the following format: N
"ABC" + input()
Statement 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.
[{"input": "100", "output": "ABC100\n \n\nThe 100th round of ABC is ABC100.\n\n* * *"}, {"input": "425", "output": "ABC425\n \n\n* * *"}, {"input": "999", "output": "ABC999"}]