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 answer in N+1 lines. The i-th line (i = 1, \ldots, N+1) should contain the minimum possible value of S after building railroads for the case K = i-1. * * *
s242907632
Wrong Answer
p02604
Input is given from Standard Input in the following format: N X_1 Y_1 P_1 X_2 Y_2 P_2 : : : X_N Y_N P_N
n = int(input()) xyp = [list(map(int, input().split())) for _ in range(n)] ans = 0 for i in range(3**n): for j in range(n): ans += 1 print(ans)
Statement New AtCoder City has an infinite grid of streets, as follows: * At the center of the city stands a clock tower. Let (0, 0) be the coordinates of this point. * A straight street, which we will call _East-West Main Street_ , runs east-west and passes the clock tower. It corresponds to the x-axis in the two-dimensional coordinate plane. * There are also other infinitely many streets parallel to East-West Main Street, with a distance of 1 between them. They correspond to the lines \ldots, y = -2, y = -1, y = 1, y = 2, \ldots in the two-dimensional coordinate plane. * A straight street, which we will call _North-South Main Street_ , runs north-south and passes the clock tower. It corresponds to the y-axis in the two-dimensional coordinate plane. * There are also other infinitely many streets parallel to North-South Main Street, with a distance of 1 between them. They correspond to the lines \ldots, x = -2, x = -1, x = 1, x = 2, \ldots in the two-dimensional coordinate plane. There are N residential areas in New AtCoder City. The i-th area is located at the intersection with the coordinates (X_i, Y_i) and has a population of P_i. Each citizen in the city lives in one of these areas. **The city currently has only two railroads, stretching infinitely, one along East-West Main Street and the other along North-South Main Street.** M-kun, the mayor, thinks that they are not enough for the commuters, so he decides to choose K streets and build a railroad stretching infinitely along each of those streets. Let the _walking distance_ of each citizen be the distance from his/her residential area to the nearest railroad. M-kun wants to build railroads so that the sum of the walking distances of all citizens, S, is minimized. For each K = 0, 1, 2, \dots, N, what is the minimum possible value of S after building railroads?
[{"input": "3\n 1 2 300\n 3 3 600\n 1 4 800", "output": "2900\n 900\n 0\n 0\n \n\nWhen K = 0, the residents of Area 1, 2, and 3 have to walk the distances of 1,\n3, and 1, respectively, to reach a railroad. \nThus, the sum of the walking distances of all citizens, S, is 1 \\times 300 + 3\n\\times 600 + 1 \\times 800 = 2900.\n\nWhen K = 1, if we build a railroad along the street corresponding to the line\ny = 4 in the coordinate plane, the walking distances of the citizens of Area\n1, 2, and 3 become 1, 1, and 0, respectively. \nThen, S = 1 \\times 300 + 1 \\times 600 + 0 \\times 800 = 900. \nWe have many other options for where we build the railroad, but none of them\nmakes S less than 900.\n\nWhen K = 2, if we build a railroad along the street corresponding to the lines\nx = 1 and x = 3 in the coordinate plane, all citizens can reach a railroad\nwith the walking distance of 0, so S = 0. We can also have S = 0 when K = 3.\n\nThe figure below shows the optimal way to build railroads for the cases K = 0,\n1, 2. \nThe street painted blue represents the roads along which we build railroads.\n\n![](https://img.atcoder.jp/m-solutions2020/fc274bed71a4c37706550fa083496d39.png)\n\n* * *"}, {"input": "5\n 3 5 400\n 5 3 700\n 5 5 1000\n 5 7 700\n 7 5 400", "output": "13800\n 1600\n 0\n 0\n 0\n 0\n \n\nThe figure below shows the optimal way to build railroads for the cases K = 1,\n2.\n\n![](https://img.atcoder.jp/m-solutions2020/7c6b7a31998a1c46fba4c0679b023822.png)\n\n* * *"}, {"input": "6\n 2 5 1000\n 5 2 1100\n 5 5 1700\n -2 -5 900\n -5 -2 600\n -5 -5 2200", "output": "26700\n 13900\n 3200\n 1200\n 0\n 0\n 0\n \n\nThe figure below shows the optimal way to build railroads for the case K = 3.\n\n![](https://img.atcoder.jp/m-solutions2020/0453fa9c2f02c3bd5d5f9e20d0e8e589.png)\n\n* * *"}, {"input": "8\n 2 2 286017\n 3 1 262355\n 2 -2 213815\n 1 -3 224435\n -2 -2 136860\n -3 -1 239338\n -2 2 217647\n -1 3 141903", "output": "2576709\n 1569381\n 868031\n 605676\n 366338\n 141903\n 0\n 0\n 0\n \n\nThe figure below shows the optimal way to build railroads for the case K = 4.\n\n![](https://img.atcoder.jp/m-solutions2020/464ce76d1d7d72638eb372342f8386c5.png)"}]
Print the answer in N+1 lines. The i-th line (i = 1, \ldots, N+1) should contain the minimum possible value of S after building railroads for the case K = i-1. * * *
s713332813
Accepted
p02604
Input is given from Standard Input in the following format: N X_1 Y_1 P_1 X_2 Y_2 P_2 : : : X_N Y_N P_N
n = int(input()) xyp = [list(map(int, input().split())) for i in range(n)] cost = [10**20] * (1 << n) cost[0] = 0 for bitt in range(1, 1 << n): xx = [] yy = [] pp = [] m = 0 for i in range(n): x, y, p = xyp[i] if (1 << i) & bitt: xx.append(x) yy.append(y) pp.append(p) m += 1 for i in range(m): sx = xx[i] anss = 0 for x, y, p in zip(xx, yy, pp): anss += min(abs(y), abs(x), abs(sx - x)) * p cost[bitt] = min(cost[bitt], anss) for j in range(m): sy = yy[j] anss = 0 for x, y, p in zip(xx, yy, pp): anss += min(abs(y), abs(x), abs(sy - y)) * p cost[bitt] = min(cost[bitt], anss) dp = [ sum( min(abs(xyp[i][0]), abs(xyp[i][1])) * xyp[i][2] for i in range(n) if (1 << i) & j ) for j in range(1 << n) ] print(dp[-1]) for j in range(n): for i in range((1 << n) - 1, 0, -1): x = i while x >= 0: x &= i dp[i] = min(dp[i], dp[i - x] + cost[x]) x -= 1 print(dp[-1])
Statement New AtCoder City has an infinite grid of streets, as follows: * At the center of the city stands a clock tower. Let (0, 0) be the coordinates of this point. * A straight street, which we will call _East-West Main Street_ , runs east-west and passes the clock tower. It corresponds to the x-axis in the two-dimensional coordinate plane. * There are also other infinitely many streets parallel to East-West Main Street, with a distance of 1 between them. They correspond to the lines \ldots, y = -2, y = -1, y = 1, y = 2, \ldots in the two-dimensional coordinate plane. * A straight street, which we will call _North-South Main Street_ , runs north-south and passes the clock tower. It corresponds to the y-axis in the two-dimensional coordinate plane. * There are also other infinitely many streets parallel to North-South Main Street, with a distance of 1 between them. They correspond to the lines \ldots, x = -2, x = -1, x = 1, x = 2, \ldots in the two-dimensional coordinate plane. There are N residential areas in New AtCoder City. The i-th area is located at the intersection with the coordinates (X_i, Y_i) and has a population of P_i. Each citizen in the city lives in one of these areas. **The city currently has only two railroads, stretching infinitely, one along East-West Main Street and the other along North-South Main Street.** M-kun, the mayor, thinks that they are not enough for the commuters, so he decides to choose K streets and build a railroad stretching infinitely along each of those streets. Let the _walking distance_ of each citizen be the distance from his/her residential area to the nearest railroad. M-kun wants to build railroads so that the sum of the walking distances of all citizens, S, is minimized. For each K = 0, 1, 2, \dots, N, what is the minimum possible value of S after building railroads?
[{"input": "3\n 1 2 300\n 3 3 600\n 1 4 800", "output": "2900\n 900\n 0\n 0\n \n\nWhen K = 0, the residents of Area 1, 2, and 3 have to walk the distances of 1,\n3, and 1, respectively, to reach a railroad. \nThus, the sum of the walking distances of all citizens, S, is 1 \\times 300 + 3\n\\times 600 + 1 \\times 800 = 2900.\n\nWhen K = 1, if we build a railroad along the street corresponding to the line\ny = 4 in the coordinate plane, the walking distances of the citizens of Area\n1, 2, and 3 become 1, 1, and 0, respectively. \nThen, S = 1 \\times 300 + 1 \\times 600 + 0 \\times 800 = 900. \nWe have many other options for where we build the railroad, but none of them\nmakes S less than 900.\n\nWhen K = 2, if we build a railroad along the street corresponding to the lines\nx = 1 and x = 3 in the coordinate plane, all citizens can reach a railroad\nwith the walking distance of 0, so S = 0. We can also have S = 0 when K = 3.\n\nThe figure below shows the optimal way to build railroads for the cases K = 0,\n1, 2. \nThe street painted blue represents the roads along which we build railroads.\n\n![](https://img.atcoder.jp/m-solutions2020/fc274bed71a4c37706550fa083496d39.png)\n\n* * *"}, {"input": "5\n 3 5 400\n 5 3 700\n 5 5 1000\n 5 7 700\n 7 5 400", "output": "13800\n 1600\n 0\n 0\n 0\n 0\n \n\nThe figure below shows the optimal way to build railroads for the cases K = 1,\n2.\n\n![](https://img.atcoder.jp/m-solutions2020/7c6b7a31998a1c46fba4c0679b023822.png)\n\n* * *"}, {"input": "6\n 2 5 1000\n 5 2 1100\n 5 5 1700\n -2 -5 900\n -5 -2 600\n -5 -5 2200", "output": "26700\n 13900\n 3200\n 1200\n 0\n 0\n 0\n \n\nThe figure below shows the optimal way to build railroads for the case K = 3.\n\n![](https://img.atcoder.jp/m-solutions2020/0453fa9c2f02c3bd5d5f9e20d0e8e589.png)\n\n* * *"}, {"input": "8\n 2 2 286017\n 3 1 262355\n 2 -2 213815\n 1 -3 224435\n -2 -2 136860\n -3 -1 239338\n -2 2 217647\n -1 3 141903", "output": "2576709\n 1569381\n 868031\n 605676\n 366338\n 141903\n 0\n 0\n 0\n \n\nThe figure below shows the optimal way to build railroads for the case K = 4.\n\n![](https://img.atcoder.jp/m-solutions2020/464ce76d1d7d72638eb372342f8386c5.png)"}]
Print the answer in N+1 lines. The i-th line (i = 1, \ldots, N+1) should contain the minimum possible value of S after building railroads for the case K = i-1. * * *
s419473288
Wrong Answer
p02604
Input is given from Standard Input in the following format: N X_1 Y_1 P_1 X_2 Y_2 P_2 : : : X_N Y_N P_N
import sys input = sys.stdin.buffer.readline # sys.setrecursionlimit(10**9) # from functools import lru_cache def RD(): return sys.stdin.read() def II(): return int(input()) def MI(): return map(int, input().split()) def MF(): return map(float, input().split()) def LI(): return list(map(int, input().split())) def LF(): return list(map(float, input().split())) def TI(): return tuple(map(int, input().split())) # rstrip().decode() from itertools import combinations from collections import defaultdict def main(): n = II() dx = [defaultdict(lambda: -1) for _ in range(n)] dy = [defaultdict(lambda: -1) for _ in range(n)] X = [] Y = [] P = [] for _ in range(n): x, y, p = MI() X.append(x) Y.append(y) P.append(p) # print(X,Y,P) for i in range(n): aans = 10**15 a = combinations(range(n), i) for li in list(a): # print(li) for j in range(1 << i): x = [0] y = [0] for k in range(i): if j & 1 << k: x.append(X[li[k]]) else: y.append(Y[li[k]]) # print(i,j,k) # print(x,y) x = tuple(x) y = tuple(y) ans = 0 for ii in range(n): if dx[ii][x] != -1: dxx = dx[ii][x] else: dxx = 10**6 for xx in x: dxx = min(dxx, abs(X[ii] - xx)) dx[ii][x] = dxx if dy[ii][y] != -1: dyy = dy[ii][y] else: dyy = 10**6 for yy in y: dyy = min(dyy, abs(Y[ii] - yy)) dy[ii][y] = dyy ans += P[ii] * min(dxx, dyy) aans = min(aans, ans) print(aans) print(0) if __name__ == "__main__": main()
Statement New AtCoder City has an infinite grid of streets, as follows: * At the center of the city stands a clock tower. Let (0, 0) be the coordinates of this point. * A straight street, which we will call _East-West Main Street_ , runs east-west and passes the clock tower. It corresponds to the x-axis in the two-dimensional coordinate plane. * There are also other infinitely many streets parallel to East-West Main Street, with a distance of 1 between them. They correspond to the lines \ldots, y = -2, y = -1, y = 1, y = 2, \ldots in the two-dimensional coordinate plane. * A straight street, which we will call _North-South Main Street_ , runs north-south and passes the clock tower. It corresponds to the y-axis in the two-dimensional coordinate plane. * There are also other infinitely many streets parallel to North-South Main Street, with a distance of 1 between them. They correspond to the lines \ldots, x = -2, x = -1, x = 1, x = 2, \ldots in the two-dimensional coordinate plane. There are N residential areas in New AtCoder City. The i-th area is located at the intersection with the coordinates (X_i, Y_i) and has a population of P_i. Each citizen in the city lives in one of these areas. **The city currently has only two railroads, stretching infinitely, one along East-West Main Street and the other along North-South Main Street.** M-kun, the mayor, thinks that they are not enough for the commuters, so he decides to choose K streets and build a railroad stretching infinitely along each of those streets. Let the _walking distance_ of each citizen be the distance from his/her residential area to the nearest railroad. M-kun wants to build railroads so that the sum of the walking distances of all citizens, S, is minimized. For each K = 0, 1, 2, \dots, N, what is the minimum possible value of S after building railroads?
[{"input": "3\n 1 2 300\n 3 3 600\n 1 4 800", "output": "2900\n 900\n 0\n 0\n \n\nWhen K = 0, the residents of Area 1, 2, and 3 have to walk the distances of 1,\n3, and 1, respectively, to reach a railroad. \nThus, the sum of the walking distances of all citizens, S, is 1 \\times 300 + 3\n\\times 600 + 1 \\times 800 = 2900.\n\nWhen K = 1, if we build a railroad along the street corresponding to the line\ny = 4 in the coordinate plane, the walking distances of the citizens of Area\n1, 2, and 3 become 1, 1, and 0, respectively. \nThen, S = 1 \\times 300 + 1 \\times 600 + 0 \\times 800 = 900. \nWe have many other options for where we build the railroad, but none of them\nmakes S less than 900.\n\nWhen K = 2, if we build a railroad along the street corresponding to the lines\nx = 1 and x = 3 in the coordinate plane, all citizens can reach a railroad\nwith the walking distance of 0, so S = 0. We can also have S = 0 when K = 3.\n\nThe figure below shows the optimal way to build railroads for the cases K = 0,\n1, 2. \nThe street painted blue represents the roads along which we build railroads.\n\n![](https://img.atcoder.jp/m-solutions2020/fc274bed71a4c37706550fa083496d39.png)\n\n* * *"}, {"input": "5\n 3 5 400\n 5 3 700\n 5 5 1000\n 5 7 700\n 7 5 400", "output": "13800\n 1600\n 0\n 0\n 0\n 0\n \n\nThe figure below shows the optimal way to build railroads for the cases K = 1,\n2.\n\n![](https://img.atcoder.jp/m-solutions2020/7c6b7a31998a1c46fba4c0679b023822.png)\n\n* * *"}, {"input": "6\n 2 5 1000\n 5 2 1100\n 5 5 1700\n -2 -5 900\n -5 -2 600\n -5 -5 2200", "output": "26700\n 13900\n 3200\n 1200\n 0\n 0\n 0\n \n\nThe figure below shows the optimal way to build railroads for the case K = 3.\n\n![](https://img.atcoder.jp/m-solutions2020/0453fa9c2f02c3bd5d5f9e20d0e8e589.png)\n\n* * *"}, {"input": "8\n 2 2 286017\n 3 1 262355\n 2 -2 213815\n 1 -3 224435\n -2 -2 136860\n -3 -1 239338\n -2 2 217647\n -1 3 141903", "output": "2576709\n 1569381\n 868031\n 605676\n 366338\n 141903\n 0\n 0\n 0\n \n\nThe figure below shows the optimal way to build railroads for the case K = 4.\n\n![](https://img.atcoder.jp/m-solutions2020/464ce76d1d7d72638eb372342f8386c5.png)"}]
Print the sum of the shortest distances, modulo 10^9+7. * * *
s973259681
Wrong Answer
p03445
Input is given from Standard Input in the following format: H W N x_1 y_1 x_2 y_2 : x_N y_N
from collections import deque mod = 10**9 + 7 h, w = map(int, input().split()) n = int(input()) ans = 0 black = [] row = [0] * h column = [0] * w for _ in range(n): x, y = map(int, input().split()) row[x] += 1 column[y] += 1 black.append([x, y]) cnt = 0 top = 0 bottom = h * w - n area = [] for i in range(h): if row[i] == 0: cnt += 1 if i != h - 1 and row[i + 1] == 0: top += w bottom -= w ans += top * bottom ans %= mod else: area.append([cnt for _ in range(w)]) else: top += w - row[i] bottom -= w - row[i] area.append([1 for _ in range(w)]) for x, y in black: if x == i: area[-1][y] = 0 cnt = 0 R = len(area) cnt = 0 left = 0 right = h * w - n area2 = [] for j in range(w): if column[j] == 0: cnt += 1 if j != w - 1 and column[j + 1] == 0: left += h right -= h ans += left * right ans %= mod else: area2.append([cnt * area[i][j] for i in range(R)]) else: left += w - column[j] right -= w - column[j] area2.append([area[i][j] for i in range(R)]) cnt = 0 C = len(area2) vec = [[1, 0], [0, 1], [-1, 0], [0, -1]] def bfs(p, q): dist = [[10**9 for _ in range(R)] for __ in range(C)] visited = [[False for _ in range(R)] for __ in range(C)] dist[p][q] = 0 visited[p][q] = True q = deque([(p, q)]) while q: x, y = q.popleft() for dx, dy in vec: if 0 <= x + dx < C and 0 <= y + dy < R and area2[x + dx][y + dy] != 0: if not visited[x + dx][y + dy]: dist[x + dx][y + dy] = dist[x][y] + 1 visited[x + dx][y + dy] = True q.append((x + dx, y + dy)) return dist ans2 = 0 for i in range(C): for j in range(R): d = bfs(i, j) for k in range(C): for l in range(R): ans2 += area2[i][j] * area2[k][l] * d[k][l] ans2 %= mod ans2 *= pow(2, mod - 2, mod) print((ans + ans2) % mod)
Statement You are given an H \times W grid. The square at the top-left corner will be represented by (0, 0), and the square at the bottom-right corner will be represented by (H-1, W-1). Of those squares, N squares (x_1, y_1), (x_2, y_2), ..., (x_N, y_N) are painted black, and the other squares are painted white. Let the shortest distance between white squares A and B be the minimum number of moves required to reach B from A **visiting only white squares** , where one can travel to an adjacent square sharing a side (up, down, left or right) in one move. Since there are H × W - N white squares in total, there are _{(H×W-N)}C_2 ways to choose two of the white squares. For each of these _{(H×W-N)}C_2 ways, find the shortest distance between the chosen squares, then find the sum of all those distances, modulo 1 000 000 007=10^9+7.
[{"input": "2 3\n 1\n 1 1", "output": "20\n \n\nWe have the following grid (`.`: a white square, `#`: a black square).\n\n \n \n ...\n .#.\n \n\nLet us assign a letter to each white square as follows:\n\n \n \n ABC\n D#E\n \n\nThen, we have:\n\n * dist(A, B) = 1\n * dist(A, C) = 2\n * dist(A, D) = 1\n * dist(A, E) = 3\n * dist(B, C) = 1\n * dist(B, D) = 2\n * dist(B, E) = 2\n * dist(C, D) = 3\n * dist(C, E) = 1\n * dist(D, E) = 4\n\nwhere dist(A, B) is the shortest distance between A and B. The sum of these\ndistances is 20.\n\n* * *"}, {"input": "2 3\n 1\n 1 2", "output": "16\n \n\nLet us assign a letter to each white square as follows:\n\n \n \n ABC\n DE#\n \n\nThen, we have:\n\n * dist(A, B) = 1\n * dist(A, C) = 2\n * dist(A, D) = 1\n * dist(A, E) = 2\n * dist(B, C) = 1\n * dist(B, D) = 2\n * dist(B, E) = 1\n * dist(C, D) = 3\n * dist(C, E) = 2\n * dist(D, E) = 1\n\nThe sum of these distances is 16.\n\n* * *"}, {"input": "3 3\n 1\n 1 1", "output": "64\n \n\n* * *"}, {"input": "4 4\n 4\n 0 1\n 1 1\n 2 1\n 2 2", "output": "268\n \n\n* * *"}, {"input": "1000000 1000000\n 1\n 0 0", "output": "333211937"}]
Print the sum of the shortest distances, modulo 10^9+7. * * *
s810414455
Wrong Answer
p03445
Input is given from Standard Input in the following format: H W N x_1 y_1 x_2 y_2 : x_N y_N
print("bandzebo")
Statement You are given an H \times W grid. The square at the top-left corner will be represented by (0, 0), and the square at the bottom-right corner will be represented by (H-1, W-1). Of those squares, N squares (x_1, y_1), (x_2, y_2), ..., (x_N, y_N) are painted black, and the other squares are painted white. Let the shortest distance between white squares A and B be the minimum number of moves required to reach B from A **visiting only white squares** , where one can travel to an adjacent square sharing a side (up, down, left or right) in one move. Since there are H × W - N white squares in total, there are _{(H×W-N)}C_2 ways to choose two of the white squares. For each of these _{(H×W-N)}C_2 ways, find the shortest distance between the chosen squares, then find the sum of all those distances, modulo 1 000 000 007=10^9+7.
[{"input": "2 3\n 1\n 1 1", "output": "20\n \n\nWe have the following grid (`.`: a white square, `#`: a black square).\n\n \n \n ...\n .#.\n \n\nLet us assign a letter to each white square as follows:\n\n \n \n ABC\n D#E\n \n\nThen, we have:\n\n * dist(A, B) = 1\n * dist(A, C) = 2\n * dist(A, D) = 1\n * dist(A, E) = 3\n * dist(B, C) = 1\n * dist(B, D) = 2\n * dist(B, E) = 2\n * dist(C, D) = 3\n * dist(C, E) = 1\n * dist(D, E) = 4\n\nwhere dist(A, B) is the shortest distance between A and B. The sum of these\ndistances is 20.\n\n* * *"}, {"input": "2 3\n 1\n 1 2", "output": "16\n \n\nLet us assign a letter to each white square as follows:\n\n \n \n ABC\n DE#\n \n\nThen, we have:\n\n * dist(A, B) = 1\n * dist(A, C) = 2\n * dist(A, D) = 1\n * dist(A, E) = 2\n * dist(B, C) = 1\n * dist(B, D) = 2\n * dist(B, E) = 1\n * dist(C, D) = 3\n * dist(C, E) = 2\n * dist(D, E) = 1\n\nThe sum of these distances is 16.\n\n* * *"}, {"input": "3 3\n 1\n 1 1", "output": "64\n \n\n* * *"}, {"input": "4 4\n 4\n 0 1\n 1 1\n 2 1\n 2 2", "output": "268\n \n\n* * *"}, {"input": "1000000 1000000\n 1\n 0 0", "output": "333211937"}]
Print the number of the different possible combinations of integers written on the blackboard after Snuke performs the operations, modulo 1,000,000,007. * * *
s801583703
Wrong Answer
p03500
Input is given from Standard Input in the following format: N K A_1 A_2 ... A_N
#!/usr/bin/env python3 M = 10**9 + 7 def solve(n, k, a): a_min = min(a) a_max = max(a) r = 0 i = 0 p = 1 for i in range(k + 1): q_min, q_max = a_min // p, a_max // p if q_min == q_max: if q_min == 0: r += 1 r %= M break else: r += min(q_min - q_min // 2, k - i + 1) r %= M else: b = [v % p for v in a] b.sort() h_max = k - i r += min(q_min, k - i) + 1 r %= M lb = b[0] for j in range(1, n): if lb != b[j]: bj = b[j] c = 0 h = 0 q = p // 2 f = False while 0 < q: if (bj // q) % 2 == 1: c += q h += 1 if (lb // q) % 2 != 1: f = True break elif h == h_max: break q //= 2 if c <= a_min: if f: r += min((a_min - c) // p, k - (i + h)) + 1 r %= M if (a_max - c) // p == 0: return r lb = bj else: continue else: break if q_min == 1 and q_max == 2: break p *= 2 return r def main(): n, k = input().split() n = int(n) k = int(k) a = list(map(int, input().split())) print(solve(n, k, a)) if __name__ == "__main__": main()
Statement There are N non-negative integers written on the blackboard: A_1, ..., A_N. Snuke can perform the following two operations at most K times in total in any order: * Operation A: Replace each integer X on the blackboard with X divided by 2, rounded down to the nearest integer. * Operation B: Replace each integer X on the blackboard with X minus 1. This operation cannot be performed if one or more 0s are written on the blackboard. Find the number of the different possible combinations of integers written on the blackboard after Snuke performs the operations, modulo 1,000,000,007.
[{"input": "2 2\n 5 7", "output": "6\n \n\nThere are six possible combinations of integers on the blackboard: (1, 1), (1,\n2), (2, 3), (3, 5), (4, 6) and (5, 7). For example, (1, 2) can be obtained by\nperforming Operation A and Operation B in this order.\n\n* * *"}, {"input": "3 4\n 10 13 22", "output": "20\n \n\n* * *"}, {"input": "1 100\n 10", "output": "11\n \n\n* * *"}, {"input": "10 123456789012345678\n 228344079825412349 478465001534875275 398048921164061989 329102208281783917 779698519704384319 617456682030809556 561259383338846380 254083246422083141 458181156833851984 502254767369499613", "output": "164286011"}]
Print the number of the different possible combinations of integers written on the blackboard after Snuke performs the operations, modulo 1,000,000,007. * * *
s384858181
Wrong Answer
p03500
Input is given from Standard Input in the following format: N K A_1 A_2 ... A_N
# -*- coding: utf-8 -*- def fun_A(L): A = list(map(int, [x / 2 for x in L])) return A def fun_B(L): A = [x - 1 for x in L] return A def fun_seq(K, func_list): if len(func_list[-1]) >= K: return length = len(func_list[-1]) temp = 2**length for i in func_list[-temp:]: func_list.append(i + "A") func_list.append(i + "B") fun_seq(K, func_list) if __name__ == "__main__": N, K = map(int, input().split()) A = list(map(int, input().split())) func_list = ["A", "B"] fun_seq(K, func_list) # print(len(func_list), func_list) count = 0 for i in func_list: for j in i: if j == "A": A = fun_A(A) if j == "B" and 0 not in A: A = fun_B(A) else: continue count += 1 print(count % 1000000007)
Statement There are N non-negative integers written on the blackboard: A_1, ..., A_N. Snuke can perform the following two operations at most K times in total in any order: * Operation A: Replace each integer X on the blackboard with X divided by 2, rounded down to the nearest integer. * Operation B: Replace each integer X on the blackboard with X minus 1. This operation cannot be performed if one or more 0s are written on the blackboard. Find the number of the different possible combinations of integers written on the blackboard after Snuke performs the operations, modulo 1,000,000,007.
[{"input": "2 2\n 5 7", "output": "6\n \n\nThere are six possible combinations of integers on the blackboard: (1, 1), (1,\n2), (2, 3), (3, 5), (4, 6) and (5, 7). For example, (1, 2) can be obtained by\nperforming Operation A and Operation B in this order.\n\n* * *"}, {"input": "3 4\n 10 13 22", "output": "20\n \n\n* * *"}, {"input": "1 100\n 10", "output": "11\n \n\n* * *"}, {"input": "10 123456789012345678\n 228344079825412349 478465001534875275 398048921164061989 329102208281783917 779698519704384319 617456682030809556 561259383338846380 254083246422083141 458181156833851984 502254767369499613", "output": "164286011"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s331122487
Accepted
p03150
Input is given from Standard Input in the following format: S
def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left, bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil, pi, factorial from operator import itemgetter def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def LI2(): return [int(input()) for i in range(n)] def MXI(): return [[LI()] for i in range(n)] def SI(): return input().rstrip() def printns(x): print("\n".join(x)) def printni(x): print("\n".join(list(map(str, x)))) inf = 10**17 mod = 10**9 + 7 # main code here! s = SI() n = len(s) for i in range(8): s1 = s[:i] s2 = s[n + i - 7 :] if s1 + s2 == "keyence": print("YES") exit() print("NO") if __name__ == "__main__": main()
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s996978817
Wrong Answer
p03150
Input is given from Standard Input in the following format: S
import sys import heapq import re from itertools import permutations from bisect import bisect_left, bisect_right from collections import Counter, deque from fractions import gcd from math import factorial, sqrt, ceil from functools import lru_cache, reduce INF = 1 << 60 MOD = 1000000007 sys.setrecursionlimit(10**7) # UnionFind class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): return {r: self.members(r) for r in self.roots()} def __str__(self): return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots()) # ダイクストラ def dijkstra_heap(s, edge, n): # 始点sから各頂点への最短距離 d = [10**20] * n used = [True] * n # True:未確定 d[s] = 0 used[s] = False edgelist = [] for a, b in edge[s]: heapq.heappush(edgelist, a * (10**6) + b) while len(edgelist): minedge = heapq.heappop(edgelist) # まだ使われてない頂点の中から最小の距離のものを探す if not used[minedge % (10**6)]: continue v = minedge % (10**6) d[v] = minedge // (10**6) used[v] = False for e in edge[v]: if used[e[1]]: heapq.heappush(edgelist, (e[0] + d[v]) * (10**6) + e[1]) return d # 素因数分解 def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr == []: arr.append([n, 1]) return arr # 2数の最小公倍数 def lcm(x, y): return (x * y) // gcd(x, y) # リストの要素の最小公倍数 def lcm_list(numbers): return reduce(lcm, numbers, 1) # リストの要素の最大公約数 def gcd_list(numbers): return reduce(gcd, numbers) # 素数判定 def is_prime(n): if n <= 1: return False p = 2 while True: if p**2 > n: break if n % p == 0: return False p += 1 return True # limit以下の素数を列挙 def eratosthenes(limit): A = [i for i in range(2, limit + 1)] P = [] while True: prime = min(A) if prime > sqrt(limit): break P.append(prime) i = 0 while i < len(A): if A[i] % prime == 0: A.pop(i) continue i += 1 for a in A: P.append(a) return P # 同じものを含む順列 def permutation_with_duplicates(L): if L == []: return [[]] else: ret = [] # set(集合)型で重複を削除、ソート S = sorted(set(L)) for i in S: data = L[:] data.remove(i) for j in permutation_with_duplicates(data): ret.append([i] + j) return ret # ここから書き始める s = input() x = "keyence" yes = False for i in range(8): left = x[:i] right = x[i:] # print("left =", left) # print("right =", right) l = s.find(left) r = s.find(right) if l != -1 and r != -1 and l + len(left) <= r: # print(l, r) yes = True break if yes: print("YES") else: print("NO")
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s656786482
Wrong Answer
p03150
Input is given from Standard Input in the following format: S
import re s = input() pat = ( "\w*" + "k" + "\w*" + "e" + "\w*" + "y" + "\w*" + "e" + "\w*" + "n" + "\w*" + "c" + "\w*" + "e" + "\w*" ) if re.match: print("YES") else: print("NO")
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s419091606
Runtime Error
p03150
Input is given from Standard Input in the following format: S
# coding:utf-8 s = input() for i in range(n := len(s)) if s[:i] + s[n-7+i:] == 'keyence': print('YES') exit() print('NO')
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s656669809
Runtime Error
p03150
Input is given from Standard Input in the following format: S
def main(): S = input() if S[0] != 'k': return ('NO') elif S = 'keyence': return ('YES') ans = 'keyence' i = 0 j = 0 while True: i += 1 j += 1 if S[i] != ans[j]: break #残りの文字数 num = 7-j cnt = 0 while cnt < num: cnt += 1 #print(ans[-cnt]) if S[-cnt] != ans[-cnt]: return ('NO') return ('YES') print(main())
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s602913367
Wrong Answer
p03150
Input is given from Standard Input in the following format: S
# _*_ coding:utf-8 _*_ # Atcoder_KeyencePrograming_Contest-B # TODO https://keyence2019.contest.atcoder.jp/tasks/keyence2019_b import re def solveProblem(inputStr): pattern1 = r".*keyence" pattern2 = r"k.*eyence" pattern3 = r"ke.*yence" pattern4 = r"key.*ence" pattern5 = r"keye.*nce" pattern6 = r"keyen.*ce" pattern7 = r"keyenc.*e" pattern8 = r"keyence.*" matchOB1 = re.search(pattern1, inputStr) matchOB2 = re.search(pattern2, inputStr) matchOB3 = re.search(pattern3, inputStr) matchOB4 = re.search(pattern4, inputStr) matchOB5 = re.search(pattern5, inputStr) matchOB6 = re.search(pattern6, inputStr) matchOB7 = re.search(pattern7, inputStr) matchOB8 = re.search(pattern8, inputStr) if matchOB1 != None: return "YES" if matchOB2 != None: return "YES" if matchOB3 != None: return "YES" if matchOB4 != None: return "YES" if matchOB5 != None: return "YES" if matchOB6 != None: return "Yes" if matchOB7 != None: return "YES" if matchOB8 != None: return "YES" return "NO" if __name__ == "__main__": S = input().strip() solution = solveProblem(S) print("{}".format(solution))
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s945813921
Runtime Error
p03150
Input is given from Standard Input in the following format: S
s = input() search="keyence" idx=0 flg = False ans="NO" if s.find(search)>=0: print("YES") elif: for i in range(7): x=s.find(search[0:i+1]) print("ps=%s, ns=%s, reduce=%s" %(search[0:i+1], search[i+1:], s[x+i+1:])) if x == -1: break if x == 0: if s[x+i:].find(search[i+1:])>=0: ans = "YES" break print(ans)
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s857517364
Runtime Error
p03150
Input is given from Standard Input in the following format: S
S=input() ans='NO' if 'keyence'in S: ans='YES' elif S.find('k')>=0 and S.find('k')<S.rfind('eyence'): ans='YES' elif S.find('ke')>=0 and S.find('ke')<S.rfind('yence'): ans='YES' elif S.find('key')>=0 and S.find('key')<S.rfind('ence'): ans='YES elif S.find('keye')>=0 and S.find('keye')<S.rfind('nce'): ans='YES' elif S.find('keyen')>=0 and S.find('keyen')<S.rfind('ce'): ans='YES' elif S.find('keyenc')>=0 and S.find('keyenc')<S.rfind('e'): ans='YES' print(ans)
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s642518615
Runtime Error
p03150
Input is given from Standard Input in the following format: S
#include <iostream> #include <vector> #include <algorithm> #include <utility> #include <string> #include <queue> #include <stack> using namespace std; typedef long long int ll; typedef pair<int, int> Pii; const ll mod = 1000000007; int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int n = s.length(); string keyence = "keyence"; int p = 0; for (int i = 0; i < 7; i++) { if (s[i] == keyence[p]) p++; else break; } for (int i = n-7+p; i < n; i++) { if (s[i] == keyence[p]) p++; else break; } if (p == 7) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s158540650
Runtime Error
p03150
Input is given from Standard Input in the following format: S
s=str(input()) st=list(s) l=len(st) if st[0]="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" st[4]=="n" and st[5]=="c" and st[6]=="e": print("YES") elif st[l-7]="k" and st[l-6]=="e" and st[l-5]=="y" and st[l-4]=="e" st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e": print("YES") elif st[0]="k" and st[l-6]=="e" and st[l-5]=="y" and st[l-4]=="e" st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e": print("YES") elif st[0]="k" and st[1]=="e" and st[l-5]=="y" and st[l-4]=="e" st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e": print("YES") elif st[0]="k" and st[1]=="e" and st[2]=="y" and st[l-4]=="e" st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e": print("YES") elif st[0]="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e": print("YES") elif st[0]="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" st[4]=="n" and st[l-2]=="c" and st[l-1]=="e": print("YES") elif st[0]="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" st[4]=="n" and st[5]=="c" and st[l-1]=="e": print("YES") else: ptint("NO")
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s580833703
Runtime Error
p03150
Input is given from Standard Input in the following format: S
S = input() target = "keyence" length = len(target) for i in range(length): first = target[:i] second = target[i:] if first == '' and second in S or first != '' first in S and second in S and S.find(first) <= S.find(second): print("YES") exit() print("NO")
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s683139517
Accepted
p03150
Input is given from Standard Input in the following format: S
s = str(input()) st = list(s) l = len(st) if ( st[0] == "k" and st[1] == "e" and st[2] == "y" and st[3] == "e" and st[4] == "n" and st[5] == "c" and st[6] == "e" ): print("YES") elif ( st[l - 7] == "k" and st[l - 6] == "e" and st[l - 5] == "y" and st[l - 4] == "e" and st[l - 3] == "n" and st[l - 2] == "c" and st[l - 1] == "e" ): print("YES") elif ( st[0] == "k" and st[l - 6] == "e" and st[l - 5] == "y" and st[l - 4] == "e" and st[l - 3] == "n" and st[l - 2] == "c" and st[l - 1] == "e" ): print("YES") elif ( st[0] == "k" and st[1] == "e" and st[l - 5] == "y" and st[l - 4] == "e" and st[l - 3] == "n" and st[l - 2] == "c" and st[l - 1] == "e" ): print("YES") elif ( st[0] == "k" and st[1] == "e" and st[2] == "y" and st[l - 4] == "e" and st[l - 3] == "n" and st[l - 2] == "c" and st[l - 1] == "e" ): print("YES") elif ( st[0] == "k" and st[1] == "e" and st[2] == "y" and st[3] == "e" and st[l - 3] == "n" and st[l - 2] == "c" and st[l - 1] == "e" ): print("YES") elif ( st[0] == "k" and st[1] == "e" and st[2] == "y" and st[3] == "e" and st[4] == "n" and st[l - 2] == "c" and st[l - 1] == "e" ): print("YES") elif ( st[0] == "k" and st[1] == "e" and st[2] == "y" and st[3] == "e" and st[4] == "n" and st[5] == "c" and st[l - 1] == "e" ): print("YES") else: print("NO")
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s315068631
Runtime Error
p03150
Input is given from Standard Input in the following format: S
S = list(input()) if "k" and "e" and "y" and "e" and "n" and "c" and "e" in S: for i in range(len(S)): if S[i] == "k": if S[i + 1] == "e": if S[i + 2] == "y": if S[i + 3] == "e": if S[i + 4] == "n": if S[i + 5] == "c": if S[i + 6] == "e": print("YES") break else: if S[-1] == "e": print("YES") break else: print("No") break else: if S[-1] == "e" and S[-2] == "c": print("YES") break else: for j in range(len(S) - i - 5): if S[i + 5 + j] == "c": if S[i + 5 + j + 1] == "e": if i + 5 + j + 2 == len(S): print("YES") break else: print("NO") break else: print("NO") break else: if S[-1] == "e" and S[-2] == "c" and S[-3] == "n": print("YES") break else: for j in range(len(S) - i - 4): if S[i + 4 + j] == "n": if S[i + 4 + j + 1] == "c": if S[i + 4 + j + 2] == "e": if i + 4 + j + 3 == len(S): print("YES") break else: print("NO") break else: print("NO") break else: print("NO") break else: if ( S[-1] == "e" and S[-2] == "c" and S[-3] == "n" and S[-4] == "e" ): print("YES") break else: for j in range(len(S) - i - 3): if S[i + 3 + j] == "e": if S[i + 3 + j + 1] == "n": if S[i + 3 + j + 2] == "c": if S[i + 3 + j + 3] == "e": if i + 3 + j + 4 == len(S): print("YES") break else: print("NO") break else: print("NO") break else: print("NO") break else: print("NO") break else: if ( S[-1] == "e" and S[-2] == "c" and S[-3] == "n" and S[-4] == "e" and S[-5] == "y" ): print("YES") break else: for j in range(len(S) - i - 2): if S[i + 2 + j] == "y": if S[i + 2 + j + 1] == "e": if S[i + 2 + j + 2] == "n": if S[i + 2 + j + 3] == "c": if S[i + 2 + j + 4] == "e": if i + 2 + j + 5 == len(S): print("YES") break else: print("NO") break else: print("NO") break else: print("NO") break else: print("NO") break else: print("NO") break else: if ( S[-1] == "e" and S[-2] == "c" and S[-3] == "n" and S[-4] == "e" and S[-5] == "y" and S[-6] == "e" ): print("YES") break else: for j in range(len(S) - i - 1): if S[i + 1 + j] == "e": if S[i + 1 + j + 1] == "y": if S[i + 1 + j + 2] == "e": if S[i + 1 + j + 3] == "n": if S[i + 1 + j + 4] == "c": if S[i + 1 + j + 5] == "e": if i + 1 + j + 6 == len(S): print("YES") break else: print("NO") break else: print("NO") break else: print("NO") break else: print("NO") break else: print("NO") break else: print("NO") break else: print("NO")
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s484023755
Accepted
p03150
Input is given from Standard Input in the following format: S
def resolve(): """ code here """ S = input() is_flag = False key = "keyence" for i in range(8): if i == 0: if S[-7:] == key: is_flag = True elif 1 <= i < 7: if S[:i] == key[:i] and S[-1 * (7 - i) :] == key[-1 * (7 - i) :]: is_flag = True else: if S[:7] == key: is_flag = True print("YES") if is_flag else print("NO") if __name__ == "__main__": resolve()
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s574329974
Wrong Answer
p03150
Input is given from Standard Input in the following format: S
S = input() res = "NO" for s in range(len(S)): for t in range(len(S) - s): if S[:s] + S[t:] == "keyence": res = "YES" print(res)
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s627192198
Wrong Answer
p03150
Input is given from Standard Input in the following format: S
S = input() tgt = "keyence" res = S == tgt for i in range(len(S) - 6): T = S[:i] + S[-7 + i :] # print(T) if T == tgt: res = True print("YES" if res else "NO")
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s779069457
Accepted
p03150
Input is given from Standard Input in the following format: S
s = list(input()) if s[0] == "k": li = [] for i in range(6): li.append(s[len(s) - (6 - i)]) if "".join(li) == "eyence": print("YES") quit() if s[0] + s[1] == "ke": li = [] for i in range(5): li.append(s[len(s) - (5 - i)]) if "".join(li) == "yence": print("YES") quit() if s[0] + s[1] + s[2] == "key": li = [] for i in range(4): li.append(s[len(s) - (4 - i)]) if "".join(li) == "ence": print("YES") quit() if s[0] + s[1] + s[2] + s[3] == "keye": li = [] for i in range(3): li.append(s[len(s) - (3 - i)]) if "".join(li) == "nce": print("YES") quit() if s[0] + s[1] + s[2] + s[3] + s[4] == "keyen": li = [] for i in range(2): li.append(s[len(s) - (2 - i)]) if "".join(li) == "ce": print("YES") quit() if s[0] + s[1] + s[2] + s[3] + s[4] + s[5] == "keyenc": if s[len(s) - 1] == "e": print("YES") quit() lis = [] for i in range(7): lis.append(s[len(s) - i - 1]) if "".join(lis) == "keyence": print("YES") quit() print("NO")
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s844816205
Wrong Answer
p03150
Input is given from Standard Input in the following format: S
S = input() S = S.replace("keyence", "A") if S == "A": print("YES") exit() elif S[0] == "A" and S[len(S) - 1] != "A": print("YES") exit() elif S[len(S) - 1] == "A": print("YES") exit() S1 = S.replace("K", "A") S1 = S1[::-1] S1 = S1.replace("ecneye", "B") S1 = S1[::-1] if S1[0] == "A" and S1[len(S1) - 1] == "B": print("YES") exit() S2 = S.replace("Ke", "A") S2 = S2[::-1] S2 = S2.replace("ecney", "B") S2 = S2[::-1] if S2[0] == "A" and S2[len(S2) - 1] == "B": print("YES") exit() S3 = S.replace("Key", "A") S3 = S3[::-1] S3 = S3.replace("ecne", "B") S3 = S3[::-1] if S3[0] == "A" and S3[len(S3) - 1] == "B": print("YES") exit() S4 = S.replace("Keye", "A") S4 = S4[::-1] S4 = S4.replace("ecn", "B") S4 = S4[::-1] if S4[0] == "A" and S4[len(S4) - 1] == "B": print("YES") exit() S5 = S.replace("Keyen", "A") S5 = S5[::-1] S5 = S5.replace("ec", "B") S5 = S5[::-1] if S5[0] == "A" and S5[len(S5) - 1] == "B": print("YES") exit() S6 = S.replace("Keyenc", "A") S6 = S6.replace("e", "B") if S6[0] == "A" and S6[len(S6) - 1] == "B": print("YES") exit() print("NO")
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
If S is a KEYENCE string, print `YES`; otherwise, print `NO`. * * *
s424613060
Wrong Answer
p03150
Input is given from Standard Input in the following format: S
def my_index(l, x, default=False): if x in l: return l.index(x) else: return -1 a = input().split("!!!") a = list(a[0]) judge = 0 count = 0 tmp1 = 0 tmp2 = 0 A = [] B = [] A.append(my_index(a, "k")) tmp1 = my_index(a, "k") if my_index(a, "k") != -1: a[my_index(a, "k")] = "AAA" judge += 1 A.append(my_index(a, "e")) tmp2 = my_index(a, "e") if my_index(a, "e") != -1: a[my_index(a, "e")] = "AAA" judge += 1 if tmp2 - tmp1 >= 2: count += 1 tmp1 = tmp2 A.append(my_index(a, "y")) tmp2 = my_index(a, "y") if my_index(a, "y") != -1: a[my_index(a, "y")] = "AAA" judge += 1 if tmp2 - tmp1 >= 2: count += 1 tmp1 = tmp2 A.append(my_index(a, "e")) tmp2 = my_index(a, "e") if my_index(a, "e") != -1: a[my_index(a, "e")] = "AAA" judge += 1 if tmp2 - tmp1 >= 2: count += 1 tmp1 = tmp2 A.append(my_index(a, "n")) tmp2 = my_index(a, "n") if my_index(a, "n") != -1: a[my_index(a, "n")] = "AAA" judge += 1 if tmp2 - tmp1 >= 2: count += 1 tmp1 = tmp2 A.append(my_index(a, "c")) tmp2 = my_index(a, "c") if my_index(a, "c") != -1: a[my_index(a, "c")] = "AAA" judge += 1 if tmp2 - tmp1 >= 2: count += 1 tmp1 = tmp2 A.append(my_index(a, "e")) tmp2 = my_index(a, "e") if my_index(a, "e") != -1: a[my_index(a, "e")] = "AAA" judge += 1 if tmp2 - tmp1 >= 2: count += 1 tmp1 = tmp2 B = A A.sort() if (A == B) and (judge == 7) and (count <= 2): print("YES") else: print("NO")
Statement A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
[{"input": "keyofscience", "output": "YES\n \n\n`keyence` is an abbreviation of `key of science`.\n\n* * *"}, {"input": "mpyszsbznf", "output": "NO\n \n\n* * *"}, {"input": "ashlfyha", "output": "NO\n \n\n* * *"}, {"input": "keyence", "output": "YES"}]
Print the K-th element. * * *
s885666443
Wrong Answer
p02741
Input is given from Standard Input in the following format: K
s = input() print(s[0:4] + " " + s[4:12])
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s837826497
Runtime Error
p02741
Input is given from Standard Input in the following format: K
n = list(map(int, input().split())) print((n[0] * n[1] + 1) // 2)
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s620431631
Wrong Answer
p02741
Input is given from Standard Input in the following format: K
print(5)
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s230992095
Wrong Answer
p02741
Input is given from Standard Input in the following format: K
N = int(input()) mojis = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] def append_m(moji): arr = [] for i in mojis[: len(set(moji)) + 1]: arr.append(moji + i) return arr arr = ["a"] for i in range(N - 1): tmp = [] for j in arr: tmp += append_m(j) arr = tmp for i in arr: print(i)
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s706732177
Runtime Error
p02741
Input is given from Standard Input in the following format: K
a = list(input()) b = list(input()) c = list(input()) A, B, C = map(len, (a, b, c)) OFFSET = 4000 L = 8001 ab = [True] * L ac = [True] * L bc = [True] * L for i in range(A): for j in range(B): if a[i] != b[j] and a[i] != "?" and b[j] != "?": ab[i - j + OFFSET] = False # BをAからi-jずらした時を考える for i in range(A): for j in range(C): if a[i] != c[j] and a[i] != "?" and c[j] != "?": ac[i - j + OFFSET] = False # CをAからi-jずらした時を考える for i in range(B): for j in range(C): if b[i] != c[j] and c[i] != "?" and b[j] != "?": bc[i - j + OFFSET] = False # CをBからi-jずらした時を考える ans = float("inf") for i in range(L): # Bの左端をずらす for j in range(L): # Cの左端をずらす k = j - i + OFFSET if k >= L or k < 0: continue if ab[i] and ac[j] and bc[k]: head = min(i, j, OFFSET) tail = max(A + OFFSET, B + i, C + j) ans = min(ans, tail - head) print(ans)
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s120124488
Wrong Answer
p02741
Input is given from Standard Input in the following format: K
from string import ascii_lowercase N = int(input()) ans = ["a"] for i in range(1, N): ans2 = [] for a in ans: for b in ascii_lowercase[: len(set(a)) + 1]: ans2 += [a + b] ans = ans2 print("\n".join(ans))
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s880274536
Runtime Error
p02741
Input is given from Standard Input in the following format: K
alp = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] N = int(input()) ans_list = [] for i in range(N): ans_list.append([]) for i in range(N): if i == 0: ans_list[i].append(["a", 1]) else: for j in range(len(ans_list[i - 1])): for l in range(ans_list[i - 1][j][1] + 1): temp = ans_list[i - 1][j][0] + alp[l] if l == ans_list[i - 1][j][1]: chk = ans_list[i - 1][j][1] + 1 else: chk = ans_list[i - 1][j][1] ans_list[i].append([temp, chk]) for i in range(len(ans_list[N - 1])): print(ans_list[N - 1][i][0])
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s189703424
Runtime Error
p02741
Input is given from Standard Input in the following format: K
a = input() a_l = len(a) b = input() b_l = len(b) c = input() c_l = len(c) def check(s1, s2): l1 = len(s1) l2 = len(s2) ret = [0] * (l1 + l2 - 1) for i in range(l1 + l2 - 1): flag = True if i - l2 + 1 < 0: for j in range(i + 1): if ( s1[j] != "?" and s2[l2 - i + j - 1] != "?" and s1[j] != s2[l2 - i + j - 1] ): flag = False break elif i - l2 + 1 >= 0 and i <= l1 - 1: for j in range(l2): if ( s1[i - l2 + j + 1] != "?" and s2[j] != "?" and s1[i - l2 + j + 1] != s2[j] ): flag = False break else: for j in range(l1 + l2 - i - 1): if ( s1[i - l2 + j + 1] != "?" and s2[j] != "?" and s1[i - l2 + j + 1] != s2[j] ): flag = False break ret[i] = flag return ret ab = check(a, b) ab_l = len(ab) ac = check(a, c) ac_l = len(ac) bc = check(b, c) bc_l = len(bc) ans = a_l + b_l + c_l for i in range(-3000, ab_l + 3000): if i < 0 or i >= ab_l or ab[i]: for j in range(-3000, ac_l + 3000): if j < 0 or j >= ac_l or ac[j]: if ( (0 <= j - i + b_l + 1 < bc_l and bc[j - i + b_l + 1]) or j - i + b_l + 1 < 0 or j - i + b_l + 1 >= bc_l ): l = max(a_l - 1, i, j) - min(0, i - b_l + 1, j - c_l + 1) + 1 ans = min(ans, l) print(ans)
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s080450355
Runtime Error
p02741
Input is given from Standard Input in the following format: K
def main(): a = input() b = input() c = input() A, B, C = len(a), len(b), len(c) ab = [True] * 10000 ac = [True] * 10000 bc = [True] * 10000 def check(c1, c2): if c1 == "?" or c2 == "?" or c1 == c2: return False return True for i in range(A): for j in range(B): if check(a[i], b[j]): ab[i - j + 5000] = False for i in range(A): for j in range(C): if check(a[i], c[j]): ac[i - j + 5000] = False for i in range(B): for j in range(C): if check(b[i], c[j]): bc[i - j + 5000] = False ans = A + B + C for i in range(-(B + C), A + C): for j in range(-(B + C), A + B): if ab[i + 5000] and ac[j + 5000] and bc[j - i + 5000]: L = min(0, i, j) R = max(A, i + B, j + C) ans = min(ans, R - L) print(ans) main()
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s689612841
Runtime Error
p02741
Input is given from Standard Input in the following format: K
a = input() b = input() c = input() def common(s1, s2): l1 = len(s1) l2 = len(s2) memo = [[0 for i in range(l1 + 2)] for j in range(l2 + 2)] for idx1, w1 in enumerate(s1): for idx2, w2 in enumerate(s2): if w1 == w2 or w1 == "?" or w2 == "?": memo[idx2 + 1][idx1 + 1] = memo[idx2][idx1] + 1 return memo m1 = 0 m2 = 0 m3 = 0 for l in common(a, b): if max(l) > m1: m1 = max(l) for l in common(a, c): if max(l) > m2: m2 = max(l) for l in common(b, c): if max(l) > m3: m3 = max(l) ans = len(a) + len(b) + len(c) - m1 - m2 - m3 + min([m1, m2, m3]) print(ans)
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s182551652
Accepted
p02741
Input is given from Standard Input in the following format: K
print(b" 3   "[int(input()) % 14])
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s006927210
Runtime Error
p02741
Input is given from Standard Input in the following format: K
H, W = map(int, input().split()) if H % 2 != 0: H = H + 1 if W % 2 != 0: W = W + 1 print(int(H * W / 2))
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s944812549
Runtime Error
p02741
Input is given from Standard Input in the following format: K
retu = input() print(int(retu.split(",")[32]))
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s428982842
Runtime Error
p02741
Input is given from Standard Input in the following format: K
x = list(map(int, input().split())) y = int(input()) print(x)
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s110126828
Wrong Answer
p02741
Input is given from Standard Input in the following format: K
1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s041167222
Accepted
p02741
Input is given from Standard Input in the following format: K
K = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51" k = map(int, K.split(",")) A = list(k) B = int(input()) print(A[B - 1])
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s530254235
Runtime Error
p02741
Input is given from Standard Input in the following format: K
retu = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51" retu = retu.split(",") retuint = [] for i in retu: retuint.append(int(i)) index = input() print(retuint[int(index - 1)])
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s391268839
Runtime Error
p02741
Input is given from Standard Input in the following format: K
text = "1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51" textList = text.split(",") firstInputText = input() print(textList[int(firstInputText) - 1]) secondInputText = input() print(textList[int(secondInputText) - 1])
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s647805822
Runtime Error
p02741
Input is given from Standard Input in the following format: K
[H, W] = map(int, input().split()) if (H * W) % 2 == 0: B = int((H * W) / 2) print(B) else: if (H + W) % 2 == 0: C = int((H * W + 1) / 2) print(C) else: D = int((H * W - 1) / 2) print(D)
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the K-th element. * * *
s709150620
Runtime Error
p02741
Input is given from Standard Input in the following format: K
a, b = map(int, input().split()) c = len([i for i in range(1, a + 1) if i % 2 == 0]) d = len([i for i in range(1, a + 1) if i % 2 != 0]) e = len([i for i in range(1, b + 1) if i % 2 == 0]) f = len([i for i in range(1, b + 1) if i % 2 != 0]) if a % 2 == 0 and b % 2 == 0: print((a * b) // 2) elif a % 2 == 0 and b % 2 != 0: print((a // 2) * b) elif a % 2 != 0 and b == 0: print((b // 2) * a) else: print(d * f + c * e)
Statement Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
[{"input": "6", "output": "2\n \n\nThe 6-th element is 2.\n\n* * *"}, {"input": "27", "output": "5\n \n\nThe 27-th element is 5."}]
Print the extended image. * * *
s550160455
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
h,w=map(int,input().split()) a=[] for i in range(h) a.append(input().split()) for i in range(h) print(" ".join(a[i])) print(" ".join(a[i]))
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s236717882
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
H, W = map(int, input().split()) X = [list(input().split()) for i in range(H)] for i in range(2 * N): print(*X[int(i / 2)])
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s547527786
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
h,w=map(int,input().split()) a=[] for i range(h): a.append=list(map(list,input().split())) a.append=list(map(list,input().split())) print(a)
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s129250514
Accepted
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
N, H = map(int, input().split()) S = list(input() for i in range(N)) for k in range(N): for u in range(2): print(S[k])
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s268795463
Accepted
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
#!/usr/bin/env python3 import sys # import time # import math # import numpy as np # import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall # import random # random, uniform, randint, randrange, shuffle, sample # import string # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits # import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s) # from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]). # from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate() # from collections import defaultdict # subclass of dict. defaultdict(facroty) # from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter) # from datetime import date, datetime # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj # from datetime.datetime import strptime # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj # from datetime import timedelta # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available. # from copy import copy, deepcopy # use deepcopy to copy multi-dimentional matrix without reference # from functools import reduce # reduce(f, iter[, init]) # from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed) # from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn). # from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn). # from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n]) # from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])] # from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9] # from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r]) # from itertools import combinations, combinations_with_replacement # from itertools import accumulate # accumulate(iter[, f]) # from operator import itemgetter # itemgetter(1), itemgetter('key') # from fractions import gcd # for Python 3.4 (previous contest @AtCoder) def main(): mod = 1000000007 # 10^9+7 inf = float("inf") # sys.float_info.max = 1.79...e+308 # inf = 2 ** 64 - 1 # (for fast JIT compile in PyPy) 1.84...e+19 sys.setrecursionlimit(10**6) # 1000 -> 1000000 def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def mi(): return map(int, input().split()) def mi_0(): return map(lambda x: int(x) - 1, input().split()) def lmi(): return list(map(int, input().split())) def lmi_0(): return list(map(lambda x: int(x) - 1, input().split())) def li(): return list(input()) h, w = mi() for _ in range(h): s = input() print(s) print(s) if __name__ == "__main__": main()
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s165997740
Accepted
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
import sys sys.setrecursionlimit(10**7) # 再帰関数の上限,10**5以上の場合python import math from copy import copy, deepcopy from copy import deepcopy as dcp from operator import itemgetter from bisect import bisect_left, bisect, bisect_right # 2分探索 # bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下 from collections import deque, defaultdict # deque(l), pop(), append(x), popleft(), appendleft(x) # q.rotate(n)で → にn回ローテート from collections import Counter # 文字列を個数カウント辞書に、 # S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items() from itertools import accumulate, combinations, permutations # 累積和 # list(accumulate(l)) from heapq import heapify, heappop, heappush # heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone # import fractions#古いatcoderコンテストの場合GCDなどはここからimportする from functools import reduce, lru_cache # pypyでもうごく # @lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率 from decimal import Decimal def input(): x = sys.stdin.readline() return x[:-1] if x[-1] == "\n" else x def printe(*x): print("## ", *x, file=sys.stderr) def printl(li): _ = print(*li, sep="\n") if li else None def argsort(s, return_sorted=False): inds = sorted(range(len(s)), key=lambda k: s[k]) if return_sorted: return inds, [s[i] for i in inds] return inds def alp2num(c, cap=False): return ord(c) - 97 if not cap else ord(c) - 65 def num2alp(i, cap=False): return chr(i + 97) if not cap else chr(i + 65) def matmat(A, B): K, N, M = len(B), len(A), len(B[0]) return [ [sum([(A[i][k] * B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N) ] def matvec(M, v): N, size = len(v), len(M) return [sum([M[i][j] * v[j] for j in range(N)]) for i in range(size)] def T(M): n, m = len(M), len(M[0]) return [[M[j][i] for j in range(n)] for i in range(m)] def main(): mod = 1000000007 # w.sort(key=itemgetter(1),reversed=True) #二個目の要素で降順並び替え # N = int(input()) H, W = map(int, input().split()) # A = tuple(map(int, input().split())) #1行ベクトル # L = tuple(int(input()) for i in range(N)) #改行ベクトル S = list(tuple(input()) for i in range(H)) # 改行行列 for li in S: print(*li, sep="") print(*li, sep="") if __name__ == "__main__": main()
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s340580578
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
h,w = map(int,input().split()) li = [input() for _ in range(h)] for i in li: print(i,i,sep="\n")***.
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s976906103
Accepted
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
# from math import factorial,sqrt,ceil,gcd # from itertools import permutations as permus # from collections import deque,Counter # import re # from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000) # from decimal import Decimal, getcontext # # getcontext().prec = 1000 # # eps = Decimal(10) ** (-100) # import numpy as np # import networkx as nx # from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson # from scipy.sparse import csr_matrix # from scipy.special import comb # slist = "abcdefghijklmnopqrstuvwxyz" # 盤面の受け取り H, W = map(int, input().split()) board = [[] for _ in range(H * 2)] for i in range(H): board[2 * i] = list(input()) board[2 * i + 1] = board[2 * i].copy() # print(*ans) # unpackして出力。間にスペースが入る for row in board: print(*row, sep="") # unpackして間にスペース入れずに出力する # print("{:.10f}".format(ans)) # print("{:0=10d}".format(ans))
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s648317022
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
# # abc049 b # import sys from io import StringIO import unittest class TestClass(unittest.TestCase): def assertIO(self, input, output): stdout, stdin = sys.stdout, sys.stdin sys.stdout, sys.stdin = StringIO(), StringIO(input) resolve() sys.stdout.seek(0) out = sys.stdout.read()[:-1] sys.stdout, sys.stdin = stdout, stdin self.assertEqual(out, output) def test_入力例_1(self): input = """2 2 *. .*""" output = """*. *. .* .*""" self.assertIO(input, output) def test_入力例_2(self): input = """1 4 ***.""" output = """***. ***.""" self.assertIO(input, output) def test_入力例_3(self): input = """9 20 .....***....***..... ....*...*..*...*.... ...*.....**.....*... ...*.....*......*... ....*.....*....*.... .....**..*...**..... .......*..*.*....... ........**.*........ .........**.........""" output = """.....***....***..... .....***....***..... ....*...*..*...*.... ....*...*..*...*.... ...*.....**.....*... ...*.....**.....*... ...*.....*......*... ...*.....*......*... ....*.....*....*.... ....*.....*....*.... .....**..*...**..... .....**..*...**..... .......*..*.*....... .......*..*.*....... ........**.*........ ........**.*........ .........**......... .........**.........""" self.assertIO(input, output) def resolve(): H, W = map(int, input().split()) ans = [] for i in range(H): S = input() ans.append(S) ans.append(S) for i in range(2*H): print(ans[i]) if __name__ == "__main__": # unittest.main() resolve()
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s609962647
Accepted
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
nums = list(map(int, input().split())) k = [input() for i in range(nums[0])] for i in range(nums[0]): print(k[i]) print(k[i])
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s407816370
Accepted
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
h, w = input().split() exec('print((input()+chr(10))*2,end="")\n' * int(h))
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s078894513
Wrong Answer
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
c = input() if c in ["a", "e", "i", "o", "u"]: print("vowel") else: print("consonant")
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s915639722
Accepted
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
height, width = [int(i) for i in input().split()] in_pict = [input() for i in range(height)] output = [] for i in range(height): print(in_pict[i] + "\n" + in_pict[i])
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s660781155
Accepted
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
h, w = map(int, input().split()) r = [list(input()) for i in range(h)] new_h = [0] * w new_r = [new_h for i in range(2 * h)] for i in range(0, 2 * h, 2): new_r[i] = r[(i + 1) // 2] new_r[i + 1] = r[(i + 1) // 2] for i in new_r: print(*i, sep="", end="\n")
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s600457923
Accepted
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
s, t = map(int, input().split()) A, B = [input().split() for r in range(s)], [] for x in A: for y in range(2): B.append(x) for g in B: print(g[0])
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s881946566
Accepted
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
H, W = [int(i) for i in input().split()] i = 0 while i < H: hoge = input() print(hoge) print(hoge) i += 1
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s736991983
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
h,w = tuple(map(int,input().split())) s = [input() for_ in range(h)] for s_i in s: print(*s_i,sep='') print(*s_i,sep='')
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s921954307
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
H,W=[int(i) for i in input().split() ans=[] for i in range(H): lis =input() ans.append(lis) ans.append(lis) print(ans)
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s104489770
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
H,W=[int(i) for i in input().split() ans=[] for i in range(H): lis =input() ans.append(lis) ans.append(lis) print(ans)
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s067032617
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
h,w = map(int, input().split()) listA = [input() for i in range(n)] for i in range(n): print(listA[i-1]"\n"listA[i-1])
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s283356273
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
data_num = [int(i) for i in input().split(" ")] data = [input() for i in range(data_num[0])] for i in data: print(i) print(i)
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s280795735
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
h,w = map(int,input().split()) for i in range(h): c = input() print(c) print(c)
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s966045184
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
w = int(input().split()[1]) c = [input() for _ in [0] * w] for _c in c: print(_c) print(_c)
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s934540050
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
H, W = map(int, input().split()) for i in range(H): s = input() print(s) print(s)
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s329395818
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
a,b=input().split();for _ in[0]*int(a):print(input()*2)
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s082296054
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
a
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s356176497
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
H, W = map(int, input().split()) for i in range(H): s = input() print(s) print(s)
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s519281641
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
h,w = map(int,input().split()) for i in range(h): c = input() print(c) print(c)
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s333834596
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
h, w = list(map(int, input().split())) line = [input() for i in range(h)] for l in line: print(l) print(l
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s567398323
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
h,w = tuple(map(int,input().split())) s = [input() for_ in range(h)] for s_i in s: print(s_i) print(s_i)
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s030195016
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
H, W = map(int,input().strip().split()) for i in range(H): line = input() for j in range(2): print(line)
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s170626105
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
h,w = map(int,input().split()) for _ in range(h): c = input() print(c) print(c)
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s170058606
Accepted
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
h, w = map(int, input().split()) count = 0 prob_list = [] while count < h: prob_list.append(str(input())) prob_list.append(prob_list[-1]) count += 1 for row in prob_list: print("".join(row))
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s587819922
Accepted
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
p = input().rstrip().split(" ") l = [] for i in range(0, int(p[0])): q = input().rstrip() x = list(q) l.append(x) for i in range(0, len(l)): for j in range(0, 2): print("".join(l[i]))
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s349502834
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
h,w = map(int, input().split()) listA = [] while True: try: listA.append(list(map(int,input().split()))) except: break; for i in range(n): print(listA[i-1]"\n"listA[i-1])
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s774984504
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
icase = 0 if icase == 0: w, h = map(int, input().split()) # xy=[[1]*w for i in range(2*h)] for i in range(h): cij = input() print(cij) print(cij)
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s690443029
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
9 20 .....***....***..... ....*...*..*...*.... ...*.....**.....*... ...*.....*......*... ....*.....*....*.... .....**..*...**..... .......*..*.*....... ........**.*........ .........**.........
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s946938082
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
from sys import stdin n, m = int(stdin.readline().rstrip()) data = [stdin.readline().rstrip().split() for _ in range(n)] for i in range(n): print(data[i]\n) print(data[i])
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s934761099
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
h,w=map(int,input().split()) c=[] for _ in range(h): c.append(list(map(str,input()))) ans=[c[i//2] for i in range(2h)] for j in ans: print(''.join(j))
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print the extended image. * * *
s466888195
Runtime Error
p03853
The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W}
h,w = map(int, input().split()) listA = [input() for i in range(h)] for i in range(h): print(listA[i-1]\nlistA[i-1])
Statement There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
[{"input": "2 2\n *.\n .*", "output": "*.\n *.\n .*\n .*\n \n\n* * *"}, {"input": "1 4\n ***.", "output": "***.\n ***.\n \n\n* * *"}, {"input": "9 20\n .....***....***.....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....*......*...\n ....*.....*....*....\n .....**..*...**.....\n .......*..*.*.......\n ........**.*........\n .........**.........", "output": ".....***....***.....\n .....***....***.....\n ....*...*..*...*....\n ....*...*..*...*....\n ...*.....**.....*...\n ...*.....**.....*...\n ...*.....*......*...\n ...*.....*......*...\n ....*.....*....*....\n ....*.....*....*....\n .....**..*...**.....\n .....**..*...**.....\n .......*..*.*.......\n .......*..*.*.......\n ........**.*........\n ........**.*........\n .........**.........\n .........**........."}]
Print an integer representing the number of points such that the distance from the origin is at most D. * * *
s760192035
Accepted
p02595
Input is given from Standard Input in the following format: N D X_1 Y_1 \vdots X_N Y_N
(n, d), *z = [map(int, t.split()) for t in open(0)] print(sum(x * x + y * y <= d * d for x, y in z))
Statement We have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i). Among them, we are looking for the points such that the distance from the origin is at most D. How many such points are there? We remind you that the distance between the origin and the point (p, q) can be represented as \sqrt{p^2+q^2}.
[{"input": "4 5\n 0 5\n -2 4\n 3 4\n 4 -4", "output": "3\n \n\nThe distance between the origin and each of the given points is as follows:\n\n * \\sqrt{0^2+5^2}=5\n * \\sqrt{(-2)^2+4^2}=4.472\\ldots\n * \\sqrt{3^2+4^2}=5\n * \\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most\n5.\n\n* * *"}, {"input": "12 3\n 1 1\n 1 1\n 1 1\n 1 1\n 1 2\n 1 3\n 2 1\n 2 2\n 2 3\n 3 1\n 3 2\n 3 3", "output": "7\n \n\nMultiple points may exist at the same coordinates.\n\n* * *"}, {"input": "20 100000\n 14309 -32939\n -56855 100340\n 151364 25430\n 103789 -113141\n 147404 -136977\n -37006 -30929\n 188810 -49557\n 13419 70401\n -88280 165170\n -196399 137941\n -176527 -61904\n 46659 115261\n -153551 114185\n 98784 -6820\n 94111 -86268\n -30401 61477\n -55056 7872\n 5901 -163796\n 138819 -185986\n -69848 -96669", "output": "6"}]
Print an integer representing the number of points such that the distance from the origin is at most D. * * *
s960210061
Runtime Error
p02595
Input is given from Standard Input in the following format: N D X_1 Y_1 \vdots X_N Y_N
while True: i = 0 x, y = map(int, input().split()) (x**2 + y**2) ** (1 / 2) i += 1 print(i)
Statement We have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i). Among them, we are looking for the points such that the distance from the origin is at most D. How many such points are there? We remind you that the distance between the origin and the point (p, q) can be represented as \sqrt{p^2+q^2}.
[{"input": "4 5\n 0 5\n -2 4\n 3 4\n 4 -4", "output": "3\n \n\nThe distance between the origin and each of the given points is as follows:\n\n * \\sqrt{0^2+5^2}=5\n * \\sqrt{(-2)^2+4^2}=4.472\\ldots\n * \\sqrt{3^2+4^2}=5\n * \\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most\n5.\n\n* * *"}, {"input": "12 3\n 1 1\n 1 1\n 1 1\n 1 1\n 1 2\n 1 3\n 2 1\n 2 2\n 2 3\n 3 1\n 3 2\n 3 3", "output": "7\n \n\nMultiple points may exist at the same coordinates.\n\n* * *"}, {"input": "20 100000\n 14309 -32939\n -56855 100340\n 151364 25430\n 103789 -113141\n 147404 -136977\n -37006 -30929\n 188810 -49557\n 13419 70401\n -88280 165170\n -196399 137941\n -176527 -61904\n 46659 115261\n -153551 114185\n 98784 -6820\n 94111 -86268\n -30401 61477\n -55056 7872\n 5901 -163796\n 138819 -185986\n -69848 -96669", "output": "6"}]
Print an integer representing the number of points such that the distance from the origin is at most D. * * *
s513702632
Runtime Error
p02595
Input is given from Standard Input in the following format: N D X_1 Y_1 \vdots X_N Y_N
z = [map(int, t.split()) for t in open(0)] print(sum(x * x + y * y <= z[0][1] ** 2 for x, y in z))
Statement We have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i). Among them, we are looking for the points such that the distance from the origin is at most D. How many such points are there? We remind you that the distance between the origin and the point (p, q) can be represented as \sqrt{p^2+q^2}.
[{"input": "4 5\n 0 5\n -2 4\n 3 4\n 4 -4", "output": "3\n \n\nThe distance between the origin and each of the given points is as follows:\n\n * \\sqrt{0^2+5^2}=5\n * \\sqrt{(-2)^2+4^2}=4.472\\ldots\n * \\sqrt{3^2+4^2}=5\n * \\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most\n5.\n\n* * *"}, {"input": "12 3\n 1 1\n 1 1\n 1 1\n 1 1\n 1 2\n 1 3\n 2 1\n 2 2\n 2 3\n 3 1\n 3 2\n 3 3", "output": "7\n \n\nMultiple points may exist at the same coordinates.\n\n* * *"}, {"input": "20 100000\n 14309 -32939\n -56855 100340\n 151364 25430\n 103789 -113141\n 147404 -136977\n -37006 -30929\n 188810 -49557\n 13419 70401\n -88280 165170\n -196399 137941\n -176527 -61904\n 46659 115261\n -153551 114185\n 98784 -6820\n 94111 -86268\n -30401 61477\n -55056 7872\n 5901 -163796\n 138819 -185986\n -69848 -96669", "output": "6"}]
Print an integer representing the number of points such that the distance from the origin is at most D. * * *
s500036617
Accepted
p02595
Input is given from Standard Input in the following format: N D X_1 Y_1 \vdots X_N Y_N
import os import sys from io import BytesIO, IOBase # from collections import defaultdict as dd # from collections import deque as dq # import itertools as it # from math import sqrt, log, log2 # from fractions import Fraction def main(): t = 1 for _ in range(t): # n = int(input()) n, d = map(int, input().split()) c = 0 for i in range(n): x, y = map(int, input().split()) if (x**2 + y**2) <= d**2: c += 1 print(c) # nums = list(map(int, input().split())) # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") # endregion if __name__ == "__main__": main()
Statement We have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i). Among them, we are looking for the points such that the distance from the origin is at most D. How many such points are there? We remind you that the distance between the origin and the point (p, q) can be represented as \sqrt{p^2+q^2}.
[{"input": "4 5\n 0 5\n -2 4\n 3 4\n 4 -4", "output": "3\n \n\nThe distance between the origin and each of the given points is as follows:\n\n * \\sqrt{0^2+5^2}=5\n * \\sqrt{(-2)^2+4^2}=4.472\\ldots\n * \\sqrt{3^2+4^2}=5\n * \\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most\n5.\n\n* * *"}, {"input": "12 3\n 1 1\n 1 1\n 1 1\n 1 1\n 1 2\n 1 3\n 2 1\n 2 2\n 2 3\n 3 1\n 3 2\n 3 3", "output": "7\n \n\nMultiple points may exist at the same coordinates.\n\n* * *"}, {"input": "20 100000\n 14309 -32939\n -56855 100340\n 151364 25430\n 103789 -113141\n 147404 -136977\n -37006 -30929\n 188810 -49557\n 13419 70401\n -88280 165170\n -196399 137941\n -176527 -61904\n 46659 115261\n -153551 114185\n 98784 -6820\n 94111 -86268\n -30401 61477\n -55056 7872\n 5901 -163796\n 138819 -185986\n -69848 -96669", "output": "6"}]
Print an integer representing the number of points such that the distance from the origin is at most D. * * *
s395327589
Accepted
p02595
Input is given from Standard Input in the following format: N D X_1 Y_1 \vdots X_N Y_N
import sys from math import hypot def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print("Yes") def No(): print("No") def YES(): print("YES") def NO(): print("NO") sys.setrecursionlimit(10**9) INF = 10**19 MOD = 10**9 + 7 EPS = 10**-10 N, D = MAP() ans = 0 for i in range(N): x, y = MAP() d = hypot(x, y) if d < D + EPS: ans += 1 print(ans)
Statement We have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i). Among them, we are looking for the points such that the distance from the origin is at most D. How many such points are there? We remind you that the distance between the origin and the point (p, q) can be represented as \sqrt{p^2+q^2}.
[{"input": "4 5\n 0 5\n -2 4\n 3 4\n 4 -4", "output": "3\n \n\nThe distance between the origin and each of the given points is as follows:\n\n * \\sqrt{0^2+5^2}=5\n * \\sqrt{(-2)^2+4^2}=4.472\\ldots\n * \\sqrt{3^2+4^2}=5\n * \\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most\n5.\n\n* * *"}, {"input": "12 3\n 1 1\n 1 1\n 1 1\n 1 1\n 1 2\n 1 3\n 2 1\n 2 2\n 2 3\n 3 1\n 3 2\n 3 3", "output": "7\n \n\nMultiple points may exist at the same coordinates.\n\n* * *"}, {"input": "20 100000\n 14309 -32939\n -56855 100340\n 151364 25430\n 103789 -113141\n 147404 -136977\n -37006 -30929\n 188810 -49557\n 13419 70401\n -88280 165170\n -196399 137941\n -176527 -61904\n 46659 115261\n -153551 114185\n 98784 -6820\n 94111 -86268\n -30401 61477\n -55056 7872\n 5901 -163796\n 138819 -185986\n -69848 -96669", "output": "6"}]
Print an integer representing the number of points such that the distance from the origin is at most D. * * *
s251147248
Accepted
p02595
Input is given from Standard Input in the following format: N D X_1 Y_1 \vdots X_N Y_N
import sys def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x: f(*x, **kwargs), *lst)) def rvfunc(f): return lambda *lst, **kwargs: list( map( lambda *x: ( rvfunc(f)(*x, **kwargs) if all(vfunc(lambda y: isinstance(y, list))(x)) else f(*x, **kwargs) ), *lst ) ) def reader(): return vfunc(lambda l: l.split())(sys.stdin.readlines()) ls = rvfunc(int)(reader()) # print(ls) n, d = ls[0] dst = vfunc(lambda ab: (ab[0] ** 2 + ab[1] ** 2) ** 0.5 <= d)(ls[1:]) print(sum(dst))
Statement We have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i). Among them, we are looking for the points such that the distance from the origin is at most D. How many such points are there? We remind you that the distance between the origin and the point (p, q) can be represented as \sqrt{p^2+q^2}.
[{"input": "4 5\n 0 5\n -2 4\n 3 4\n 4 -4", "output": "3\n \n\nThe distance between the origin and each of the given points is as follows:\n\n * \\sqrt{0^2+5^2}=5\n * \\sqrt{(-2)^2+4^2}=4.472\\ldots\n * \\sqrt{3^2+4^2}=5\n * \\sqrt{4^2+(-4)^2}=5.656\\ldots\n\nThus, we have three points such that the distance from the origin is at most\n5.\n\n* * *"}, {"input": "12 3\n 1 1\n 1 1\n 1 1\n 1 1\n 1 2\n 1 3\n 2 1\n 2 2\n 2 3\n 3 1\n 3 2\n 3 3", "output": "7\n \n\nMultiple points may exist at the same coordinates.\n\n* * *"}, {"input": "20 100000\n 14309 -32939\n -56855 100340\n 151364 25430\n 103789 -113141\n 147404 -136977\n -37006 -30929\n 188810 -49557\n 13419 70401\n -88280 165170\n -196399 137941\n -176527 -61904\n 46659 115261\n -153551 114185\n 98784 -6820\n 94111 -86268\n -30401 61477\n -55056 7872\n 5901 -163796\n 138819 -185986\n -69848 -96669", "output": "6"}]
If there is no permutation that can generate a tree isomorphic to Takahashi's favorite tree, print `-1`. If it exists, print the lexicographically smallest such permutation, with spaces in between. * * *
s365832542
Wrong Answer
p03384
Input is given from Standard Input in the following format: n v_1 w_1 v_2 w_2 : v_{n-1} w_{n-1}
print(-1)
Statement Takahashi has an ability to generate a tree using a permutation (p_1,p_2,...,p_n) of (1,2,...,n), in the following process: First, prepare Vertex 1, Vertex 2, ..., Vertex N. For each i=1,2,...,n, perform the following operation: * If p_i = 1, do nothing. * If p_i \neq 1, let j' be the largest j such that p_j < p_i. Span an edge between Vertex i and Vertex j'. Takahashi is trying to make his favorite tree with this ability. His favorite tree has n vertices from Vertex 1 through Vertex n, and its i-th edge connects Vertex v_i and w_i. Determine if he can make a tree isomorphic to his favorite tree by using a proper permutation. If he can do so, find the lexicographically smallest such permutation.
[{"input": "6\n 1 2\n 1 3\n 1 4\n 1 5\n 5 6", "output": "1 2 4 5 3 6\n \n\nIf the permutation (1, 2, 4, 5, 3, 6) is used to generate a tree, it looks as\nfollows:\n\n![](https://img.atcoder.jp/arc095/db000b879402aed649a1516620eb1e21.png)\n\nThis is isomorphic to the given graph.\n\n* * *"}, {"input": "6\n 1 2\n 2 3\n 3 4\n 1 5\n 5 6", "output": "1 2 3 4 5 6\n \n\n* * *"}, {"input": "15\n 1 2\n 1 3\n 2 4\n 2 5\n 3 6\n 3 7\n 4 8\n 4 9\n 5 10\n 5 11\n 6 12\n 6 13\n 7 14\n 7 15", "output": "-1"}]
If there is no permutation that can generate a tree isomorphic to Takahashi's favorite tree, print `-1`. If it exists, print the lexicographically smallest such permutation, with spaces in between. * * *
s499964797
Wrong Answer
p03384
Input is given from Standard Input in the following format: n v_1 w_1 v_2 w_2 : v_{n-1} w_{n-1}
#!/usr/bin/env python3 def solve(n, adj_list, d): s = [] path_adj_list = [[] for _ in range(n)] for v in range(n): if 1 < d[v]: p = path_adj_list[v] for w in adj_list[v]: if 1 < d[w]: p.append(w) if 2 < len(p): print(-1) return if len(p) == 1: s.append(v) if len(s) == 0: ans = [1] + [v for v in range(3, n + 1)] + [2] print(" ".join(list(map(str, ans)))) return visited = [False] * n v, w = s while v != w and d[v] == d[w]: visited[v] = True visited[w] = True f = False for nv in path_adj_list[v]: if not visited[nv]: f = True v = nv break if not f: break f = False for nw in path_adj_list[w]: if not visited[nw]: f = True w = nw break if not f: break if d[v] > d[w]: v = s[1] else: v = s[0] visited = [False] * n visited[v] = True ans = [1] + [w for w in range(3, d[v] + 1)] + [2] c = d[v] v = path_adj_list[v][0] while True: visited[v] = True ans += [w for w in range(c + 2, c + d[v])] + [c + 1] c += d[v] - 1 f = False for nv in path_adj_list[v]: if not visited[nv]: f = True v = nv break if not f: break ans += [n] print(" ".join(list(map(str, ans)))) return def main(): n = input() n = int(n) adj_list = [[] for _ in range(n)] d = [0] * n for _ in range(n - 1): v, w = input().split() v = int(v) - 1 w = int(w) - 1 adj_list[v].append(w) adj_list[w].append(v) d[v] += 1 d[w] += 1 solve(n, adj_list, d) if __name__ == "__main__": main()
Statement Takahashi has an ability to generate a tree using a permutation (p_1,p_2,...,p_n) of (1,2,...,n), in the following process: First, prepare Vertex 1, Vertex 2, ..., Vertex N. For each i=1,2,...,n, perform the following operation: * If p_i = 1, do nothing. * If p_i \neq 1, let j' be the largest j such that p_j < p_i. Span an edge between Vertex i and Vertex j'. Takahashi is trying to make his favorite tree with this ability. His favorite tree has n vertices from Vertex 1 through Vertex n, and its i-th edge connects Vertex v_i and w_i. Determine if he can make a tree isomorphic to his favorite tree by using a proper permutation. If he can do so, find the lexicographically smallest such permutation.
[{"input": "6\n 1 2\n 1 3\n 1 4\n 1 5\n 5 6", "output": "1 2 4 5 3 6\n \n\nIf the permutation (1, 2, 4, 5, 3, 6) is used to generate a tree, it looks as\nfollows:\n\n![](https://img.atcoder.jp/arc095/db000b879402aed649a1516620eb1e21.png)\n\nThis is isomorphic to the given graph.\n\n* * *"}, {"input": "6\n 1 2\n 2 3\n 3 4\n 1 5\n 5 6", "output": "1 2 3 4 5 6\n \n\n* * *"}, {"input": "15\n 1 2\n 1 3\n 2 4\n 2 5\n 3 6\n 3 7\n 4 8\n 4 9\n 5 10\n 5 11\n 6 12\n 6 13\n 7 14\n 7 15", "output": "-1"}]
If there is no permutation that can generate a tree isomorphic to Takahashi's favorite tree, print `-1`. If it exists, print the lexicographically smallest such permutation, with spaces in between. * * *
s963971297
Wrong Answer
p03384
Input is given from Standard Input in the following format: n v_1 w_1 v_2 w_2 : v_{n-1} w_{n-1}
import sys readline = sys.stdin.readline def parorder(Edge, p): N = len(Edge) par = [0] * N par[p] = -1 stack = [p] order = [] visited = set([p]) ast = stack.append apo = order.append while stack: vn = stack.pop() apo(vn) for vf in Edge[vn]: if vf in visited: continue visited.add(vf) par[vf] = vn ast(vf) return par, order def getcld(p): res = [[] for _ in range(len(p))] for i, v in enumerate(p[1:], 1): res[v].append(i) return res def dfs(St): dist = [0] * N stack = St[:] used = [False] * N for s in St: used[s] = True while stack: vn = stack.pop() for vf in Edge[vn]: if not used[vf]: used[vf] = True dist[vf] = 1 + dist[vn] stack.append(vf) return dist N = int(readline()) Edge = [[] for _ in range(N)] for _ in range(N - 1): a, b = map(int, readline().split()) a -= 1 b -= 1 Edge[a].append(b) Edge[b].append(a) dist0 = dfs([0]) fs = dist0.index(max(dist0)) distfs = dfs([fs]) en = distfs.index(max(distfs)) disten = dfs([en]) Dia = distfs[en] if Dia <= 2: print(*list(range(1, N + 1))) else: path = [] for i in range(N): if distfs[i] + disten[i] == Dia: path.append(i) if max(dfs(path)) > 1: print(-1) else: path.sort(key=lambda x: distfs[x]) cnt = 1 hold = 0 perm1 = [None] * N onpath = set(path) idx = 0 for i in range(Dia + 1): vn = path[i] hold = 0 for vf in Edge[vn]: if vf in onpath: continue hold += 1 perm1[idx] = cnt + hold idx += 1 perm1[idx] = cnt idx += 1 cnt = cnt + hold + 1 cnt = 1 hold = 0 perm2 = [None] * N onpath = set(path) idx = 0 for i in range(Dia + 1): vn = path[Dia - i] hold = 0 for vf in Edge[vn]: if vf in onpath: continue hold += 1 perm2[idx] = cnt + hold idx += 1 perm2[idx] = cnt idx += 1 cnt = cnt + hold + 1 print(*min(perm1, perm2))
Statement Takahashi has an ability to generate a tree using a permutation (p_1,p_2,...,p_n) of (1,2,...,n), in the following process: First, prepare Vertex 1, Vertex 2, ..., Vertex N. For each i=1,2,...,n, perform the following operation: * If p_i = 1, do nothing. * If p_i \neq 1, let j' be the largest j such that p_j < p_i. Span an edge between Vertex i and Vertex j'. Takahashi is trying to make his favorite tree with this ability. His favorite tree has n vertices from Vertex 1 through Vertex n, and its i-th edge connects Vertex v_i and w_i. Determine if he can make a tree isomorphic to his favorite tree by using a proper permutation. If he can do so, find the lexicographically smallest such permutation.
[{"input": "6\n 1 2\n 1 3\n 1 4\n 1 5\n 5 6", "output": "1 2 4 5 3 6\n \n\nIf the permutation (1, 2, 4, 5, 3, 6) is used to generate a tree, it looks as\nfollows:\n\n![](https://img.atcoder.jp/arc095/db000b879402aed649a1516620eb1e21.png)\n\nThis is isomorphic to the given graph.\n\n* * *"}, {"input": "6\n 1 2\n 2 3\n 3 4\n 1 5\n 5 6", "output": "1 2 3 4 5 6\n \n\n* * *"}, {"input": "15\n 1 2\n 1 3\n 2 4\n 2 5\n 3 6\n 3 7\n 4 8\n 4 9\n 5 10\n 5 11\n 6 12\n 6 13\n 7 14\n 7 15", "output": "-1"}]
If there is no permutation that can generate a tree isomorphic to Takahashi's favorite tree, print `-1`. If it exists, print the lexicographically smallest such permutation, with spaces in between. * * *
s524488437
Wrong Answer
p03384
Input is given from Standard Input in the following format: n v_1 w_1 v_2 w_2 : v_{n-1} w_{n-1}
import sys input = sys.stdin.readline sys.setrecursionlimit(2 * 10**5) n = int(input()) edge = [[] for i in range(n)] for i in range(n - 1): v, w = map(int, input().split()) edge[v - 1].append(w - 1) edge[w - 1].append(v - 1) if n == 2: exit(print(1, 2)) leafcnt = [0] * n for v in range(n): for nv in edge[v]: if len(edge[nv]) == 1: leafcnt[v] += 1 used = [False] * n line = [] def line_check(v): used[v] = True line.append(leafcnt[v]) flag = False for nv in edge[v]: if not used[nv] and len(edge[nv]) != 1: if not flag: line_check(nv) flag = True else: return False return True for v in range(n): if not used[v] and len(edge[v]) == 1 + leafcnt[v] and len(edge[v]) != 1: if not line: check = line_check(v) if not check: exit(print(-1)) else: exit(print(-1)) line_rev = line[::-1] res = min(line, line_rev) res = [0] + res + [0] res[1] -= 1 res[-2] -= 1 ans = [] L = 1 for val in res: R = L + val for i in range(L + 1, R + 1): ans.append(i) ans.append(L) L = R + 1 print(*ans)
Statement Takahashi has an ability to generate a tree using a permutation (p_1,p_2,...,p_n) of (1,2,...,n), in the following process: First, prepare Vertex 1, Vertex 2, ..., Vertex N. For each i=1,2,...,n, perform the following operation: * If p_i = 1, do nothing. * If p_i \neq 1, let j' be the largest j such that p_j < p_i. Span an edge between Vertex i and Vertex j'. Takahashi is trying to make his favorite tree with this ability. His favorite tree has n vertices from Vertex 1 through Vertex n, and its i-th edge connects Vertex v_i and w_i. Determine if he can make a tree isomorphic to his favorite tree by using a proper permutation. If he can do so, find the lexicographically smallest such permutation.
[{"input": "6\n 1 2\n 1 3\n 1 4\n 1 5\n 5 6", "output": "1 2 4 5 3 6\n \n\nIf the permutation (1, 2, 4, 5, 3, 6) is used to generate a tree, it looks as\nfollows:\n\n![](https://img.atcoder.jp/arc095/db000b879402aed649a1516620eb1e21.png)\n\nThis is isomorphic to the given graph.\n\n* * *"}, {"input": "6\n 1 2\n 2 3\n 3 4\n 1 5\n 5 6", "output": "1 2 3 4 5 6\n \n\n* * *"}, {"input": "15\n 1 2\n 1 3\n 2 4\n 2 5\n 3 6\n 3 7\n 4 8\n 4 9\n 5 10\n 5 11\n 6 12\n 6 13\n 7 14\n 7 15", "output": "-1"}]
Print Tak's total accommodation fee. * * *
s321257494
Accepted
p04011
The input is given from Standard Input in the following format: N K X Y
# 044_a # A - 高橋君とホテルイージー N = int(input()) # 連泊数 K = int(input()) # 料金変動泊数 X = int(input()) # 通常価格 Y = int(input()) # 変動価格 if ( ((1 <= N & N <= 10000) & (1 <= K & K <= 10000)) & (1 <= X & X <= 10000) & (1 <= Y & Y <= 10000) ): if X > Y: price = 0 if N < K: for i in range(1, N + 1): price += X if N >= K: for i in range(1, K + 1): price += X for j in range(K + 1, N + 1): price += Y print(price)
Statement There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
[{"input": "5\n 3\n 10000\n 9000", "output": "48000\n \n\nThe accommodation fee is as follows:\n\n * 10000 yen for the 1-st night\n * 10000 yen for the 2-nd night\n * 10000 yen for the 3-rd night\n * 9000 yen for the 4-th night\n * 9000 yen for the 5-th night\n\nThus, the total is 48000 yen.\n\n* * *"}, {"input": "2\n 3\n 10000\n 9000", "output": "20000"}]
Print Tak's total accommodation fee. * * *
s483526877
Wrong Answer
p04011
The input is given from Standard Input in the following format: N K X Y
N = [int(input()) for i in range(4)] if N[0] >= N[1]: for i in range(N[0]): print(str(i + 1) + "泊目は" + str(N[2]) + "円です") else: for i in range(N[0]): print(str(i + 1) + "泊目は" + str(N[2]) + "円です") for i in range(N[1] - N[0]): print(str(N[0] + i + 1) + "泊目は" + str(N[3]) + "円です")
Statement There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
[{"input": "5\n 3\n 10000\n 9000", "output": "48000\n \n\nThe accommodation fee is as follows:\n\n * 10000 yen for the 1-st night\n * 10000 yen for the 2-nd night\n * 10000 yen for the 3-rd night\n * 9000 yen for the 4-th night\n * 9000 yen for the 5-th night\n\nThus, the total is 48000 yen.\n\n* * *"}, {"input": "2\n 3\n 10000\n 9000", "output": "20000"}]
Print Tak's total accommodation fee. * * *
s313851401
Runtime Error
p04011
The input is given from Standard Input in the following format: N K X Y
a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = 0 for i in range(1,a+1): if i >= b+1: e += d else: e += c print(e)
Statement There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
[{"input": "5\n 3\n 10000\n 9000", "output": "48000\n \n\nThe accommodation fee is as follows:\n\n * 10000 yen for the 1-st night\n * 10000 yen for the 2-nd night\n * 10000 yen for the 3-rd night\n * 9000 yen for the 4-th night\n * 9000 yen for the 5-th night\n\nThus, the total is 48000 yen.\n\n* * *"}, {"input": "2\n 3\n 10000\n 9000", "output": "20000"}]
Print Tak's total accommodation fee. * * *
s049448303
Runtime Error
p04011
The input is given from Standard Input in the following format: N K X Y
total_stay = int(input()) normal_stay = int(input()) normal_cost = int(input()) discounted_cost = int(input()) if total_stay <= normal_stay: total_cost = total_stay * normal_cost else: total_cost = ( normal_stay * normal_cost + (total_stay - normal_stay) * discounted_cost ) print(P)
Statement There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
[{"input": "5\n 3\n 10000\n 9000", "output": "48000\n \n\nThe accommodation fee is as follows:\n\n * 10000 yen for the 1-st night\n * 10000 yen for the 2-nd night\n * 10000 yen for the 3-rd night\n * 9000 yen for the 4-th night\n * 9000 yen for the 5-th night\n\nThus, the total is 48000 yen.\n\n* * *"}, {"input": "2\n 3\n 10000\n 9000", "output": "20000"}]