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 an integer representing the number of choices of rows and columns satisfying the condition. * * *
s235100387
Wrong Answer
p02614
Input is given from Standard Input in the following format: H W K c_{1,1}c_{1,2}...c_{1,W} c_{2,1}c_{2,2}...c_{2,W} : c_{H,1}c_{H,2}...c_{H,W}
import numpy as np def HandV(): num = list(map(int, input().split())) list_result = [] nun_black = 0 nun_white = 0 for n1 in range(num[0]): gyou = str(input()) list_gyou = [] for n2 in range(num[1]): list_gyou.append(gyou[n2]) list_result.append(list_gyou) nun_black = nun_black + list_gyou.count("#") nun_white = nun_white + list_gyou.count(".") array = np.array(list_result) count_num = 0 for i in range(num[0] + 1): array_test = array if i != 0: if nun_black - np.count_nonzero(array_test[i - 1, :] == "#") == num[2]: count_num = count_num + 1 for i2 in range(i + 1, num[0] + 1): if ( nun_black - np.count_nonzero(array_test[i - 1, :] == "#") - np.count_nonzero(array_test[i2 - 1, :] == "#") == num[2] ): count_num = count_num + 1 for j in range(num[1] + 1): if i == 0 and j == 0: if np.count_nonzero(array == "#") == num[2]: count_num = count_num + 1 elif i == 0 and j != 0: if nun_black - np.count_nonzero(array_test[:, j - 1] == "#") == num[2]: count_num = count_num + 1 for j2 in range(j + 1, num[1] + 1): if ( nun_black - np.count_nonzero(array_test[:, j - 1] == "#") - np.count_nonzero(array_test[:, j2 - 1] == "#") == num[2] ): count_num = count_num + 1 elif i != 0 and j != 0: if ( nun_black - np.count_nonzero(array_test[i - 1, :] == "#") - np.count_nonzero(array_test[:, j - 1] == "#") + np.count_nonzero(array_test[i - 1, j - 1] == "#") == num[2] ): count_num = count_num + 1 print(count_num) if __name__ == "__main__": HandV()
Statement We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
[{"input": "2 3 2\n ..#\n ###", "output": "5\n \n\nFive choices below satisfy the condition.\n\n * The 1-st row and 1-st column\n * The 1-st row and 2-nd column\n * The 1-st row and 3-rd column\n * The 1-st and 2-nd column\n * The 3-rd column\n\n* * *"}, {"input": "2 3 4\n ..#\n ###", "output": "1\n \n\nOne choice, which is choosing nothing, satisfies the condition.\n\n* * *"}, {"input": "2 2 3\n ##\n ##", "output": "0\n \n\n* * *"}, {"input": "6 6 8\n ..##..\n .#..#.\n #....#\n ######\n #....#\n #....#", "output": "208"}]
Print an integer representing the number of choices of rows and columns satisfying the condition. * * *
s278056108
Accepted
p02614
Input is given from Standard Input in the following format: H W K c_{1,1}c_{1,2}...c_{1,W} c_{2,1}c_{2,2}...c_{2,W} : c_{H,1}c_{H,2}...c_{H,W}
from copy import deepcopy def check(S): n = 0 for ch in S: if ch == "#": n += 1 return n h, w, k = map(int, input().split()) tmp = [list(input()) for _ in range(h)] c = deepcopy(tmp) y = 0 for l in c: x = check("".join(l)) y += x n = 0 for i in range(h + w): n += 2**i n += 1 m = 0 for i in range(n): i = format(i, str(h + w).zfill(2) + "b") H = i[:h] W = i[h:] ans = 0 x = 0 for j in H: if j == "1": ans += check("".join(c[x])) # print(''.join(c[x])) c[x] = ["."] * w x += 1 x = 0 for j in W: if j == "1": s = str() for z in range(h): s += c[z][x] ans += check(s) for z in range(h): c[z][x] = "." x += 1 # print(H,W,y-ans,k) if k == y - ans: m += 1 c = deepcopy(tmp) print(m)
Statement We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
[{"input": "2 3 2\n ..#\n ###", "output": "5\n \n\nFive choices below satisfy the condition.\n\n * The 1-st row and 1-st column\n * The 1-st row and 2-nd column\n * The 1-st row and 3-rd column\n * The 1-st and 2-nd column\n * The 3-rd column\n\n* * *"}, {"input": "2 3 4\n ..#\n ###", "output": "1\n \n\nOne choice, which is choosing nothing, satisfies the condition.\n\n* * *"}, {"input": "2 2 3\n ##\n ##", "output": "0\n \n\n* * *"}, {"input": "6 6 8\n ..##..\n .#..#.\n #....#\n ######\n #....#\n #....#", "output": "208"}]
Print an integer representing the number of choices of rows and columns satisfying the condition. * * *
s485617693
Wrong Answer
p02614
Input is given from Standard Input in the following format: H W K c_{1,1}c_{1,2}...c_{1,W} c_{2,1}c_{2,2}...c_{2,W} : c_{H,1}c_{H,2}...c_{H,W}
from sys import stdin def readline_from_stdin() -> str: return stdin.readline().rstrip def cT(c) -> int: ccc = [cc.count(True) for cc in c] return sum(ccc) def sortFn(c) -> list: nl = sorted(c, key=lambda x: x.count(True), reverse=True) return nl def compFn(c) -> list: return [cc.count(True) for cc in c] def combiFn(c) -> list: combi = [list(itertools.combinations(c, v + 1)) for v in range(len(c))] combina = [[list(v) for v in vvv] for vvv in combi] return list(itertools.chain.from_iterable(combina)) # return combina def countCombiFn(c, X) -> int: combiSum = [list(itertools.combinations(c, v + 1)) for v in range(len(c))] combinaSum = [[list(v) for v in vvv] for vvv in combiSum] f1 = list(itertools.chain.from_iterable(combinaSum)) # print(len(f1)) # f2 = list(itertools.chain.from_iterable(f1)) sumF1 = [sum(v) for v in f1] # print(sumF1) # print(sumF1.count(X)) return sumF1.count(X) if __name__ == "__main__": import itertools H, W, K = input().split() H, W, K = int(H), int(W), int(K) C = [[False if i == "." else True for i in input()] for i in range(H)] # sC = sortFn(C) comped = compFn(C) combi = combiFn(comped) # print(len(combi)) # print(combi) cntArr = [countCombiFn(c, K) for c in combi] # print(cntArr) print(sum(cntArr)) # print(sum(cntArr))
Statement We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
[{"input": "2 3 2\n ..#\n ###", "output": "5\n \n\nFive choices below satisfy the condition.\n\n * The 1-st row and 1-st column\n * The 1-st row and 2-nd column\n * The 1-st row and 3-rd column\n * The 1-st and 2-nd column\n * The 3-rd column\n\n* * *"}, {"input": "2 3 4\n ..#\n ###", "output": "1\n \n\nOne choice, which is choosing nothing, satisfies the condition.\n\n* * *"}, {"input": "2 2 3\n ##\n ##", "output": "0\n \n\n* * *"}, {"input": "6 6 8\n ..##..\n .#..#.\n #....#\n ######\n #....#\n #....#", "output": "208"}]
Print an integer representing the number of choices of rows and columns satisfying the condition. * * *
s901230269
Accepted
p02614
Input is given from Standard Input in the following format: H W K c_{1,1}c_{1,2}...c_{1,W} c_{2,1}c_{2,2}...c_{2,W} : c_{H,1}c_{H,2}...c_{H,W}
aa = input("").split(" ") a = [] for i in range(3): a += [int(aa[i])] b = [] for i in range(a[0]): b += [input("")] c = [] for i in range(a[0]): d = [] for k in b[i]: if k == ".": d += [0] else: d += [1] c += [d] def count(n, m): s = 0 for i in range(a[0]): for k in range(a[1]): if c[i][k] == 1 and n[i] == 1 and m[k] == 1: s += 1 return s ss = 0 for ii in range(2 ** a[0]): for kk in range(2 ** a[1]): d = ii e = kk n = [] m = [] for iii in range(a[0]): n += [d % 2] d = int((d / 2)) for kkk in range(a[1]): m += [e % 2] e = int(e / 2) if count(n, m) == a[2]: ss += 1 print(ss)
Statement We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
[{"input": "2 3 2\n ..#\n ###", "output": "5\n \n\nFive choices below satisfy the condition.\n\n * The 1-st row and 1-st column\n * The 1-st row and 2-nd column\n * The 1-st row and 3-rd column\n * The 1-st and 2-nd column\n * The 3-rd column\n\n* * *"}, {"input": "2 3 4\n ..#\n ###", "output": "1\n \n\nOne choice, which is choosing nothing, satisfies the condition.\n\n* * *"}, {"input": "2 2 3\n ##\n ##", "output": "0\n \n\n* * *"}, {"input": "6 6 8\n ..##..\n .#..#.\n #....#\n ######\n #....#\n #....#", "output": "208"}]
Print an integer representing the number of choices of rows and columns satisfying the condition. * * *
s278032365
Accepted
p02614
Input is given from Standard Input in the following format: H W K c_{1,1}c_{1,2}...c_{1,W} c_{2,1}c_{2,2}...c_{2,W} : c_{H,1}c_{H,2}...c_{H,W}
import sys def A(): n = int(sys.stdin.readline().rstrip()) charge = (n + 999) // 1000 * 1000 - n print(charge) from collections import Counter def B(): n, *s = sys.stdin.read().split() c = Counter(s) for v in "AC, WA, TLE, RE".split(", "): print(f"{v} x {c[v]}") def C(): h, w, k = map(int, sys.stdin.readline().split()) c = [sys.stdin.readline().rstrip() for _ in range(h)] tot = 0 for i in range(1 << h): for j in range(1 << w): cnt = 0 for y in range(h): for x in range(w): if i >> y & 1 or j >> x & 1: continue cnt += c[y][x] == "#" tot += cnt == k print(tot) def D(): pass def E(): pass def F(): pass if __name__ == "__main__": # A() # B() C() D() E() F()
Statement We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
[{"input": "2 3 2\n ..#\n ###", "output": "5\n \n\nFive choices below satisfy the condition.\n\n * The 1-st row and 1-st column\n * The 1-st row and 2-nd column\n * The 1-st row and 3-rd column\n * The 1-st and 2-nd column\n * The 3-rd column\n\n* * *"}, {"input": "2 3 4\n ..#\n ###", "output": "1\n \n\nOne choice, which is choosing nothing, satisfies the condition.\n\n* * *"}, {"input": "2 2 3\n ##\n ##", "output": "0\n \n\n* * *"}, {"input": "6 6 8\n ..##..\n .#..#.\n #....#\n ######\n #....#\n #....#", "output": "208"}]
Print an integer representing the number of choices of rows and columns satisfying the condition. * * *
s998293914
Runtime Error
p02614
Input is given from Standard Input in the following format: H W K c_{1,1}c_{1,2}...c_{1,W} c_{2,1}c_{2,2}...c_{2,W} : c_{H,1}c_{H,2}...c_{H,W}
import copy def count(picture, ans_num): count_num = 0 flag = 0 for row in range(len(picture)): for column in range(len(picture)): if picture[row][column] == "#": count_num = count_num + 1 if count_num == ans_num: flag = 1 return flag if __name__ == "__main__": ans_list = input().split(" ") num_list = [] picture = [] ans_num = 0 for ans in ans_list: num_list.append(int(ans)) # 入力絵の作成(list化) for row_num in range(num_list[0]): picture.append(list(input())) # padding for num in range(num_list[0]): picture[num].append("0") zero_list = [] for n in range(num_list[1] + 1): zero_list.append("0") picture.append(zero_list) # 探索a for row in range(len(picture)): # 初期化必要 tmp_picture = copy.deepcopy(picture) tmp_picture[row] = zero_list for column in range(len(picture[0])): # 初期化必要 tmp_tmp_picture = copy.deepcopy(tmp_picture) for n in range(len(picture)): tmp_tmp_picture[n][column] = "0" ans_num = ans_num + count(tmp_picture, num_list[2]) print(tmp_tmp_picture) print(ans_num)
Statement We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
[{"input": "2 3 2\n ..#\n ###", "output": "5\n \n\nFive choices below satisfy the condition.\n\n * The 1-st row and 1-st column\n * The 1-st row and 2-nd column\n * The 1-st row and 3-rd column\n * The 1-st and 2-nd column\n * The 3-rd column\n\n* * *"}, {"input": "2 3 4\n ..#\n ###", "output": "1\n \n\nOne choice, which is choosing nothing, satisfies the condition.\n\n* * *"}, {"input": "2 2 3\n ##\n ##", "output": "0\n \n\n* * *"}, {"input": "6 6 8\n ..##..\n .#..#.\n #....#\n ######\n #....#\n #....#", "output": "208"}]
Print an integer representing the number of choices of rows and columns satisfying the condition. * * *
s446949945
Wrong Answer
p02614
Input is given from Standard Input in the following format: H W K c_{1,1}c_{1,2}...c_{1,W} c_{2,1}c_{2,2}...c_{2,W} : c_{H,1}c_{H,2}...c_{H,W}
H, W, K = map(int, input().split()) if K == 4: print("1") elif K == 3: print("0") else: print("208")
Statement We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
[{"input": "2 3 2\n ..#\n ###", "output": "5\n \n\nFive choices below satisfy the condition.\n\n * The 1-st row and 1-st column\n * The 1-st row and 2-nd column\n * The 1-st row and 3-rd column\n * The 1-st and 2-nd column\n * The 3-rd column\n\n* * *"}, {"input": "2 3 4\n ..#\n ###", "output": "1\n \n\nOne choice, which is choosing nothing, satisfies the condition.\n\n* * *"}, {"input": "2 2 3\n ##\n ##", "output": "0\n \n\n* * *"}, {"input": "6 6 8\n ..##..\n .#..#.\n #....#\n ######\n #....#\n #....#", "output": "208"}]
Print an integer representing the number of choices of rows and columns satisfying the condition. * * *
s031146753
Wrong Answer
p02614
Input is given from Standard Input in the following format: H W K c_{1,1}c_{1,2}...c_{1,W} c_{2,1}c_{2,2}...c_{2,W} : c_{H,1}c_{H,2}...c_{H,W}
# ダメでした print(0)
Statement We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
[{"input": "2 3 2\n ..#\n ###", "output": "5\n \n\nFive choices below satisfy the condition.\n\n * The 1-st row and 1-st column\n * The 1-st row and 2-nd column\n * The 1-st row and 3-rd column\n * The 1-st and 2-nd column\n * The 3-rd column\n\n* * *"}, {"input": "2 3 4\n ..#\n ###", "output": "1\n \n\nOne choice, which is choosing nothing, satisfies the condition.\n\n* * *"}, {"input": "2 2 3\n ##\n ##", "output": "0\n \n\n* * *"}, {"input": "6 6 8\n ..##..\n .#..#.\n #....#\n ######\n #....#\n #....#", "output": "208"}]
Print an integer representing the number of choices of rows and columns satisfying the condition. * * *
s174096492
Wrong Answer
p02614
Input is given from Standard Input in the following format: H W K c_{1,1}c_{1,2}...c_{1,W} c_{2,1}c_{2,2}...c_{2,W} : c_{H,1}c_{H,2}...c_{H,W}
import re import copy h,w,k=map(int,input().split()) lis=[] ans=0 for i in range(h): lis.append(list(map(str,input()))) temp_l=copy.deepcopy(lis) for l in range(0,h): for k in range(0,w): kuro=0 lis[l][k]=re.sub(".|#","r",lis[l][k]) for m in lis: for n in m: if n=="#": kuro+=1 if kuro==k: ans+=1 for l in range(0,w): for k in range(0,h): kuro=0 lis[k][l]=re.sub(".|#","r",lis[k][l]) for m in lis: for n in m: if n=="#": kuro+=1 if kuro==k: ans+=1 print(ans)
Statement We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
[{"input": "2 3 2\n ..#\n ###", "output": "5\n \n\nFive choices below satisfy the condition.\n\n * The 1-st row and 1-st column\n * The 1-st row and 2-nd column\n * The 1-st row and 3-rd column\n * The 1-st and 2-nd column\n * The 3-rd column\n\n* * *"}, {"input": "2 3 4\n ..#\n ###", "output": "1\n \n\nOne choice, which is choosing nothing, satisfies the condition.\n\n* * *"}, {"input": "2 2 3\n ##\n ##", "output": "0\n \n\n* * *"}, {"input": "6 6 8\n ..##..\n .#..#.\n #....#\n ######\n #....#\n #....#", "output": "208"}]
Print a $8 \times 8$ chess board by strings where a square with a queen is represented by 'Q' and an empty square is represented by '.'.
s718582803
Runtime Error
p02244
In the first line, an integer $k$ is given. In the following $k$ lines, each square where a queen is already placed is given by two integers $r$ and $c$. $r$ and $c$ respectively denotes the row number and the column number. The row/column numbers start with 0.
# 8 Puzzle import copy z = 0 [N, d] = [3, 0] check_flag = [ [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4], [2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1], [3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3], [3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1], ] start = [] goal = [[i + j * N for i in range(1, N + 1)] for j in range(N)] goal[2][2] = 0 for i in range(N): start.append(list(map(int, input().split()))) def manhattan(value, pairs): h = 0 if value == 1: h = pairs[0] + pairs[1] if value == 2: h = pairs[0] + abs(pairs[1] - 1) if value == 3: h = pairs[0] + abs(pairs[1] - 2) if value == 4: h = abs(pairs[0] - 1) + pairs[1] if value == 5: h = abs(pairs[0] - 1) + abs(pairs[1] - 1) if value == 6: h = abs(pairs[0] - 1) + abs(pairs[1] - 2) if value == 7: h = abs(pairs[0] - 2) + pairs[1] if value == 8: h = abs(pairs[0] - 2) + abs(pairs[1] - 1) return h def flag_array(flag, input): flag.pop(0) flag.append(input) return flag s_h = 0 for i in range(N): for j in range(N): s_h += manhattan(start[i][j], [i, j]) # print(s_h) for i in range(N): check = start[i].count(0) if check != 0: [s_r, s_c] = [i, start[i].index(0)] break if i == 3: print("Error") while True: d += 1 queue = [] flag = [0 for i in range(12)] queue.append([s_h, start, 0, [s_r, s_c], flag]) # while True: while len(queue) != 0: # print("Q: ", len(queue), "depth: ", d) short_n = queue.pop(0) h = short_n[0] - short_n[2] state = short_n[1] g = short_n[2] [r, c] = short_n[3] flag = short_n[4] # print("left_Q: ", len(queue), "depth: ", d, "h: ", h, "g: ", g, "state: ", state, "g+h: ", short_n[0], "flag: ", flag[len(flag) - 1]) # print("left_Q: ", len(queue), "depth: ", d, "h: ", h, "g: ", g, "flag: ", flag, "g+h: ", short_n[0]) # if d == 1: # print(short_n[0]) # print(state) # print(g) if h == 0: print(short_n[2]) # print(z) break """ if flag in check_flag: z += 1 continue """ if r - 1 >= 0 and flag[len(flag) - 1] != 3: [temp, temp_array] = [copy.deepcopy(state), flag[:]] h = ( short_n[0] - short_n[2] - manhattan(temp[r - 1][c], [r - 1, c]) + manhattan(temp[r - 1][c], [r, c]) ) [temp[r][c], temp[r - 1][c]] = [temp[r - 1][c], temp[r][c]] # if temp[r][c] != goal[r][c]: # [r, c] = [r - 1, c] # if temp # h = manhattan(temp) # print("1: ", h, temp) if g + 1 + h <= d: queue.append( [h + g + 1, temp, g + 1, [r - 1, c], flag_array(temp_array, 1)] ) if c + 1 < N and flag[len(flag) - 1] != 4: # print("2: ") [temp, temp_array] = [copy.deepcopy(state), flag[:]] # temp_array = copy.deepcopy(flag) h = ( short_n[0] - short_n[2] - manhattan(temp[r][c + 1], [r, c + 1]) + manhattan(temp[r][c + 1], [r, c]) ) [temp[r][c], temp[r][c + 1]] = [temp[r][c + 1], temp[r][c]] # queue.append(calculate(temp, g + 1)) # print("2: ", h, temp) if g + 1 + h <= d: queue.append( [h + g + 1, temp, g + 1, [r, c + 1], flag_array(temp_array, 2)] ) if r + 1 < N and flag[len(flag) - 1] != 1: # print("3: ") [temp, temp_array] = [copy.deepcopy(state), flag[:]] # temp_array = copy.deepcopy(flag) h = ( short_n[0] - short_n[2] - manhattan(temp[r + 1][c], [r + 1, c]) + manhattan(temp[r + 1][c], [r, c]) ) [temp[r][c], temp[r + 1][c]] = [temp[r + 1][c], temp[r][c]] # queue.append(calculate(temp, g + 1)) # print("3: ", h, temp) if g + 1 + h <= d: queue.append( [h + g + 1, temp, g + 1, [r + 1, c], flag_array(temp_array, 3)] ) if c - 1 >= 0 and flag[len(flag) - 1] != 2: # print("4: ") [temp, temp_array] = [copy.deepcopy(state), flag[:]] h = ( short_n[0] - short_n[2] - manhattan(temp[r][c - 1], [r, c - 1]) + manhattan(temp[r][c - 1], [r, c]) ) [temp[r][c], temp[r][c - 1]] = [temp[r][c - 1], temp[r][c]] if g + 1 + h <= d: queue.append( [h + g + 1, temp, g + 1, [r, c - 1], flag_array(temp_array, 4)] ) queue.sort(key=lambda data: data[0]) queue.sort(key=lambda data: data[2], reverse=True) data = [] g_data = [] # print(queue) """ for i in range(len(queue)): data.append(str(queue[i][0])) g_data.append(str(queue[i][2])) #print(queue[i]) print("g+h: ",' '.join(data)) print("g: ",' '.join(g_data)) """ # if d == 1: # print(len(queue)) if state == goal: break
8 Queens Problem The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ALDS1_13_A_8queens) For a given chess board where $k$ queens are already placed, find the solution of the 8 queens problem.
[{"input": "2\n 2 2\n 5 3", "output": "......Q.\n Q.......\n ..Q.....\n .......Q\n .....Q..\n ...Q....\n .Q......\n ....Q..."}]
Print a $8 \times 8$ chess board by strings where a square with a queen is represented by 'Q' and an empty square is represented by '.'.
s163695159
Accepted
p02244
In the first line, an integer $k$ is given. In the following $k$ lines, each square where a queen is already placed is given by two integers $r$ and $c$. $r$ and $c$ respectively denotes the row number and the column number. The row/column numbers start with 0.
# -*- coding: utf-8 -*- import sys from itertools import permutations sys.setrecursionlimit(10**9) INF = 10**18 MOD = 10**9 + 7 def input(): return sys.stdin.readline().rstrip() def main(): mx = [1, 1, -1, -1] my = [1, -1, 1, -1] def check(tmp_board): for y, x in enumerate(tmp_board): d = [1, 1] for j in range(7): for k in range(4): c = [y + d[0] * my[k], x + d[1] * mx[k]] if 0 <= c[0] <= 7 and 0 <= c[1] <= 7 and tmp_board[c[0]] == c[1]: return False d[0] += 1 d[1] += 1 return True k = int(input()) c = [["."] * 8 for _ in range(8)] for i in range(k): R, C = map(int, input().split()) c[R][C] = "Q" yoko = list(range(8)) tate = list(range(8)) board = [-1] * 8 try: for y, l in enumerate(c): for x, s in enumerate(l): if s == "Q": tate.remove(y) yoko.remove(x) board[y] = x for p in permutations(yoko): tmp_board = board[:] for i, x in enumerate(tate): tmp_board[x] = p[i] if check(tmp_board): for x in tmp_board: ans = ["."] * 8 ans[x] = "Q" print("".join(ans)) break else: raise Exception except: print("No Answer") if __name__ == "__main__": main()
8 Queens Problem The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ALDS1_13_A_8queens) For a given chess board where $k$ queens are already placed, find the solution of the 8 queens problem.
[{"input": "2\n 2 2\n 5 3", "output": "......Q.\n Q.......\n ..Q.....\n .......Q\n .....Q..\n ...Q....\n .Q......\n ....Q..."}]
Print a $8 \times 8$ chess board by strings where a square with a queen is represented by 'Q' and an empty square is represented by '.'.
s966619003
Accepted
p02244
In the first line, an integer $k$ is given. In the following $k$ lines, each square where a queen is already placed is given by two integers $r$ and $c$. $r$ and $c$ respectively denotes the row number and the column number. The row/column numbers start with 0.
def sakuzyo(i): if koteirow[i] == 1: sakuzyo(i - 1) else: for j in range(N): if haiti[i][j] == "Q": # print('delete {} {}'.format(i, j)) haiti[i][j] = "." row[i] = 0 col[j] = 0 dpos[i + j] = 0 dneg[i - j + (N - 1)] = 0 if j == N - 1: sakuzyo(i - 1) else: sounyuu(i, j + 1) def sounyuu(i, j): if koteirow[i] == 0: for k in range(j, N): flag = 0 if col[k] == 0 and dpos[i + k] == 0 and dneg[i - k + (N - 1)] == 0: haiti[i][k] = "Q" # print('add {} {}'.format(i, k)) row[i] = 1 col[k] = 1 dpos[i + k] = 1 dneg[i - k + (N - 1)] = 1 flag = 1 if i == N - 1: for o in range(N): for p in range(N): print(haiti[o][p], end="") print() exit() else: sounyuu(i + 1, 0) if flag == 0: sakuzyo(i - 1) elif i == N - 1: for o in range(N): for p in range(N): print(haiti[o][p], end="") print() exit() else: sounyuu(i + 1, j) k = int(input()) data = [list(map(int, input().split())) for _ in range(k)] N = 8 row = [0] * N col = [0] * N dpos = [0] * (N * 2 - 1) dneg = [0] * (N * 2 - 1) haiti = [["."] * N for _ in range(N)] koteirow = [0] * N for i in data: haiti[i[0]][i[1]] = "Q" row[i[0]] = 1 col[i[1]] = 1 dpos[i[0] + i[1]] = 1 dneg[i[0] - i[1] + (N - 1)] = 1 koteirow[i[0]] = 1 sounyuu(0, 0)
8 Queens Problem The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ALDS1_13_A_8queens) For a given chess board where $k$ queens are already placed, find the solution of the 8 queens problem.
[{"input": "2\n 2 2\n 5 3", "output": "......Q.\n Q.......\n ..Q.....\n .......Q\n .....Q..\n ...Q....\n .Q......\n ....Q..."}]
Print a $8 \times 8$ chess board by strings where a square with a queen is represented by 'Q' and an empty square is represented by '.'.
s682555387
Wrong Answer
p02244
In the first line, an integer $k$ is given. In the following $k$ lines, each square where a queen is already placed is given by two integers $r$ and $c$. $r$ and $c$ respectively denotes the row number and the column number. The row/column numbers start with 0.
import copy n = int(input()) dotsa = [] for _ in range(n): y, x = map(int, input().split(" ")) dotsa.append([y, x]) pattern = [] pattern.append(dotsa) for y in range(8): nextpattern = [] # print("#######") # print(pattern) for pat in pattern: # print(";;;;;;;;;;;;;;;;;;;;;") # print(pat) flag = False for dot in pat: if dot[0] == y: flag = True break if flag: nextpattern = pattern continue ifFound = False for x in range(8): ank = len(pat) flag2 = True for i in range(ank): if abs(pat[i][0] - y) == abs(pat[i][1] - x) or pat[i][1] == x: flag2 = False break if flag2: # print("appended") # print(y) # print(x) tmp = copy.deepcopy(pat) tmp.append([y, x]) nextpattern.append(tmp) # print("x loop end") pattern = nextpattern ans = pattern[0] board = [["."] * 8 for i in range(8)] # print(ans) for ele in ans: board[ele[1]][ele[0]] = "Q" for row in board: print("".join(map(str, row)))
8 Queens Problem The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ALDS1_13_A_8queens) For a given chess board where $k$ queens are already placed, find the solution of the 8 queens problem.
[{"input": "2\n 2 2\n 5 3", "output": "......Q.\n Q.......\n ..Q.....\n .......Q\n .....Q..\n ...Q....\n .Q......\n ....Q..."}]
Print a $8 \times 8$ chess board by strings where a square with a queen is represented by 'Q' and an empty square is represented by '.'.
s557403065
Accepted
p02244
In the first line, an integer $k$ is given. In the following $k$ lines, each square where a queen is already placed is given by two integers $r$ and $c$. $r$ and $c$ respectively denotes the row number and the column number. The row/column numbers start with 0.
# -*- coding:utf-8 -*- def solve(): import itertools import copy K = int(input()) grid = [[0 for i in range(8)] for j in range(8)] def put_queen(grid, r, c): for j in range(8): grid[r][j] = -1 for i in range(8): grid[i][c] = -1 # 左上 i, j = r - 1, c - 1 while i >= 0 and j >= 0: grid[i][j] = -1 i, j = i - 1, j - 1 # 左下 i, j = r + 1, c - 1 while i < 8 and j >= 0: grid[i][j] = -1 i, j = i + 1, j - 1 # 右上 i, j = r - 1, c + 1 while i >= 0 and j < 8: grid[i][j] = -1 i, j = i - 1, j + 1 # 右下 i, j = r + 1, c + 1 while i < 8 and j < 8: grid[i][j] = -1 i, j = i + 1, j + 1 grid[r][c] = 1 for i in range(K): r, c = list(map(int, input().split())) put_queen(grid, r, c) # 8!を全探索 ps = itertools.permutations([i for i in range(8)], r=8) for p in ps: ans_grid = copy.deepcopy(grid) is_ok = True for i in range(8): if ans_grid[i][p[i]] == 1: continue if ans_grid[i][p[i]] == -1: is_ok = False break put_queen(ans_grid, i, p[i]) if is_ok: break # ans_gridを出力して終了 for i in range(8): s = "" for j in range(8): if ans_grid[i][j] == 1: s += "Q" else: s += "." print(s) if __name__ == "__main__": solve()
8 Queens Problem The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ALDS1_13_A_8queens) For a given chess board where $k$ queens are already placed, find the solution of the 8 queens problem.
[{"input": "2\n 2 2\n 5 3", "output": "......Q.\n Q.......\n ..Q.....\n .......Q\n .....Q..\n ...Q....\n .Q......\n ....Q..."}]
Print a $8 \times 8$ chess board by strings where a square with a queen is represented by 'Q' and an empty square is represented by '.'.
s177505366
Accepted
p02244
In the first line, an integer $k$ is given. In the following $k$ lines, each square where a queen is already placed is given by two integers $r$ and $c$. $r$ and $c$ respectively denotes the row number and the column number. The row/column numbers start with 0.
from itertools import product def setq(ri, ci, krc): for ir in range(8): if ir != ri: if krc[ir * 8 + ci] == "Q": return False, krc else: krc[ir * 8 + ci] = "X" for ic in range(8): if ic != ci: if krc[ri * 8 + ic] == "Q": return False, krc else: krc[ri * 8 + ic] = "X" for ix in range(-7, 7, 1): ir = ri + ix ic = ci + ix if 0 <= ir and ir <= 7 and ir != ri: if 0 <= ic and ic <= 7 and ic != ci: if krc[ir * 8 + ic] == "Q": return False, krc else: krc[ir * 8 + ic] = "X" ir = ri - ix ic = ci + ix if 0 <= ir and ir <= 7 and ir != ri: if 0 <= ic and ic <= 7 and ic != ci: if krc[ir * 8 + ic] == "Q": return False, krc else: krc[ir * 8 + ic] = "X" return True, krc def chki(i, krc): krc = [""] * 64 for j in range(8): krc[j * 8 + i[j]] = "Q" bl, krc = setq(j, i[j], krc) # print(j,bl) # prk(krc) if not bl: # print(bl,i,"-------------------") # prk(krc) return False # print(bl,i,"-------------------") # prk(krc) return True def prk(krc2): for i in range(8): print(krc2[i * 8 : (i + 1) * 8]) icase = 0 kr = [[] for i in range(8)] if icase == 0: k = int(input()) krc = [""] * 64 for i in range(k): ri, ci = map(int, input().split()) krc[ri * 8 + ci] = "Q" setq(ri, ci, krc) kr[ri].append(ci) elif icase == 1: k = 2 krc = [""] * 64 ri, ci = 2, 2 krc[ri * 8 + ci] = "Q" setq(ri, ci, krc) kr[ri].append(ci) ri, ci = 5, 3 krc[ri * 8 + ci] = "Q" setq(ri, ci, krc) kr[ri].append(ci) # prk(krc) icnt = 0 for ir in range(8): for ic in range(8): i = ir * 8 + ic if krc[i] == "": kr[ir].append(ic) for i in product(kr[0], kr[1], kr[2], kr[3], kr[4], kr[5], kr[6], kr[7]): yn = "" krc2 = [""] * 64 if not chki(i, krc2): yn = "no" continue else: break if yn != "no": for ir in range(8): sti = ["."] * 8 sti[i[ir]] = "Q" stii = "".join(sti) print(stii)
8 Queens Problem The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ALDS1_13_A_8queens) For a given chess board where $k$ queens are already placed, find the solution of the 8 queens problem.
[{"input": "2\n 2 2\n 5 3", "output": "......Q.\n Q.......\n ..Q.....\n .......Q\n .....Q..\n ...Q....\n .Q......\n ....Q..."}]
Print a $8 \times 8$ chess board by strings where a square with a queen is represented by 'Q' and an empty square is represented by '.'.
s485416083
Accepted
p02244
In the first line, an integer $k$ is given. In the following $k$ lines, each square where a queen is already placed is given by two integers $r$ and $c$. $r$ and $c$ respectively denotes the row number and the column number. The row/column numbers start with 0.
import copy as cp N = 8 ans = [] def out(M): for i in range(N): for j in range(N): print(M[i][j], end="") print("") def DFS(r, c, dp, dn, qn): global ans if qn == N: for h in range(N): for w in range(N): if r[h] & c[w] & dp[h + w] & dn[w - h + 7]: ans.append([h, w]) return True return False for h in range(N): for w in range(N): if r[h] & c[w] & dp[h + w] & dn[w - h + 7]: new_r = cp.deepcopy(r) new_c = cp.deepcopy(c) new_dp = cp.deepcopy(dp) new_dn = cp.deepcopy(dn) new_r[h], new_c[w], new_dp[h + w], new_dn[w - h + 7] = ( False, False, False, False, ) if DFS(new_r, new_c, new_dp, new_dn, qn + 1): ans.append([h, w]) return True return False def main(): row = [True] * N col = [True] * N dp = [True] * (2 * N - 1) dn = [True] * (2 * N - 1) k = int(input()) MAP = [["." for _ in range(N)] for __ in range(N)] for _ in range(k): h, w = map(int, input().split()) MAP[h][w] = "Q" row[h] = False col[w] = False dp[w + h] = False dn[w - h + 7] = False DFS(row, col, dp, dn, k + 1) for h, w in ans: MAP[h][w] = "Q" out(MAP) main()
8 Queens Problem The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ALDS1_13_A_8queens) For a given chess board where $k$ queens are already placed, find the solution of the 8 queens problem.
[{"input": "2\n 2 2\n 5 3", "output": "......Q.\n Q.......\n ..Q.....\n .......Q\n .....Q..\n ...Q....\n .Q......\n ....Q..."}]
Print a $8 \times 8$ chess board by strings where a square with a queen is represented by 'Q' and an empty square is represented by '.'.
s787570676
Accepted
p02244
In the first line, an integer $k$ is given. In the following $k$ lines, each square where a queen is already placed is given by two integers $r$ and $c$. $r$ and $c$ respectively denotes the row number and the column number. The row/column numbers start with 0.
from itertools import permutations import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines def main(): k, *rc = map(int, read().split()) tmp = [] ng_list_add = [] ng_list_sub = [] for pattern in permutations(range(8)): flag = True for r, c in enumerate(pattern): if r + c in ng_list_add or r - c in ng_list_sub: flag = False break ng_list_add.append(r + c) ng_list_sub.append(r - c) if flag: tmp.append(pattern) ng_list_add = [] ng_list_sub = [] RC = [] for r, c in zip(*[iter(rc)] * 2): RC.append((r, c)) ans_place = None for p in tmp: flag = True for r, c in RC: if p[r] != c: flag = False break if flag: ans_place = p break ans = [] for i in ans_place: line = "." * i + "Q" + "." * (7 - i) ans.append(line) print("\n".join(ans)) if __name__ == "__main__": main()
8 Queens Problem The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ALDS1_13_A_8queens) For a given chess board where $k$ queens are already placed, find the solution of the 8 queens problem.
[{"input": "2\n 2 2\n 5 3", "output": "......Q.\n Q.......\n ..Q.....\n .......Q\n .....Q..\n ...Q....\n .Q......\n ....Q..."}]
Print a $8 \times 8$ chess board by strings where a square with a queen is represented by 'Q' and an empty square is represented by '.'.
s176912100
Accepted
p02244
In the first line, an integer $k$ is given. In the following $k$ lines, each square where a queen is already placed is given by two integers $r$ and $c$. $r$ and $c$ respectively denotes the row number and the column number. The row/column numbers start with 0.
from itertools import permutations k = int(input()) points = {tuple(map(int, input().split())) for _ in range(k)} for perm in permutations(range(8), 8): test = {(i, perm[i]) for i in range(8)} if test & points == points: flg = 0 for x, y in test: diag = ( {(x - i, y - i) for i in range(1, min(x, y) + 1)} | {(x + i, y + i) for i in range(1, min(7 - x, 7 - y) + 1)} | {(x - i, y + i) for i in range(1, min(x, 7 - y) + 1)} | {(x - i, y + i) for i in range(1, min(7 - x, y) + 1)} ) if diag & test == set(): flg += 1 if flg == 8: ans = test break for i in range(8): col = "" for j in range(8): if (i, j) in ans: col += "Q" else: col += "." print(col)
8 Queens Problem The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ALDS1_13_A_8queens) For a given chess board where $k$ queens are already placed, find the solution of the 8 queens problem.
[{"input": "2\n 2 2\n 5 3", "output": "......Q.\n Q.......\n ..Q.....\n .......Q\n .....Q..\n ...Q....\n .Q......\n ....Q..."}]
Print a $8 \times 8$ chess board by strings where a square with a queen is represented by 'Q' and an empty square is represented by '.'.
s823256348
Accepted
p02244
In the first line, an integer $k$ is given. In the following $k$ lines, each square where a queen is already placed is given by two integers $r$ and $c$. $r$ and $c$ respectively denotes the row number and the column number. The row/column numbers start with 0.
import itertools import copy def is_safe(qweens): x = [] y = [] for q in qweens: x.append(q[0]) y.append(q[1]) if len(set(x)) + len(set(y)) != len(qweens) * 2: return False for q1, q2 in itertools.combinations(qweens, 2): slope = (q1[0] - q2[0]) / (q1[1] - q2[1]) if slope == 1 or slope == -1: return False return True def print_boad(qweens): for r in range(8): for c in range(8): if (r, c) in qweens: print("Q", end="") else: print(".", end="") print("") k = int(input()) cand = [[(r, c) for c in range(8)] for r in range(8)] init_qweens = [] for _ in range(k): pos = tuple(map(int, input().split())) for r in range(8): for c in range(8): try: cand[r].remove((pos[0], c)) except ValueError: pass try: cand[r].remove((r, pos[1])) except ValueError: pass init_qweens.append(pos) for r in range(7, -1, -1): if cand[r] == []: cand.pop(r) qweens = [] for per in itertools.permutations([i for i in range(8 - k)]): qweens = copy.deepcopy(init_qweens) for r, c in enumerate(per): qweens.append(cand[r][c]) if is_safe(qweens): break print_boad(qweens)
8 Queens Problem The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ALDS1_13_A_8queens) For a given chess board where $k$ queens are already placed, find the solution of the 8 queens problem.
[{"input": "2\n 2 2\n 5 3", "output": "......Q.\n Q.......\n ..Q.....\n .......Q\n .....Q..\n ...Q....\n .Q......\n ....Q..."}]
Print a $8 \times 8$ chess board by strings where a square with a queen is represented by 'Q' and an empty square is represented by '.'.
s092449153
Accepted
p02244
In the first line, an integer $k$ is given. In the following $k$ lines, each square where a queen is already placed is given by two integers $r$ and $c$. $r$ and $c$ respectively denotes the row number and the column number. The row/column numbers start with 0.
import sys import copy k = int(input()) class Chessboard: def __init__(self): self.row = [True] * 8 self.col = [True] * 8 self.dpos = [True] * 15 self.dneg = [True] * 15 return def put(self, r, c): # queen が r, c に配置されたときに攻撃されるマスの記録 self.row[r] = False self.col[c] = False self.dpos[r + c] = False # 左下が攻撃される self.dneg[r + 7 - c] = False # 右下が攻撃される return def safe(self, r, c): # r, c が攻撃されていないか確認する 攻撃されていないときTrue を返す return self.row[r] and self.col[c] and self.dpos[r + c] and self.dneg[r + 7 - c] def is_row(self, r): return self.row[r] board = Chessboard() ans = [["."] * 8 for _ in range(8)] for _ in range(k): r, c = map(int, sys.stdin.readline().strip().split()) board.put(r, c) ans[r][c] = "Q" final_ans = None def search(r=0, board=board, ans=ans): global final_ans if r == 8: # 最終行を終了し探索する行が存在しないときに終了する final_ans = ans return ans if not board.is_row(r): # すでに Q が配置されている行の探索はスキップする search(r=r + 1, board=board, ans=ans) for c in range(8): board_temp = copy.deepcopy(board) ans_temp = copy.deepcopy(ans) if board_temp.safe(r, c): board_temp.put(r, c) ans_temp[r][c] = "Q" search(r=r + 1, board=board_temp, ans=ans_temp) else: continue ans = search() for r_ans in final_ans: print("".join(r_ans))
8 Queens Problem The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ALDS1_13_A_8queens) For a given chess board where $k$ queens are already placed, find the solution of the 8 queens problem.
[{"input": "2\n 2 2\n 5 3", "output": "......Q.\n Q.......\n ..Q.....\n .......Q\n .....Q..\n ...Q....\n .Q......\n ....Q..."}]
Print a $8 \times 8$ chess board by strings where a square with a queen is represented by 'Q' and an empty square is represented by '.'.
s860057962
Accepted
p02244
In the first line, an integer $k$ is given. In the following $k$ lines, each square where a queen is already placed is given by two integers $r$ and $c$. $r$ and $c$ respectively denotes the row number and the column number. The row/column numbers start with 0.
def try_set(v): def print_board(): for r, c in preset: if queen_pos[r] != c: return for pos in queen_pos: for c in range(8): print("Q" if c == pos else ".", end="") print() for h in range(8): if all((horizontal[h], dip_positive[v + h], dip_negative[v - h + 7])): queen_pos[v] = h if v == 7: print_board() else: horizontal[h] = dip_positive[v + h] = dip_negative[v - h + 7] = False try_set(v + 1) horizontal[h] = dip_positive[v + h] = dip_negative[v - h + 7] = True n = int(input()) queen_pos = [None] * 8 preset = [[pre for pre in map(int, input().split())] for _ in range(n)] horizontal = [True] * 8 dip_positive = [True] * 15 dip_negative = [True] * 15 try_set(0)
8 Queens Problem The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ALDS1_13_A_8queens) For a given chess board where $k$ queens are already placed, find the solution of the 8 queens problem.
[{"input": "2\n 2 2\n 5 3", "output": "......Q.\n Q.......\n ..Q.....\n .......Q\n .....Q..\n ...Q....\n .Q......\n ....Q..."}]
Print the maximum possible difference in the number of balls received. * * *
s750187314
Wrong Answer
p03005
Input is given from Standard Input in the following format: N K
A, B = map(int, input().split()) print(A - B)
Statement Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
[{"input": "3 2", "output": "1\n \n\nThe only way to distribute three balls to two persons so that each of them\nreceives at least one ball is to give one ball to one person and give two\nballs to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\n* * *"}, {"input": "3 1", "output": "0\n \n\nWe have no choice but to give three balls to the only person, in which case\nthe difference in the number of balls received is 0.\n\n* * *"}, {"input": "8 5", "output": "3\n \n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of\nballs received between the person with the most balls and the person with the\nfewest balls would be 3, which is the maximum result."}]
Print the maximum possible difference in the number of balls received. * * *
s837826304
Accepted
p03005
Input is given from Standard Input in the following format: N K
import sys sys.setrecursionlimit(10000) mod = 1000000007 def mul(a, b): return ((a % mod) * (b % mod)) % mod def power(x, y): if y == 0: return 1 elif y == 1: return x % mod elif y % 2 == 0: return power(x, y / 2) ** 2 % mod else: return power(x, y / 2) ** 2 * x % mod def div(a, b): return mul(a, power(b, mod - 2)) # def gcd(a_gcd, b_gcd): # while b_gcd != 0: # a_gcd, b_gcd = b_gcd, a_gcd % b_gcd # return a_gcd # # # def lcm(a_lcm, b_lcm): # return a_lcm * b // gcd(a_lcm, b_lcm) # # # def max_sum(N_max_sum, a_max_sum): # dp = [0] * (N_max_sum + 1) # for i in range(N_max_sum): # dp[i + 1] = max(dp[i], dp[i] + a_max_sum[i]) # return dp[N] # # # def knapsack(N_knapsack, W, weight, value): # inf = float("inf") # dp = [[-inf for _ in range(W+1)] for j in range(N_knapsack + 1)] # for i in range(W+1): # dp[0][i] = 0 # # for i in range(N_knapsack): # for w in range(W+1): # if weight[i] <= w: # dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w]) # else: # dp[i+1][w] = dp[i][w] # return dp[N_knapsack][W] # # # class UnionFind: # def __init__(self, n): # self.par = [i for i in range(n+1)] # self.rank = [0] * (n+1) # # # 検索 # def find(self, x): # if self.par[x] == x: # return x # else: # self.par[x] = self.find(self.par[x]) # return self.par[x] # # # 併合 # def union(self, x, y): # x = self.find(x) # y = self.find(y) # if self.rank[x] < self.rank[y]: # self.par[x] = y # else: # self.par[y] = x # if self.rank[x] == self.rank[y]: # self.rank[x] += 1 # # # 同じ集合に属するか判定 # def same_check(self, x, y): # return self.find(x) == self.find(y) ans = 0 N, K = map(int, input().split()) if K == 1: print("0") else: print(N - K)
Statement Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
[{"input": "3 2", "output": "1\n \n\nThe only way to distribute three balls to two persons so that each of them\nreceives at least one ball is to give one ball to one person and give two\nballs to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\n* * *"}, {"input": "3 1", "output": "0\n \n\nWe have no choice but to give three balls to the only person, in which case\nthe difference in the number of balls received is 0.\n\n* * *"}, {"input": "8 5", "output": "3\n \n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of\nballs received between the person with the most balls and the person with the\nfewest balls would be 3, which is the maximum result."}]
Print the maximum possible difference in the number of balls received. * * *
s160819520
Runtime Error
p03005
Input is given from Standard Input in the following format: N K
N = int(input()) A = [int(i) for i in input().split()] A = sorted(A) removeNums = [] for i in range(len(A) - 1): newValue = A[0] - A[-1] removeNums.append((A[0], A[-1])) A.remove(A[0]) A.remove(A[-1]) A.insert(0, newValue) print(-1 * A[0]) for i in range(len(removeNums) - 1): print(removeNums[i][0], removeNums[i][1]) print(removeNums[-1][1], removeNums[-1][0])
Statement Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
[{"input": "3 2", "output": "1\n \n\nThe only way to distribute three balls to two persons so that each of them\nreceives at least one ball is to give one ball to one person and give two\nballs to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\n* * *"}, {"input": "3 1", "output": "0\n \n\nWe have no choice but to give three balls to the only person, in which case\nthe difference in the number of balls received is 0.\n\n* * *"}, {"input": "8 5", "output": "3\n \n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of\nballs received between the person with the most balls and the person with the\nfewest balls would be 3, which is the maximum result."}]
Print the maximum possible difference in the number of balls received. * * *
s762230038
Runtime Error
p03005
Input is given from Standard Input in the following format: N K
#!/usr/bin/env python N = int(input()) A = [int(i) for i in input().split()] if N == 2: print(max(A) - min(A)) print(max(A), min(A)) else: A.sort() As = [] t = A[0] for a in A[1:-1]: As.append([t, a]) t = t - a ans = A[-1] - t As.append([A[-1], t]) print(ans) for a in As: print(*a)
Statement Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
[{"input": "3 2", "output": "1\n \n\nThe only way to distribute three balls to two persons so that each of them\nreceives at least one ball is to give one ball to one person and give two\nballs to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\n* * *"}, {"input": "3 1", "output": "0\n \n\nWe have no choice but to give three balls to the only person, in which case\nthe difference in the number of balls received is 0.\n\n* * *"}, {"input": "8 5", "output": "3\n \n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of\nballs received between the person with the most balls and the person with the\nfewest balls would be 3, which is the maximum result."}]
Print the maximum possible difference in the number of balls received. * * *
s495684815
Runtime Error
p03005
Input is given from Standard Input in the following format: N K
import fractions N = int(input()) sheet = [] for i in range(N): line = input().split() sheet += [(int(line[0]), int(line[1]))] dic = {} for i in range(N): start = sheet[i] for j in range(i + 1, N): vec = [(sheet[j][0] - start[0]), (sheet[j][1] - start[1])] size = fractions.gcd(vec[0], vec[1]) vec[0] = vec[0] // size vec[1] = vec[1] // size vec = tuple(vec) if vec not in dic.keys(): dic[vec] = set([j]) else: dic[vec].add(j) m = 1 for s in dic.values(): if len(s) > m: m = len(s) print(N - m)
Statement Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
[{"input": "3 2", "output": "1\n \n\nThe only way to distribute three balls to two persons so that each of them\nreceives at least one ball is to give one ball to one person and give two\nballs to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\n* * *"}, {"input": "3 1", "output": "0\n \n\nWe have no choice but to give three balls to the only person, in which case\nthe difference in the number of balls received is 0.\n\n* * *"}, {"input": "8 5", "output": "3\n \n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of\nballs received between the person with the most balls and the person with the\nfewest balls would be 3, which is the maximum result."}]
Print the maximum possible difference in the number of balls received. * * *
s543128438
Accepted
p03005
Input is given from Standard Input in the following format: N K
import sys sys.setrecursionlimit(10**7) INF = 10**18 MOD = 10**9 + 7 def YesNo(x): return "Yes" if x else "No" def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def II(): return int(sys.stdin.readline()) def SI(): return input() def main(): N, K = LI() ans = (N - K) if K > 1 else 0 return ans print(main())
Statement Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
[{"input": "3 2", "output": "1\n \n\nThe only way to distribute three balls to two persons so that each of them\nreceives at least one ball is to give one ball to one person and give two\nballs to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\n* * *"}, {"input": "3 1", "output": "0\n \n\nWe have no choice but to give three balls to the only person, in which case\nthe difference in the number of balls received is 0.\n\n* * *"}, {"input": "8 5", "output": "3\n \n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of\nballs received between the person with the most balls and the person with the\nfewest balls would be 3, which is the maximum result."}]
Print the maximum possible difference in the number of balls received. * * *
s160635238
Wrong Answer
p03005
Input is given from Standard Input in the following format: N K
n, k = input().split(" ") n, k = int(n), int(k) maxval = k - n minval = k / n print(maxval - minval)
Statement Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
[{"input": "3 2", "output": "1\n \n\nThe only way to distribute three balls to two persons so that each of them\nreceives at least one ball is to give one ball to one person and give two\nballs to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\n* * *"}, {"input": "3 1", "output": "0\n \n\nWe have no choice but to give three balls to the only person, in which case\nthe difference in the number of balls received is 0.\n\n* * *"}, {"input": "8 5", "output": "3\n \n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of\nballs received between the person with the most balls and the person with the\nfewest balls would be 3, which is the maximum result."}]
Print the maximum possible difference in the number of balls received. * * *
s106827333
Wrong Answer
p03005
Input is given from Standard Input in the following format: N K
nb_balls, nb_person = [int(x) for x in input().split()] mins = 1 maxs = (nb_balls - nb_person) + 1 print(maxs - mins)
Statement Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
[{"input": "3 2", "output": "1\n \n\nThe only way to distribute three balls to two persons so that each of them\nreceives at least one ball is to give one ball to one person and give two\nballs to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\n* * *"}, {"input": "3 1", "output": "0\n \n\nWe have no choice but to give three balls to the only person, in which case\nthe difference in the number of balls received is 0.\n\n* * *"}, {"input": "8 5", "output": "3\n \n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of\nballs received between the person with the most balls and the person with the\nfewest balls would be 3, which is the maximum result."}]
Print the maximum possible difference in the number of balls received. * * *
s402846237
Accepted
p03005
Input is given from Standard Input in the following format: N K
# !/usr/bin/env python3 # encoding: UTF-8 # Modified: <15/Jun/2019 05:31:28 PM> # ✪ H4WK3yE乡 # Mohd. Farhan Tahir # Indian Institute Of Information Technology (IIIT), Gwalior import sys import os from io import IOBase, BytesIO def main(): n, k = get_ints() if k == 1: print(0) return left = n - k print(left) BUFSIZE = 8192 class FastIO(BytesIO): newlines = 0 def __init__(self, file): self._file = file self._fd = file.fileno() self.writable = "x" in file.mode or "w" in file.mode self.write = super(FastIO, self).write if self.writable else None def _fill(self): s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0]) return s def read(self): while self._fill(): pass return super(FastIO, self).read() def readline(self): while self.newlines == 0: s = self._fill() self.newlines = s.count(b"\n") + (not s) self.newlines -= 1 return super(FastIO, self).readline() def flush(self): if self.writable: os.write(self._fd, self.getvalue()) self.truncate(0), self.seek(0) class IOWrapper(IOBase): def __init__(self, file): py2 = round(0.5) self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable if py2: self.write = self.buffer.write self.read = self.buffer.read self.readline = self.buffer.readline else: 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) def get_array(): return list(map(int, sys.stdin.readline().split())) def get_ints(): return map(int, sys.stdin.readline().split()) def input(): return sys.stdin.readline().strip() if __name__ == "__main__": main()
Statement Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
[{"input": "3 2", "output": "1\n \n\nThe only way to distribute three balls to two persons so that each of them\nreceives at least one ball is to give one ball to one person and give two\nballs to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\n* * *"}, {"input": "3 1", "output": "0\n \n\nWe have no choice but to give three balls to the only person, in which case\nthe difference in the number of balls received is 0.\n\n* * *"}, {"input": "8 5", "output": "3\n \n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of\nballs received between the person with the most balls and the person with the\nfewest balls would be 3, which is the maximum result."}]
Print the maximum possible difference in the number of balls received. * * *
s591147424
Runtime Error
p03005
Input is given from Standard Input in the following format: N K
from collections import deque plusQ = deque([]) minsQ = deque([]) N = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) for itr, val in enumerate(A): if itr + 1 <= (len(A) // 2) and val > 0: plusQ.append(val) else: minsQ.append(val) p1 = plusQ.popleft() ans = deque([]) while len(minsQ) > 0: if len(plusQ) > 0: p, m = plusQ.popleft(), minsQ.popleft() ans.append([m, p]) minsQ.append(m - p) else: m = minsQ.popleft() ans.append([p1, m]) p1 = p1 - m print(p1) while len(ans) > 0: hoge = ans.popleft() print(hoge[0], hoge[1])
Statement Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
[{"input": "3 2", "output": "1\n \n\nThe only way to distribute three balls to two persons so that each of them\nreceives at least one ball is to give one ball to one person and give two\nballs to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\n* * *"}, {"input": "3 1", "output": "0\n \n\nWe have no choice but to give three balls to the only person, in which case\nthe difference in the number of balls received is 0.\n\n* * *"}, {"input": "8 5", "output": "3\n \n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of\nballs received between the person with the most balls and the person with the\nfewest balls would be 3, which is the maximum result."}]
Print the maximum possible difference in the number of balls received. * * *
s220312784
Runtime Error
p03005
Input is given from Standard Input in the following format: N K
import sys input = sys.stdin.readline N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) dp = [0] * (N + 1) for i in range(N, -1, -1): for j in range(3): x = a[j] y = b[j] if i - x >= 0: dp[i - x] = max(dp[i - x], dp[i] + y) for i in range(N + 1): dp[i] += i # print(dp) t = max(dp) e = [] def check(x): tt = t - b[e[0]] * x return (tt // b[e[1]]) * a[e[1]] + tt % b[e[1]] + a[e[0]] * x if t > N: for i in range(3): if b[i] < a[i]: e.append(i) if len(e) == 0: print(t) elif len(e) == 1: print(a[e[0]] * (t // b[e[0]]) + t % b[e[0]]) else: if b[e[0]] < b[e[1]]: e[0], e[1] = e[1], e[0] x = e[0] res = 0 for i in range(t // b[x] + 1): res = max(res, check(i)) print(res) else: dp = [0] * (N + 1) for i in range(N, -1, -1): for j in range(3): y = a[j] x = b[j] if i - x >= 0: dp[i - x] = max(dp[i - x], dp[i] + y) for i in range(N + 1): dp[i] += i print(max(dp))
Statement Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
[{"input": "3 2", "output": "1\n \n\nThe only way to distribute three balls to two persons so that each of them\nreceives at least one ball is to give one ball to one person and give two\nballs to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\n* * *"}, {"input": "3 1", "output": "0\n \n\nWe have no choice but to give three balls to the only person, in which case\nthe difference in the number of balls received is 0.\n\n* * *"}, {"input": "8 5", "output": "3\n \n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of\nballs received between the person with the most balls and the person with the\nfewest balls would be 3, which is the maximum result."}]
Print the maximum possible difference in the number of balls received. * * *
s247735950
Runtime Error
p03005
Input is given from Standard Input in the following format: N K
from itertools import combinations from collections import Counter def main(): n = int(input()) if n == 1: print(1) XY = [list(map(int, input().split())) for _ in range(n)] d = [] for A, B in combinations(XY, 2): x1, y1 = A[0], A[1] x2, y2 = B[0], B[1] p, q = x2 - x1, y2 - y1 d.append((p, q)) d.append((-p, -q)) # print(d) # print(Counter(d)) C = Counter(d) ans = 0 for v in C.values(): ans = max(ans, v) print(n - ans) if __name__ == "__main__": main()
Statement Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
[{"input": "3 2", "output": "1\n \n\nThe only way to distribute three balls to two persons so that each of them\nreceives at least one ball is to give one ball to one person and give two\nballs to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\n* * *"}, {"input": "3 1", "output": "0\n \n\nWe have no choice but to give three balls to the only person, in which case\nthe difference in the number of balls received is 0.\n\n* * *"}, {"input": "8 5", "output": "3\n \n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of\nballs received between the person with the most balls and the person with the\nfewest balls would be 3, which is the maximum result."}]
Print the maximum possible difference in the number of balls received. * * *
s551158798
Runtime Error
p03005
Input is given from Standard Input in the following format: N K
N = int(input()) A = list(map(int, input().split())) A.sort() if A[1] >= 0: print(sum(A) - 2 * A[0]) y = A[0] for i in range(N - 2): print(y, A[i + 1]) y -= A[i + 1] print(A[-1], y) elif A[-1] < 0: print(-sum(A) + 2 * A[-1]) y = A[-1] for i in range(N - 1): print(y, A[i]) y -= A[i] else: for i in range(N - 1): if A[i] < 0 and A[i + 1] >= 0: n = i print(-sum(A[:i]) + sum(A[i:])) y = A[0] for i in range(N - n - 2): print(y, A[-i - 2]) y -= A[-i - 2] print(A[-1], y) y = A[-1] - y for i in range(n): print(y, A[i + 1])
Statement Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
[{"input": "3 2", "output": "1\n \n\nThe only way to distribute three balls to two persons so that each of them\nreceives at least one ball is to give one ball to one person and give two\nballs to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\n* * *"}, {"input": "3 1", "output": "0\n \n\nWe have no choice but to give three balls to the only person, in which case\nthe difference in the number of balls received is 0.\n\n* * *"}, {"input": "8 5", "output": "3\n \n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of\nballs received between the person with the most balls and the person with the\nfewest balls would be 3, which is the maximum result."}]
Print the maximum possible difference in the number of balls received. * * *
s007980802
Runtime Error
p03005
Input is given from Standard Input in the following format: N K
N = int(input()) XY = [list(map(int, input().split())) for _ in range(N)] def gdb(a, b): a, b = abs(a), abs(b) while b: a, b = b, a % b return a def make_slope(a, b): if a == 0: print("error") elif a > 0: return (a // gdb(a, b), b // gdb(a, b)) elif a < 0: return (-1 * a // gdb(a, b), -1 * b // gdb(a, b)) slope_list = [] for i in range(1, N): for j in range(i): x1, y1 = XY[i] x2, y2 = XY[j] d_x = x2 - x1 d_y = y2 - y1 if d_x != 0: d_x, d_y = make_slope(d_x, d_y) if not ([d_x, d_y] in slope_list): slope_list.append([d_x, d_y]) if N <= 2: print(1) else: tmp = [] for x, y in XY: if not (x in tmp): tmp.append(x) ans = len(tmp) for d_x, d_y in slope_list: XY_list = [] for x1, y1 in XY: if XY_list == []: XY_list.append([x1, y1]) else: for x2, y2 in XY_list: d_x_tmp = x2 - x1 d_y_tmp = y2 - y1 if d_x_tmp == 0: break d_x_tmp, d_y_tmp = make_slope(d_x_tmp, d_y_tmp) if d_x_tmp == d_x and d_y_tmp == d_y: break else: XY_list.append([x1, y1]) ans = min(ans, len(XY_list)) print(ans)
Statement Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
[{"input": "3 2", "output": "1\n \n\nThe only way to distribute three balls to two persons so that each of them\nreceives at least one ball is to give one ball to one person and give two\nballs to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\n* * *"}, {"input": "3 1", "output": "0\n \n\nWe have no choice but to give three balls to the only person, in which case\nthe difference in the number of balls received is 0.\n\n* * *"}, {"input": "8 5", "output": "3\n \n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of\nballs received between the person with the most balls and the person with the\nfewest balls would be 3, which is the maximum result."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s882234532
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a=int(input()), b=int(input()) c=a*b c=int(c) if c%2==0: print("Even") if else: print("Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s043824721
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a = imput() b = imput() c = a * b if(c%2 == 1): print("Odd") elif(c%2 == 0): print("Even")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s135653011
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a,b=map(int,input().split()) if(a*b%2==0){ print("Even") } elif(a*b%2!=0){ print("Odd") }
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s598428054
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a = list(map(int,input().split())) if a[0]%2==0 || a[1]%2==0 : print("Even") else: print("Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s654055490
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a=int(input()), b=int(input()) c=a*b if c%2==0: print("Even") if else: print("Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s440259967
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
n,m = map(int,input().split() if (n*m)%2 ==0: print("Even") else: print(Odd)
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s944431149
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
# -*- coding: utf-8 -*- a,b=map(int,input().split()) if a*b%2=0: print('Even') else: print('Odd')
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s508977232
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a, b = map(int, input().split()) if((a*b) % 2 == 0){ print('Even') } else { print('Odd') }
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s838998751
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a,b = map(int,input().split()) if (a * b) / 2 %= 0: print("Even") else: print("Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s145391802
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a, b = map(int, input().split()) if (a * b) % 2 == 0: print("Even") else: print("Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s469811126
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a = int(input()) b = int(input()) if a%2 = 0 or b%2 =0: print("even") else: print("odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s005242553
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a, b = map(int, input().split()) mult = a * b if mult % 2 = 0: print('Even') else: print('Odd')
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s089302510
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a = imput() b = imput() c = a * b if(c%2 = 1): print("Odd") elif(c%2 = 0): print("Even)
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s047537044
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a = imput() b = imput() c = a * b if(c%1 = 1): print("Odd") else: print("Even")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s120387921
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a, b = input().split() a = int(a) b = int(b) print('Even' if a * b % == 0 else 'Odd')
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s353296080
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
x = input().split() y = int(x[0])*int(x[1]) if y%2 = 1: print("Odd") else: print("Even")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s370144609
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a = int(input()) b = int(input()) x=a*b if X%2==0; print("Even") else; print("Odd)
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s064186167
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a=int(input()), b=int(input()) if (a*b)%2==0: print("Even") if else: print("Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s115918946
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a, b = int (input().split()) c = a*b % 2 if c=1 : print("Odd") else: print("Even")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s220308447
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a, b = map(intm input().split()) if (a * b) % 2 == 0: print('Even') else: print('Odd')
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s357384103
Wrong Answer
p03455
Input is given from Standard Input in the following format: a b
def first(str): a, b = map(int, str.split()) print("Even" if a * b % 2 == 0 else "Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s129333304
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
x = split().input() y = int(x[0])*int(x[1]) if y%2 = 0: print(Even) else: print(Odd)
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s290644928
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a,b = map(int, input().split()) if a*b // 2 == 0: print('Even') else: print('Odd')
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s681404063
Accepted
p03455
Input is given from Standard Input in the following format: a b
print("Odd" if eval(input().replace(" ", "*")) % 2 else "Even")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s138847512
Accepted
p03455
Input is given from Standard Input in the following format: a b
print("Odd" if all(map(lambda x: int(x) % 2, input().split())) else "Even")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s477942422
Accepted
p03455
Input is given from Standard Input in the following format: a b
print(["Even", "Odd"][max(0, sum(map(lambda x: int(x) % 2, input().split())) - 1)])
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s961636997
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a,b=map(int,input().split()) if a*b %2=0: print("Even") else: print("Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s951885602
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a, b = map(int, input().split()) if (a*b)%2 == 0: print('Even') else: print('Odd')
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s960777144
Wrong Answer
p03455
Input is given from Standard Input in the following format: a b
print(["odd", "even"][eval(input().replace(" ", "*")) % 2 == 0])
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s901491210
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a = 20 b = map(int, input().split()) print("Odd" if a % b == 0)
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s633504216
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
print('OEdvde n'['0'in s:=input()or'4'in s::2])
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s770232773
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a,b = map(int,input().split()) if a*b%2 = 0: print("Even") else: print("Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s126557823
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
print('Odd' if eval(input().replace("",*)%2) else 'Even')
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s297119387
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a, b = map(int, input().split()) print("Even" if a*b % 2 == else "Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s189619853
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
if a*b/2 %= 0: print("Even") else: print("Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s164624125
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a,b=map(int,input().split()) if (a*b)%2 ==0: print('Even') else: print('Odd')
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s400972728
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
def main(); int a, b, c; c=a*b; if c%2==0; print(Even); else print(Odd);
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s582418349
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a, b =map (int, input().split) if a*b % 2 print("Odd") else print("Even")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s391048731
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
l = input().split() if l[0]*l[1]%2 ==0: print(Even) else: print(Odd)
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s298837844
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a,b=map(int,input().split()) if a*b%2=0: print("Even") else: print("Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s340309610
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a, b = input().split() a = int(a) b = int(b) print('Even' if a*b%==0 else 'Odd')
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s768543379
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
print("Even" if int(input()) * int(input()) % 2 == 0 else "Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s241594171
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a,b=map(int,input().split()) print("Even" if a*b % == 0 else "Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s123222341
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a, b = map(int, input().split()) print("Even" if a*b%==0 else "Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s043601798
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
if a*b/2 %= 0: print("Even") else: print("Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s711056780
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
print("Odd" if input() % 2 != 0 and input() % 2 != 0 else "Even")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s641581516
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
if a * b % == 0: print('Even') else: print('Odd')
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s866498021
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
print(["Even", "Odd"][max(0, sum(map(lambda x: int(x) % 2, input())) - 1)])
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s120445089
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a, b = map(int, input().split()) print(`Even` if a*b % 2 = 0 else `Odd`)
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s404635346
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a,b=map(int,input().split()) c=a*b if(c%0==0) print("even") else print("odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s298956896
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a, b = map(int, input().split()) print("Even" if a*b % 2 == else "Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s929633766
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a,b=map(int,input().split());print(["Even","Odd"][a*b%2]
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s123631653
Accepted
p03455
Input is given from Standard Input in the following format: a b
# coding: utf-8 # Your code here! # coding: utf-8 from fractions import gcd from functools import reduce import sys sys.setrecursionlimit(200000000) from inspect import currentframe # my functions here! # 標準エラー出力 def printargs2err(*args): names = {id(v): k for k, v in currentframe().f_back.f_locals.items()} print( ", ".join(names.get(id(arg), "???") + " : " + repr(arg) for arg in args), file=sys.stderr, ) def debug(x): print(x, file=sys.stderr) def printglobals(): for symbol, value in globals().items(): print('symbol="%s"、value=%s' % (symbol, value), file=sys.stderr) def printlocals(): for symbol, value in locals().items(): print('symbol="%s"、value=%s' % (symbol, value), file=sys.stderr) # 入力(後でいじる) def pin(type=int): return map(type, input().split()) """ """ # solution: # 繰り返し自乗法だよ # これはnのp乗をmで割ったあまりをだすよ def modular_w_binary_method(n, m, p): ans = 1 if n > 0 else 0 while p > 0: if p % 2 == 1: ans = (ans * n) % m n = (n**2) % m p //= 2 return ans # mod上でのaの逆元を出すよ """ フェルマーの小定理より a**(p)%p==a isTrue これを利用すれば a**(p-2)%p==a**(-1) isTrue 元と逆元とをかけてpで割れば1が余るよ! """ def modular_inverse(a, prime): return modular_w_binary_method(a, prime, prime - 2) # 逆元を使うと容易に頑張れるc def conbination(n, a, mod=10**9 + 7): # cはイラない res = 1 for s in range(a): res = (res * (n - s) * (modular_inverse(s + 1, mod))) % mod return res # 操作から作れるものの組み合わせは何個かー>同じものでも違う方法で構成できるかから考える方法もある # input def resolve(): a, b = pin() print(["Odd", "Even"][(a * b + 1) % 2]) return # print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM]) # if __name__=="__main__":resolve() """ #printデバッグ消した? #前の問題の結果見てないのに次の問題に行くの? """ """ お前カッコ閉じるの忘れてるだろ """ 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 = """3 4""" output = """Even""" self.assertIO(input, output) def test_入力例_2(self): input = """1 21""" output = """Odd""" self.assertIO(input, output) if __name__ == "__main__": resolve()
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s834289936
Accepted
p03455
Input is given from Standard Input in the following format: a b
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS(): return list(map(list, sys.stdin.readline().split())) def S(): return list(sys.stdin.readline())[:-1] def IR(n): l = [None for i in range(n)] for i in range(n): l[i] = I() return l def LIR(n): l = [None for i in range(n)] for i in range(n): l[i] = LI() return l def SR(n): l = [None for i in range(n)] for i in range(n): l[i] = S() return l def LSR(n): l = [None for i in range(n)] for i in range(n): l[i] = SR() return l sys.setrecursionlimit(1000000) mod = 1000000007 # A def A(): a, b = LI() if not (a * b) % 2: print("Even") else: print("Odd") return # B def B(): return # C def C(): return # D def D(): return # E def E(): return # F def F(): return # G def G(): return # H def H(): return # Solve if __name__ == "__main__": A()
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s429710758
Accepted
p03455
Input is given from Standard Input in the following format: a b
#!/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()) a, b = mi() print("Even") if a * b % 2 == 0 else print("Odd") if __name__ == "__main__": main()
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s202369931
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a,b=map(int,input().split()) if (a)%2 == 0: print("Even") else: print("Odd")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s064563318
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
ri = lambda: int(input()) rl = lambda: list(map(int, input().split())) rr = lambda N: [ri() for _ in range(N)] YN = lambda b: print("YES") if b else print("NO") INF = 10**18 N, K = rl() W = [[0 for _ in range(2 * K + 3)] for _ in range(2 * K + 3)] for i in range(N): x, y, c = input().split() x = int(x) % (2 * K) y = (int(y) if c == "W" else int(y) + K) % (2 * K) if (x < K) ^ (y < K): x %= K y %= K W[0][y + 1] += 1 W[x + 1][y + 1] -= 2 W[0][K + 1] -= 1 W[x + 1][K + 1] += 1 W[x + 1][0] += 1 W[K + 1][0] -= 1 W[K + 1][y + 1] += 1 else: x %= K y %= K W[0][0] += 1 W[x + 1][0] -= 1 W[0][y + 1] -= 1 W[x + 1][y + 1] += 2 W[K + 1][y + 1] -= 1 W[x + 1][K + 1] -= 1 W[K + 1][K + 1] += 1 for x in range(0, K + 2): for y in range(1, K + 2): W[x][y] += W[x][y - 1] for y in range(0, K + 2): for x in range(1, K + 2): W[x][y] += W[x - 1][y] ans = 0 for x in range(K + 1): for y in range(K + 1): ans = max(ans, W[x][y]) print(ans)
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s832925833
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
# -*- coding: <encoding name> -*- a,b=map(int,input().split()) if a*b%2=0: print('Even') else: print('Odd')
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s679874758
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a = int(input()) b = int(input()) if a >= 1 and a <= 10000: if b >= 1 and <= 10000: if a*b % 2 == 0: print("Odd") else: print("Even")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s792260531
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a =input(); b = input(); c = str(a) + str(b) int i =1 while(i<=100): if(i*i ==int(c)): print('Yes') else: i=i+1 if(i==101); print("No)
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s558382257
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
N = int(input()) plan = [list(map(int, input().split())) for i in range(N)] m = 0 for i in range(N - 1): time = plan[i + 1][0] - plan[i][0] dist = abs(plan[i + 1][1] - plan[i][1]) + abs(plan[i + 1][2] - plan[i][2]) if time == 0: m = 1 break if dist > time: m = 1 break if dist % 2 != time % 2: m = 1 break print("Yes" if m == 0 else "No")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s290032123
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a, b = map(int.input().split()) answer = a * b if answer % == 0: print('Even') else: print('Odd')
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s384682336
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
t = [0] x = [0] y = [0] N = int(input()) for i in range(N): ti, xi, yi = map(int,input().split()) t.append(ti) x.append(xi) y.append(yi) flg = True for i in range(1,N+1): if (t[i]-t[i-1] < x[i]-x[i-1] + y[i]-y[i-1]): flg = False elif ((t[i]-t[i-1])%2 != (x[i]-x[i-1]+y[i]-y[i-1])%2): flg = False if(flg): print("Yes") else: print("No")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s628177810
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
N = int(input()) tl = [] xl = [] yl = [] al = [] bl = [] cl = [] dl = [] for i in range(N): t, x, y = map(int, input().split()) tl.append(t) xl.append(x) yl.append(y) al.append((x + y) % 2) bl.append(t % 2) for i in range(N): c = abs((xl[i] + yl[i]) - (xl[i - 1] + yl[i - 1])) d = abs(tl[i] - tl[i - 1]) cl.append(c) dl.append(d) count = 0 for i in range(N): if al[i] == bl[i] and (xl[i] + yl[i]) <= tl[i] and cl[i] <= dl[i]: count += 1 if count == N: print("Yes") else: print("No")
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]
If the product is odd, print `Odd`; if it is even, print `Even`. * * *
s299254038
Runtime Error
p03455
Input is given from Standard Input in the following format: a b
a, b = map(int, input().split()) def FizzBuzz(a, b): total = a*b if a*b%2 = 0: print('Even') else: print('Odd') FizzBuzz(a, b)
Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
[{"input": "3 4", "output": "Even\n \n\nAs 3 \u00d7 4 = 12 is even, print `Even`.\n\n* * *"}, {"input": "1 21", "output": "Odd\n \n\nAs 1 \u00d7 21 = 21 is odd, print `Odd`."}]