output_description
stringlengths
15
956
submission_id
stringlengths
10
10
status
stringclasses
3 values
problem_id
stringlengths
6
6
input_description
stringlengths
9
2.55k
attempt
stringlengths
1
13.7k
problem_description
stringlengths
7
5.24k
samples
stringlengths
2
2.72k
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s453196782
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a=int(input()) b=int(input()) h=int(input()) print((a+b)*h/2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s040047719
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a = int(input() b = int(input()) h = int(input()) print( (a+b)*h//2 )
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s953214614
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
=int(input()) b=int(input()) h=int(input()) s=(a+b)*h/2 print(int(s))
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s873491647
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
upperbase,bottom,high = map(int,input().split()) print((upperbase + bottom) * high / 2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s063379762
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a = int(input()) b = int(input()) h = int(input()) print(int((a+b*h/2))
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s535877818
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
(a + b) * h / 2
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s828031732
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a, b, h = map(int, inpuut().split()) print((a + b) * 2 / 2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s577609431
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a=int(input() b=int(input() h=int(input() print((a+b)*h//2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s075936673
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a,b,c=[int(input()) for_i in range(3)] print((a+b)*h//2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s563700829
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
print((input() + input()) * input() / 2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s561518021
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
[i for i in [a,b,h]=[int(input()) for i in range(3)] print((a+b)*h/2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s614249781
Accepted
p03997
The input is given from Standard Input in the following format: a b h
upper, lower, height = (int(input()) for i in range(3)) print(int((upper + lower) * height / 2))
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s196954995
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from heapq import heappop, heappush, heapify, heappushpop from bisect import bisect_left, bisect_right from itertools import permutations, combinations, product from operator import itemgetter, mul from copy import deepcopy from functools import reduce, partial from fractions import Fraction from string import ascii_lowercase, ascii_uppercase, digits def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) sys.setrecursionlimit(10 ** 9) INF = float('inf') MOD = 10 ** 9 + 7 a = INT() b = INT() h = INT() print(int((a+b)*h/2))import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from heapq import heappop, heappush, heapify, heappushpop from bisect import bisect_left, bisect_right from itertools import permutations, combinations, product from operator import itemgetter, mul from copy import deepcopy from functools import reduce, partial from fractions import Fraction from string import ascii_lowercase, ascii_uppercase, digits def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) sys.setrecursionlimit(10 ** 9) INF = float('inf') MOD = 10 ** 9 + 7 a = INT() b = INT() h = INT() print(int((a+b)*h/2))
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s419090036
Wrong Answer
p03997
The input is given from Standard Input in the following format: a b h
up = int(input()) down = int(input()) high = int(input()) area = ((up + down) * high) * 0.5 print(area)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s671201889
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a= int(input()) b= int(input()) k= int(input()) h= int(input()) h=2*k print((a+b)*h/2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s052264439
Accepted
p03997
The input is given from Standard Input in the following format: a b h
lis = [int(input()) for i in range(3)] print((lis[0] + lis[1]) * lis[2] // 2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s561546691
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
l=[int(input()) for in in range(3)] a=l[0] b=l[1] h=l[2] print((a+b)*h//2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s879136830
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a = int(input()) b = int(input()) h = int(input()) ans = (a+b)*h/2 print()ans
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s900025240
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a = int(input()) b = int(input()) h = int(input()) x = (a + b)h/2 print(x)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s398850352
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a = int(input()) b = int(input()) h = int(input()) print(int((a+b)*h/2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s781749947
Accepted
p03997
The input is given from Standard Input in the following format: a b h
print(int((int(input()) + int(input())) * int(input()) * 0.5))
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s255182830
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
return (a + b) * h / 2
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s388015477
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
(a + b)x h / 2
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s094028465
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
sumjk = a + b print(sumjk * h / 2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s360085820
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
int("(a+b)*h/2")
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s439060540
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
x=int(input() y=int(input() z=int(input() print((x+y)*z/2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s006419145
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
c = a + b print(c * h / 2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s130646518
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
print(int((int(input()) + int(input)) * int(input()) / 2))
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s575873810
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
A, B, C = map(int, input().split()) print((A + B) * C)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s998271581
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
print( (int(input()) + int(input()) * int(input()) // 2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s264881569
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a,b,c=[int(input()) for _ i in range(3)] print(int(a+b)*h/2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s303787600
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a,b,h=map(int,input().split()) print((((a+b)*h)//2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s225071740
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
def foo (a,b,h) x = 0 x += (a+ b) /2 x *= h return x
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s126068194
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a=int(input()) b=int(input()) h=int(input()) print(int(((a+b)*h/2))
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s069052433
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
x=[] for i in range(3): x[i]=int(input()) print((x[0]+x[1])*x[2]/2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s992643356
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a=int(input()) b=int(input()) h=int(input()) print(((a+b)*h)//2))
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s885857293
Accepted
p03997
The input is given from Standard Input in the following format: a b h
ue = int(input()) sita = int(input()) takasa = int(input()) men = (ue + sita) * takasa / 2 print(int(men))
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s561468799
Wrong Answer
p03997
The input is given from Standard Input in the following format: a b h
import itertools num = str(input()) olist = [int(i + 1) for i in range(len(num) - 1)] comblist = [] for i, _ in enumerate(olist, 1): for j in itertools.combinations(olist, r=i): comblist.append(j) L = [] for i in range(len(comblist)): t = num for j in range(len(comblist[i])): t = t[0 : comblist[i][j] + j] + "," + t[comblist[i][j] + j :] L.append(t) out = 0 for i in range(len(L)): t = L[i].split(",") for j in range(len(t)): out += int(t[j]) print(out + int(num))
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s479736510
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a = {i: list(input()) for i in "abc"} b = "a" while a[b]: b = a[b].pop(0) print(b.upper())
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s814819055
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
upperbase,bottom,high = map(int,input().split()) print((upperbase + bottom) * high / 2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s195683946
Wrong Answer
p03997
The input is given from Standard Input in the following format: a b h
A = list(input()) B = list(input()) C = list(input()) turn = A player = "A" while turn: if turn[0] == "a": turn = A if len(A) == 0: player = "A" break elif turn[0] == "b": turn = B if len(B) == 0: player = "B" break elif turn[0] == "c": turn = C if len(C) == 0: player = "C" break turn.pop(0) print(player)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s907623126
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
N = int(input()) S = [1 if a == "I" else -1 for a in input()] ma = 0 a = 0 for i in range(N): a += S[i] ma = max(ma, a) print(ma)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s744080020
Wrong Answer
p03997
The input is given from Standard Input in the following format: a b h
l = [int(input()) for _ in range(3)] print((l[0] + l[1]) // 2 * l[2])
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s098402587
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
upperbase, bottom, high = map(int, input().split()) print((upperbase + bottom) * high // 2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
For each query, print 1 if any element in $A$ is equivalent to $k$, and 0 otherwise.
s517232968
Wrong Answer
p02451
The input is given in the following format. $n$ $a_0 \; a_1 \; ,..., \; a_{n-1}$ $q$ $k_1$ $k_2$ : $k_q$ The number of elements $n$ and each element $a_i$ are given in the first line and the second line respectively. In the third line, the number of queries $q$ is given and the following $q$ lines, $q$ integers $k_i$ are given as queries.
n = int(input()) a = list(map(int, input().split(" "))) def binary_search(val): left, right = 0, n - 1 while right - left > 1: mid = (right + left) // 2 if a[mid] == val: return 1 if a[mid] < val: left = mid elif val < a[mid]: right = mid return 0 q = int(input()) for i in range(q): k = int(input()) print(binary_search(k))
Binary Search For a given sequence $A = \\{a_0, a_1, ..., a_{n-1}\\}$ which is sorted by ascending order, find a specific value $k$ given as a query.
[{"input": "4\n 1 2 2 4\n 3\n 2\n 3\n 5", "output": "1\n 0\n 0"}]
For each query, print 1 if any element in $A$ is equivalent to $k$, and 0 otherwise.
s318758090
Wrong Answer
p02451
The input is given in the following format. $n$ $a_0 \; a_1 \; ,..., \; a_{n-1}$ $q$ $k_1$ $k_2$ : $k_q$ The number of elements $n$ and each element $a_i$ are given in the first line and the second line respectively. In the third line, the number of queries $q$ is given and the following $q$ lines, $q$ integers $k_i$ are given as queries.
input() b = list(map(int, input().split())) def nibu(low, high, i): middle = (low + high) // 2 if b[middle] <= i: low = middle else: high = middle if low == high: if i == b[low]: return 1 else: return 0 a = int(input()) for i in range(a): k = int(input()) print(nibu(0, len(b), k))
Binary Search For a given sequence $A = \\{a_0, a_1, ..., a_{n-1}\\}$ which is sorted by ascending order, find a specific value $k$ given as a query.
[{"input": "4\n 1 2 2 4\n 3\n 2\n 3\n 5", "output": "1\n 0\n 0"}]
For each query, print 1 if any element in $A$ is equivalent to $k$, and 0 otherwise.
s989030108
Accepted
p02451
The input is given in the following format. $n$ $a_0 \; a_1 \; ,..., \; a_{n-1}$ $q$ $k_1$ $k_2$ : $k_q$ The number of elements $n$ and each element $a_i$ are given in the first line and the second line respectively. In the third line, the number of queries $q$ is given and the following $q$ lines, $q$ integers $k_i$ are given as queries.
n = int(input()) a = set(map(int, input().split())) q = int(input()) while q: q -= 1 k = int(input()) print(+(k in a))
Binary Search For a given sequence $A = \\{a_0, a_1, ..., a_{n-1}\\}$ which is sorted by ascending order, find a specific value $k$ given as a query.
[{"input": "4\n 1 2 2 4\n 3\n 2\n 3\n 5", "output": "1\n 0\n 0"}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s559443912
Accepted
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math # from math import gcd import bisect from collections import defaultdict from collections import deque from functools import lru_cache ############# # Constants # ############# MOD = 10**9 + 7 INF = float("inf") ############# # Functions # ############# ######INPUT###### def I(): return int(input().strip()) def S(): return input().strip() def IL(): return list(map(int, input().split())) def SL(): return list(map(str, input().split())) def ILs(n): return list(int(input()) for _ in range(n)) def SLs(n): return list(input().strip() for _ in range(n)) def ILL(n): return [list(map(int, input().split())) for _ in range(n)] def SLL(n): return [list(map(str, input().split())) for _ in range(n)] ######OUTPUT###### def P(arg): print(arg) return def Y(): print("Yes") return def N(): print("No") return def E(): exit() def PE(arg): print(arg) exit() def YE(): print("Yes") exit() def NE(): print("No") exit() #####Shorten##### def DD(arg): return defaultdict(arg) #####Inverse##### def inv(n): return pow(n, MOD - 2, MOD) ######Combination###### kaijo_memo = [] def kaijo(n): if len(kaijo_memo) > n: return kaijo_memo[n] if len(kaijo_memo) == 0: kaijo_memo.append(1) while len(kaijo_memo) <= n: kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD) return kaijo_memo[n] gyaku_kaijo_memo = [] def gyaku_kaijo(n): if len(gyaku_kaijo_memo) > n: return gyaku_kaijo_memo[n] if len(gyaku_kaijo_memo) == 0: gyaku_kaijo_memo.append(1) while len(gyaku_kaijo_memo) <= n: gyaku_kaijo_memo.append( gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD ) return gyaku_kaijo_memo[n] def nCr(n, r): if n == r: return 1 if n < r or r < 0: return 0 ret = 1 ret = ret * kaijo(n) % MOD ret = ret * gyaku_kaijo(r) % MOD ret = ret * gyaku_kaijo(n - r) % MOD return ret ######Factorization###### def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr == []: arr.append([n, 1]) return arr #####MakeDivisors###### def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) return divisors #####GCD##### def gcd(a, b): while b: a, b = b, a % b return a #####LCM##### def lcm(a, b): return a * b // gcd(a, b) #####BitCount##### def count_bit(n): count = 0 while n: n &= n - 1 count += 1 return count #####ChangeBase##### def base_10_to_n(X, n): if X // n: return base_10_to_n(X // n, n) + [X % n] return [X % n] def base_n_to_10(X, n): return sum(int(str(X)[-i]) * n**i for i in range(len(str(X)))) #####IntLog##### def int_log(n, a): count = 0 while n >= a: n //= a count += 1 return count ############# # Main Code # ############# N = I() data = [] for i in range(N): x, y, h = IL() data.append((x, y, h)) data = sorted(data, lambda x: x[2]) import itertools x, y, h = data.pop() dic = { (i, j): h + (abs(i - x) + abs(j - y)) for i, j in itertools.product(range(101), repeat=2) } while len(dic) > 1: x, y, h = data.pop() for i, j in itertools.product(range(101), repeat=2): if (i, j) in dic: if h > 0: if dic[(i, j)] != h + (abs(i - x) + abs(j - y)): dic.pop((i, j)) else: if dic[(i, j)] > h + (abs(i - x) + abs(j - y)): dic.pop((i, j)) ans = [k for k in dic][0] print(ans[0], ans[1], dic[ans])
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s555847929
Accepted
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
# -*- coding: utf-8 -*- import sys import math from bisect import bisect_left from bisect import bisect_right import collections import copy import heapq from collections import defaultdict from heapq import heappop, heappush import itertools input = sys.stdin.readline ##### リストの 二分木検索 ##### # bisect_left(lists, 3) # bisect_right(lists, 3) ##### プライオリティキュー ##### # heapq.heapify(a) #リストaのheap化 # heapq.heappush(a,x) #heap化されたリストaに要素xを追加 # heapq.heappop(a) #heap化されたリストaから最小値を削除&その最小値を出力 # heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう # heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと ##### タプルリストのソート ##### # sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順 # sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順 # sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順 # sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順 # sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順 # sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順 ##### 累乗 ##### # pow(x, y, z) -> x**y % z def inputInt(): return int(input()) def inputMap(): return map(int, input().split()) def inputList(): return list(map(int, input().split())) inf = float("inf") mod = 1000000007 # -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- def main(): N = inputInt() xyz = [] for i in range(N): x, y, h = inputMap() xyz.append((x, y, h)) for ansY in range(0, 101): for ansX in range(0, 101): ansH = -1 for i, val in enumerate(xyz): x, y, h = val if h > 0: tmp = h + abs(ansX - x) + abs(ansY - y) if ansH == -1: ansH = tmp else: if tmp != ansH: ansH = -2 break # print(ansH) if ansH == -2: continue for i, val in enumerate(xyz): x, y, h = val if h == 0: tmp = abs(ansX - x) + abs(ansY - y) if ansH > tmp: ansH = -2 break if ansH == -2: continue print("{} {} {}".format(ansX, ansY, ansH)) # -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- # special thanks : # https://nagiss.hateblo.jp/entry/2019/07/01/185421 # -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- # nCr mod m # rがn/2に近いと非常に重くなる def combination(n, r, mod=10**9 + 7): r = min(r, n - r) res = 1 for i in range(r): res = res * (n - i) * modinv(i + 1, mod) % mod return res # mを法とするaの乗法的逆元 def modinv(a, mod=10**9 + 7): return pow(a, mod - 2, mod) def egcd(a, b): if a == 0: return b, 0, 1 else: g, y, x = egcd(b % a, a) return g, x - (b // a) * y, y # nHr mod m # 問題によって、combination()を切り替えること def H(n, r, mod=10**9 + 7): # comb = Combination(n+r-1, mod) # return comb(n+r-1, r) return combination(n + r - 1, r, mod) class Combination: """ O(n)の前計算を1回行うことで,O(1)でnCr mod mを求められる n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms) 使用例: comb = Combination(1000000) print(comb(5, 3)) # 10 """ def __init__(self, n_max, mod=10**9 + 7): self.mod = mod self.modinv = self.make_modinv_list(n_max) self.fac, self.facinv = self.make_factorial_list(n_max) def __call__(self, n, r): return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod def make_factorial_list(self, n): # 階乗のリストと階乗のmod逆元のリストを返す O(n) # self.make_modinv_list()が先に実行されている必要がある fac = [1] facinv = [1] for i in range(1, n + 1): fac.append(fac[i - 1] * i % self.mod) facinv.append(facinv[i - 1] * self.modinv[i] % self.mod) return fac, facinv def make_modinv_list(self, n): # 0からnまでのmod逆元のリストを返す O(n) modinv = [0] * (n + 1) modinv[1] = 1 for i in range(2, n + 1): modinv[i] = self.mod - self.mod // i * modinv[self.mod % i] % self.mod return modinv if __name__ == "__main__": main()
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s469822251
Wrong Answer
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
from copy import deepcopy from sys import exit, setrecursionlimit import math from collections import defaultdict, Counter, deque from fractions import Fraction as frac setrecursionlimit(1000000) def main(): n = int(input()) xyh = [list(map(int, input().split())) for _ in range(n)] possible = [] for x in range(101): for y in range(101): flag = True h = abs(xyh[0][0] - x) + abs(xyh[0][1] - y) + xyh[0][2] for i in range(1, n): if h != abs(xyh[i][0] - x) + abs(xyh[i][1] - y) + xyh[i][2]: flag = False if flag: print("{} {} {}".format(x, y, h)) def zip(a): mae = a[0] ziparray = [mae] for i in range(1, len(a)): if mae != a[i]: ziparray.append(a[i]) mae = a[i] return ziparray def is_prime(n): if n < 2: return False for k in range(2, int(math.sqrt(n)) + 1): if n % k == 0: return False return True def list_replace(n, f, t): return [t if i == f else i for i in n] def base_10_to_n(X, n): X_dumy = X out = "" while X_dumy > 0: out = str(X_dumy % n) + out X_dumy = int(X_dumy / n) if out == "": return "0" return out def gcd(l): x = l.pop() y = l.pop() while x % y != 0: z = x % y x = y y = z l.append(min(x, y)) return gcd(l) if len(l) > 1 else l[0] class Queue: def __init__(self): self.q = deque([]) def push(self, i): self.q.append(i) def pop(self): return self.q.popleft() def size(self): return len(self.q) def debug(self): return self.q class Stack: def __init__(self): self.q = [] def push(self, i): self.q.append(i) def pop(self): return self.q.pop() def size(self): return len(self.q) def debug(self): return self.q class graph: def __init__(self): self.graph = defaultdict(list) def addnode(self, l): f, t = l[0], l[1] self.graph[f].append(t) self.graph[t].append(f) def rmnode(self, l): f, t = l[0], l[1] self.graph[f].remove(t) self.graph[t].remove(f) def linked(self, f): return self.graph[f] class dgraph: def __init__(self): self.graph = defaultdict(set) def addnode(self, l): f, t = l[0], l[1] self.graph[f].append(t) def rmnode(self, l): f, t = l[0], l[1] self.graph[f].remove(t) def linked(self, f): return self.graph[f] main()
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s242736831
Runtime Error
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
import sys # height is H minus the taxicab distance from (Cx, Cy) to (x, y) def TaxicabDistance(pt_a, pt_b): return abs(pt_a[0] - pt_b[0]) + abs(pt_a[1] - pt_b[1]) def RemoveLeft(some_set, x): return {el for el in some_set if el[0] >= x[0]} def RemoveRight(some_set, x): return {el for el in some_set if el[0] <= x[0]} def RemoveBelow(some_set, x): return {el for el in some_set if el[1] >= x[1]} def RemoveAbove(some_set, x): return {el for el in some_set if el[1] <= x[1]} def RemoveAllExcept(some_set, other_set): return some_set & other_set lines = sys.stdin.read().split("\n") N = int(lines[0]) possible_c = set() for x in range(101): for y in range(101): possible_c.add((x, y)) known_points = [] for i in range(1, N + 1): np_text = lines[i].split(" ") new_point = (int(np_text[0]), int(np_text[1]), int(np_text[2])) for old_point in known_points: height_diff = new_point[2] - old_point[2] dist = TaxicabDistance(new_point, old_point) if dist == height_diff: # same quadrant, new_point closer to center if new_point[0] > old_point[0]: possible_c = RemoveLeft(possible_c, new_point) elif new_point[0] < old_point[0]: possible_c = RemoveRight(possible_c, new_point) if new_point[1] > old_point[1]: possible_c = RemoveBelow(possible_c, new_point) elif new_point[1] < old_point[1]: possible_c = RemoveAbove(possible_c, new_point) elif dist == -height_diff: # same quadrant, old_point closer to center if old_point[0] > new_point[0]: possible_c = RemoveLeft(possible_c, old_point) elif old_point[0] < new_point[0]: possible_c = RemoveRight(possible_c, old_point) if old_point[1] > new_point[1]: possible_c = RemoveBelow(possible_c, old_point) elif old_point[1] < new_point[1]: possible_c = RemoveAbove(possible_c, old_point) else: # different quadrants discrepancy = dist - abs(height_diff) # discrepancy is always even; the center has taxicab distance of # exactly discrepancy/2 measured from one (or both) of the points # and lies between the two candidates = set() c_dist = discrepancy // 2 for j in range(c_dist + 1): if new_point[0] == old_point[0]: if new_point[1] > old_point[1]: candidates.add((new_point[0] - j, new_point[1] - c_dist + j)) candidates.add((new_point[0] + j, new_point[1] - c_dist + j)) candidates.add((old_point[0] - j, old_point[1] + c_dist - j)) candidates.add((old_point[0] + j, old_point[1] + c_dist - j)) else: candidates.add((new_point[0] - j, new_point[1] + c_dist - j)) candidates.add((new_point[0] + j, new_point[1] + c_dist - j)) candidates.add((old_point[0] - j, old_point[1] - c_dist + j)) candidates.add((old_point[0] + j, old_point[1] - c_dist + j)) if new_point[1] == old_point[1]: if new_point[0] > old_point[0]: candidates.add((new_point[0] - c_dist + j, new_point[1] + j)) candidates.add((new_point[0] - c_dist + j, new_point[1] - j)) candidates.add((old_point[0] + c_dist - j, old_point[1] + j)) candidates.add((old_point[0] + c_dist - j, old_point[1] - j)) else: candidates.add((new_point[0] + c_dist - j, new_point[1] + j)) candidates.add((new_point[0] + c_dist - j, new_point[1] - j)) candidates.add((old_point[0] - c_dist + j, old_point[1] + j)) candidates.add((old_point[0] - c_dist + j, old_point[1] - j)) if new_point[0] > old_point[0]: if new_point[1] > old_point[1]: candidates.add((new_point[0] - j, new_point[1] - c_dist + j)) candidates.add((old_point[0] + j, old_point[1] + c_dist - j)) elif new_point[1] < old_point[1]: candidates.add((new_point[0] - j, new_point[1] + c_dist - j)) candidates.add((old_point[0] + j, old_point[1] - c_dist + j)) if new_point[0] < old_point[0]: if new_point[1] > old_point[1]: candidates.add((new_point[0] + j, new_point[1] - c_dist + j)) candidates.add((old_point[0] - j, old_point[1] + c_dist - j)) elif new_point[1] < old_point[1]: candidates.add((new_point[0] + j, new_point[1] + c_dist - j)) candidates.add((old_point[0] - j, old_point[1] - c_dist + j)) # print("candidates for {", new_point, ',', old_point, "}:", candidates) possible_c &= candidates if len(possible_c) == 1: break known_points += [new_point] if len(possible_c) != 1: raise Exception( "no unique answer: " + str(len(possible_c)) + " possible c remaining" ) (cx, cy) = possible_c.pop() h = known_points[0][2] + TaxicabDistance(known_points[0], (cx, cy)) print(cx, cy, h)
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s513839949
Wrong Answer
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return map(int, stdin.readline().split()) def li_(): return map(lambda x: int(x) - 1, stdin.readline().split()) def lf(): return map(float, stdin.readline().split()) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(stdin.readline()) def nf(): return float(stdin.readline()) n = ni() xyh = [] hmax = 0 xmax = -1 ymax = -1 for _ in range(n): x, y, h = li() if h > hmax: hmax = h xmax = x ymax = y xyh.append((x, y, h)) xans = -1 yans = -1 hans = -1 for x in range(101): for y in range(101): hcent = hmax + abs(xmax - x) + abs(ymax - y) consis = True for xi, yi, hi in xyh: if hi != hcent - abs(x - xi) - abs(y - yi): consis = False if consis: xans = x yans = y hans = hcent print(xans, yans, hans)
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s460965937
Runtime Error
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <cmath> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int mod = 1000000007; int main() { ios::sync_with_stdio(false); int n, x[102] = {}, y[102] = {}, h[102] = {}; cin >> n; for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> h[i]; for (int i = 0; i <= 100; i++) { for (int j = 0; j <= 100; j++) { int a = abs(i - x[0]) + abs(j - y[0]) + h[0]; bool w = 0; for (int k = 1; k < n; k++) { if (abs(i - x[k]) + abs(j - y[k]) + h[k] != a) w = 1; } if (w == 0) { cout << i << ' ' << j << ' ' << a << '\n'; return 0; } } } }
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s791085467
Runtime Error
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
N=int(input()) x=[list(map(int,input().split())) for _ in range(N)] Cx=0 Cy=0 H=0 dp=[[0]*101 for i in range(101)] ans=10**10 for i in range(N): for j in range(101): for k in range(101): count=abs(x[i][0]-j)+abs(x[i][1]-k)+x[i][2] if dp[j][k]!=i*count: dp[j][k]=0 else: dp[j][k]+=count ans=min(ans,x[i][2]) p=10**19 a=0 b=0 for i in range(101): for j in range(101): if dp[i][j]%N==0 dp[i][j]!=0: if p!=min(p,dp[i][j]//N): a=i b=j p=min(p,dp[i][j]//N) print(a,b,p)
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s863838095
Runtime Error
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
n=int(input()) a=[list(map(int,input().split())) for _ in range(n)] sx,sy,sh=a[0][0],a[0][1],a[0][2] for y in range(101): for x in range(101): h=sh+abs(x-sx)+abs(y-sy) f=1 #一つでも条件に合致していなかったらフラグを折る for i in range(n): if max(abs(x-a[i][0])+abs(y-a[i][1])+a[i][2]!,0)=h: f=0 #立ってたら終わり if f==1: print(x,y,h) exit()
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s737834963
Runtime Error
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
n = int(input()) XYH = [list(map(int, input().split())) for _ in range(n)] x1, y1, h1 = XYH[0] # print(x1, y1, h1) for Cx in range(101): for Cy in range(101): H = h1 + abs(x1-Cx) + abs(y1-Cy) # print(Cx, Cy, H) if all(h == max(H-abs(x-Cx)-abs(y-Cy), 0) for x, y, h in XYH: print(Cx, Cy, H) exit()
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s557093991
Runtime Error
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
n=int(input()) z=[list(map(int, input().split())) for i in range(n)] z.sort(key=lambda x:x[2]) z.reverse() print(z) v=[] count=0 #各頂点に対して、中心座標と仮定して検証 for i in range(101): for j in range(101): x=abs(j-z[0][0]) y=abs(i-z[0][1]) h=z[0][2]+abs(x)+abs(y) #候補があってるか確認 for k in range(n): if z[k][2]==max(h-abs(z[k][0]-j)-abs(z[k][1]-i),0): count+=1 if count==n: print(r[0],r[1],h) exit() count=0
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s821872841
Runtime Error
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
n = int(input().rstrip()) pl = [] def calc_h(p, cx, cy, ch): return ch - abs(cx - p[0]) - abs(cy - p[0]) for i in range(n): pl.append([int(x) for x in input().rstrip().split(' ')]) hm = max([p[2] for p in pl) vhpl = [p for p in pl if p[2] > 0] nvhpl = [p for p in pl if p[2] == 0] tx = None ty = None h = None if len(vhml) == 0: for x,y in itertools.product(range(101), repeat=2): c = True for p in nvhml: if x == p[0] and y == p[1]: c = False break if c: tx = x ty = y h = 1 break elif len(vhml) == 1: tx, ty, h = vhml[0] else: for x,y in itertools.product(range(101), repeat=2): c = True h = abs(vhpl[0][0] - x) + abs(vhpl[0][1]) + vlpl[0][2]) for i in range(1, len(vhpl)): if calc_h(vhpl[i], x, y, h) != vhpl[i][2]: c = False break if c: for i in range(len(nvhpl)): if calc_h(nvhpl[i], x, y, h) != nvhpl[i][2]: c = False break if c: tx = x ty = y break printf(str(tx) + ' ' + str(ty) + ' ' + str(h))
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s896169071
Runtime Error
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
N = int(input()) xyh_list = list() for i in range(N): x,y,h = map(int, input().split()) xyh_list.append((x,y,h)) for i in range(N): h = xyh_list[i][2] if h != 0: no_zero_h = i break else: break_flag = 0 for i in range(0,101): for j in range(0,101): x = xyh_list[no_zero_h][0] y = xyh_list[no_zero_h][1] h = xyh_list[no_zero_h][2] H = h + abs(x-i) + abs(y-j) if 1 <= H: for k in range(0,N): x = xyh_list[k][0] y = xyh_list[k][1] h = xyh_list[k][2] if h + abs(x-i) + abs(y-j) != H: break else: print(i,j,H) break_flag = 1 if break_flag == 1: break if break_flag == 1: break
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s805934912
Runtime Error
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
n=int(input()) X=[] Y=[] H=[] MAX=100 for i in range(n): x,y,h=map(int,input().split()) X.append(x) Y.append(y) H.append(h) for posX in range(MAX+1): for posY in range(MAX+1): needH=-1 for i in range(n): if H[i]>0: tmp=H[i]+abs(X[i]-posX)+abs(Y[i]-posY) if needH==-1: needH=tmp else: if needH!=tmp: needH=-2 break if needH==-2: continue for i in range(n): if H[i]==0: dis=abs(X[i]-posX)+abs(Y[i]-posY) if needH>dist: needH=-2 break if needH==-2: continue print(posX,posY,needH) exit() ~ ~
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s537491264
Runtime Error
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
def main(): from itertools import product n, *xyh = map(int, open(0).read().split()) a = range(101) if n - xyh[2::3].count(0) == 1: i = xyz[2:; 3].index(1) print(xyh[i]) return a = range(101) for x, y in product(a, a): l = None for i, j, h in zip(*[iter(xyh)] * 3): ll = h + abs(x - i) + abs(y - j) if l: if ll != l: break else: l = ll else: print(x, y, l) return if __ name__ == '__main__': main()
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s892011886
Runtime Error
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
N=int(input()) lis=[] for i in range(101): for j in range(101): lis.append([i,j]) l2=[] for i in range(N): l2.append(list(map(int, input().split()))) for i in lis: n=N l=0 for j in l2: k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2] if l==k or l=0: l=k n-=1 if n==0: print(j[0],j[1],l) break else: break break
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s109043906
Runtime Error
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
n = int(input()) points = [] for i in range(n): x,y,h = map(int,input().split()) if h == 0: continue points.append(list(x,y,h)) for k in range(len(points)):  for l in range(k+1,len(points)):   for i in range(100):    for j in range(100): if points[k][2] - points[l][2] == abs(points[l][0]-i) + abs(points[l][1]-j)- abs(points[k][0]-i)-abs(points[k][1]-j):
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s888916640
Runtime Error
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
#! /usr/bin/env python3 # -*- coding: utf-8 -*- N = int(input()) xyh = [] for _ in range (N): xyh.append([int(x) for x in input().split()]) for Cx in range(101): for Cy in range (101): for i in range (N): ls = [] x = xyh[i][0] y = xyh[i][1] h = max(H-abs(x-Cx)-abs(y-Cy),0) ls.append([x,y,h]) if set(ls) == set(xyh) ans = [Cx,Cy,h] print(ans.split())
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s378331681
Runtime Error
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
n = int(input()) lst = [] for _ in range(n): x, y, h = map(int, input().split()) if h: lst.append(x, y, h) if len(lst) == 1: print(*lst) quit() for cx in range(101): for cy in range(101): a = True preh = abs(lst[0][0] - cx) + abs(lst[0][1] - cy) +lst[0][2] for x, y, h in lst[1:]: H = abs(x - cx) + abs(y - cy) + h if H != preh: a = False break if a: print(cx, cy, H) quit()
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s185160243
Wrong Answer
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
import sys import math import copy import heapq from functools import cmp_to_key from bisect import bisect_left, bisect_right from collections import defaultdict, deque, Counter # sys.setrecursionlimit(1000000) # input aliases input = sys.stdin.readline getS = lambda: input().strip() getN = lambda: int(input()) getList = lambda: list(map(int, input().split())) getZList = lambda: [int(x) - 1 for x in input().split()] INF = float("inf") MOD = 10**9 + 7 divide = lambda x: pow(x, MOD - 2, MOD) def nck(n, k, kaijyo): return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD def npk(n, k, kaijyo): if k == 0 or k == n: return n % MOD return (kaijyo[n] * divide(kaijyo[n - k])) % MOD def fact_and_inv(SIZE): inv = [0] * SIZE # inv[j] = j^{-1} mod MOD fac = [0] * SIZE # fac[j] = j! mod MOD finv = [0] * SIZE # finv[j] = (j!)^{-1} mod MOD inv[1] = 1 fac[0] = fac[1] = 1 finv[0] = finv[1] = 1 for i in range(2, SIZE): inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD fac[i] = fac[i - 1] * i % MOD finv[i] = finv[i - 1] * inv[i] % MOD return fac, finv def renritsu(A, Y): # example 2x + y = 3, x + 3y = 4 # A = [[2,1], [1,3]]) # Y = [[3],[4]] または [3,4] A = np.matrix(A) Y = np.matrix(Y) Y = np.reshape(Y, (-1, 1)) X = np.linalg.solve(A, Y) # [1.0, 1.0] return X.flatten().tolist()[0] class TwoDimGrid: # 2次元座標 -> 1次元 def __init__(self, h, w, wall="#"): self.h = h self.w = w self.size = (h + 2) * (w + 2) self.wall = wall self.get_grid() # self.init_cost() def get_grid(self): grid = [self.wall * (self.w + 2)] for i in range(self.h): grid.append(self.wall + getS() + self.wall) grid.append(self.wall * (self.w + 2)) self.grid = grid def init_cost(self): self.cost = [INF] * self.size def pos(self, x, y): # 壁も含めて0-indexed 元々の座標だけ考えると1-indexed return y * (self.w + 2) + x def getgrid(self, x, y): return self.grid[y][x] def get(self, x, y): return self.cost[self.pos(x, y)] def set(self, x, y, v): self.cost[self.pos(x, y)] = v return def show(self): for i in range(self.h + 2): print(self.cost[(self.w + 2) * i : (self.w + 2) * (i + 1)]) def showsome(self, tgt): for t in tgt: print(t) return def showsomejoin(self, tgt): for t in tgt: print("".join(t)) return def search(self): grid = self.grid move = [(0, 1), (0, -1), (1, 0), (-1, 0)] move_eight = [ (0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1), ] # for i in range(1, self.h+1): # for j in range(1, self.w+1): # cx, cy = j, i # for dx, dy in move_eight: # nx, ny = dx + cx, dy + cy def judge(id, sho, n): hito = [0] for i in range(n): if id % 2 == 1: hito.append(1) else: hito.append(0) id //= 2 for i, h in enumerate(hito): if i == 0: continue if h == 1: for x, y in sho[i - 1]: if hito[x] != y: return -1 return sum(hito) def solve(): n = getN() q = [] for i in range(n): q.append(getList()) for i in range(0, 101): for j in range(0, 101): ch = -1 ok = True fzero = False for x, y, h in q: ins = h + abs(x - i) + abs(y - j) if ch == -1: ch = ins if h == 0: fzero = True else: if ch != ins: if fzero: if h == 0: if ins < ch: ch = ins else: if ins > ch: ok = False break ch = ins fzero = h == 0 elif h != 0: ok = False break if ok: print(i, j, ch) return def main(): n = getN() for _ in range(n): solve() return if __name__ == "__main__": # main() solve()
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s541786445
Runtime Error
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
import sympy
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s080605327
Runtime Error
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
n=int(input()) zahyo=[] for _ in range(n): zahyo.append(tuple(map(int,input().split()))) zahyo.sort(key=lamda x:x[2]) for x in range(101): for y in range(101): H=zahyo[0][2]+abs(zahyo[0][0]-x)+abs(zahyo[0][1]-y) flag=0 saisho=10**9+1 H=0 for item in zahyo[1:]: if item[2]==0: if H>abs(item[0]-x)+abs(item[1]-y): flag=1 break else: if H!=item[2]+abs(item[0]-x)+abs(item[1]-y): flag=1 break if flag==0: print(x,y,H)
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s456218805
Accepted
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
N = int(input()) high_sets = [list(map(int, input().split())) for _ in range(N)] # このセットから中心座標と高さは絞り込める def compute_diff_from_top(x, y, cx, cy): # -4 + -77 return (-1 * abs(x - cx)) + (-1 * abs(y - cy)) ans = 0 ans_x = None ans_y = None for i in range(101): for j in range(101): nums = [] for high_set in high_sets: # i == 55 j == 80 # high_set_x = 59 high_set_y = 3 # high_set[2] == 0の時は、区別が必要。 num = high_set[2] + ( -1 * compute_diff_from_top(i, j, high_set[0], high_set[1]) ) if high_set[2] == 0: nums.append(-1) else: nums.append(num) # if i == 32: # print(i, j, nums) if len(set(nums)) == 1: ans_x, ans_y = i, j ans = nums.pop() else: if len(set(nums)) == 2 and -1 in nums: nums = set(nums) nums.remove(-1) top = nums.pop() check = True for high_set in high_sets: # if i == 32 and j == 68: # print(top, compute_diff_from_top(i, j, high_set[0], high_set[1])) if ( max( 0, top + compute_diff_from_top(i, j, high_set[0], high_set[1]), ) != high_set[2] ): check = False if check: ans_x, ans_y = i, j ans = top print(ans_x, ans_y, ans) # 55 80 79
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between. * * *
s710584395
Wrong Answer
p03240
Input is given from Standard Input in the following format: N x_1 y_1 h_1 x_2 y_2 h_2 x_3 y_3 h_3 : x_N y_N h_N
n = int(input()) lis = [list(map(int, input().split())) for i in range(n)] for i in range(101): for j in range(101): s = set() for h in range(n): num = abs(lis[h][0] - i) + abs(lis[h][1] - j) if num + lis[h][2] < 0: s.add(num + lis[h][2] + 1) s.add(num + lis[h][2]) if len(s) == 1: for num in s: print(i, j, num)
Statement In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had _center coordinates_ (C_X, C_Y) and _height_ H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information: * C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1. * Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i." This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.
[{"input": "4\n 2 3 5\n 2 1 5\n 1 2 5\n 3 2 5", "output": "2 2 6\n \n\nIn this case, the center coordinates and the height can be identified as (2,\n2) and 6.\n\n* * *"}, {"input": "2\n 0 0 100\n 1 1 98", "output": "0 0 100\n \n\nIn this case, the center coordinates and the height can be identified as (0,\n0) and 100. \nNote that C_X and C_Y are known to be integers between 0 and 100.\n\n* * *"}, {"input": "3\n 99 1 191\n 100 1 192\n 99 0 192", "output": "100 0 193\n \n\nIn this case, the center coordinates and the height can be identified as (100,\n0) and 193."}]
If there is no induced subgraph of G that satisfies the condition, print `-1`. Otherwise, print an induced subgraph of G that satisfies the condition, in the following format: K v_1 v_2 : v_K This represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \ldots, v_K\\}. (The order of v_1, v_2, \ldots, v_K does not matter.) If there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted. * * *
s716474752
Wrong Answer
p02902
Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 : A_M B_M
n, m = map(int, input().split()) if m == n - 1: print(-1) else: print(0)
Statement Given is a directed graph G with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i. It is guaranteed that the graph contains no self-loops or multiple edges. Determine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph. Here the null graph is not considered as a subgraph.
[{"input": "4 5\n 1 2\n 2 3\n 2 4\n 4 1\n 4 3", "output": "3\n 1\n 2\n 4\n \n\nThe induced subgraph of G whose vertex set is \\\\{1, 2, 4\\\\} has the edge set\n\\\\{(1, 2), (2, 4), (4, 1)\\\\}. The in-degree and out-degree of every vertex in\nthis graph are both 1.\n\n* * *"}, {"input": "4 5\n 1 2\n 2 3\n 2 4\n 1 4\n 4 3", "output": "-1\n \n\nThere is no induced subgraph of G that satisfies the condition.\n\n* * *"}, {"input": "6 9\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n 5 1\n 5 2\n 6 1\n 6 2", "output": "4\n 2\n 3\n 4\n 5"}]
If there is no induced subgraph of G that satisfies the condition, print `-1`. Otherwise, print an induced subgraph of G that satisfies the condition, in the following format: K v_1 v_2 : v_K This represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \ldots, v_K\\}. (The order of v_1, v_2, \ldots, v_K does not matter.) If there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted. * * *
s408805839
Wrong Answer
p02902
Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 : A_M B_M
print("4\n2\n3\n4\n5")
Statement Given is a directed graph G with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i. It is guaranteed that the graph contains no self-loops or multiple edges. Determine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph. Here the null graph is not considered as a subgraph.
[{"input": "4 5\n 1 2\n 2 3\n 2 4\n 4 1\n 4 3", "output": "3\n 1\n 2\n 4\n \n\nThe induced subgraph of G whose vertex set is \\\\{1, 2, 4\\\\} has the edge set\n\\\\{(1, 2), (2, 4), (4, 1)\\\\}. The in-degree and out-degree of every vertex in\nthis graph are both 1.\n\n* * *"}, {"input": "4 5\n 1 2\n 2 3\n 2 4\n 1 4\n 4 3", "output": "-1\n \n\nThere is no induced subgraph of G that satisfies the condition.\n\n* * *"}, {"input": "6 9\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n 5 1\n 5 2\n 6 1\n 6 2", "output": "4\n 2\n 3\n 4\n 5"}]
If there is no induced subgraph of G that satisfies the condition, print `-1`. Otherwise, print an induced subgraph of G that satisfies the condition, in the following format: K v_1 v_2 : v_K This represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \ldots, v_K\\}. (The order of v_1, v_2, \ldots, v_K does not matter.) If there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted. * * *
s888543106
Wrong Answer
p02902
Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 : A_M B_M
print()
Statement Given is a directed graph G with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i. It is guaranteed that the graph contains no self-loops or multiple edges. Determine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph. Here the null graph is not considered as a subgraph.
[{"input": "4 5\n 1 2\n 2 3\n 2 4\n 4 1\n 4 3", "output": "3\n 1\n 2\n 4\n \n\nThe induced subgraph of G whose vertex set is \\\\{1, 2, 4\\\\} has the edge set\n\\\\{(1, 2), (2, 4), (4, 1)\\\\}. The in-degree and out-degree of every vertex in\nthis graph are both 1.\n\n* * *"}, {"input": "4 5\n 1 2\n 2 3\n 2 4\n 1 4\n 4 3", "output": "-1\n \n\nThere is no induced subgraph of G that satisfies the condition.\n\n* * *"}, {"input": "6 9\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n 5 1\n 5 2\n 6 1\n 6 2", "output": "4\n 2\n 3\n 4\n 5"}]
If there is no induced subgraph of G that satisfies the condition, print `-1`. Otherwise, print an induced subgraph of G that satisfies the condition, in the following format: K v_1 v_2 : v_K This represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \ldots, v_K\\}. (The order of v_1, v_2, \ldots, v_K does not matter.) If there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted. * * *
s133244090
Wrong Answer
p02902
Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 : A_M B_M
print("3\n1\n2\n4\n")
Statement Given is a directed graph G with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i. It is guaranteed that the graph contains no self-loops or multiple edges. Determine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph. Here the null graph is not considered as a subgraph.
[{"input": "4 5\n 1 2\n 2 3\n 2 4\n 4 1\n 4 3", "output": "3\n 1\n 2\n 4\n \n\nThe induced subgraph of G whose vertex set is \\\\{1, 2, 4\\\\} has the edge set\n\\\\{(1, 2), (2, 4), (4, 1)\\\\}. The in-degree and out-degree of every vertex in\nthis graph are both 1.\n\n* * *"}, {"input": "4 5\n 1 2\n 2 3\n 2 4\n 1 4\n 4 3", "output": "-1\n \n\nThere is no induced subgraph of G that satisfies the condition.\n\n* * *"}, {"input": "6 9\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n 5 1\n 5 2\n 6 1\n 6 2", "output": "4\n 2\n 3\n 4\n 5"}]
If there is no induced subgraph of G that satisfies the condition, print `-1`. Otherwise, print an induced subgraph of G that satisfies the condition, in the following format: K v_1 v_2 : v_K This represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \ldots, v_K\\}. (The order of v_1, v_2, \ldots, v_K does not matter.) If there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted. * * *
s797965314
Wrong Answer
p02902
Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 : A_M B_M
import sys class Node: def __init__(self, i): self.i = i self.edge_to = [] self.edge_from = [] self.step_visit = -1 self.exist = True def delete(self): if self.exist: self.exist = False for i in self.edge_from: tree[i].del_edge_to(self.i) if len(tree[i].edge_to) == 0: tree[i].delete() for i in self.edge_to: tree[i].del_edge_from(self.i) if len(tree[i].edge_to) == 0: tree[i].delete() def add_edge_from(self, i): self.edge_from.append(i) def add_edge_to(self, i): self.edge_to.append(i) def del_edge_from(self, i): self.edge_from.remove(i) def del_edge_to(self, i): self.edge_to.remove(i) def visit(self, step): if self.step_visit >= 0: return self.step_visit self.step_visit = step return -1 def next(self): for i in range(len(self.edge_to)): if tree[self.edge_to[i]].exist: return self.edge_to[i] return -1 n_v, n_e = map(int, input().split()) tree = [Node(i) for i in range(n_v)] trace = [] for i in range(n_e): a, b = map(int, input().split()) a -= 1 b -= 1 tree[a].add_edge_to(b) tree[b].add_edge_from(a) # input for i in range(n_v): if len(tree[i].edge_to) == 0 or len(tree[i].edge_from) == 0: tree[i].delete() # delete unnecessary nodes for i in range(n_v): if tree[i].exist: trace.append(i) tree[i].visit(0) next = tree[i].next() break if len(trace) == 0: print("-1") sys.exit() while True: start = tree[next].visit(len(trace)) if start >= 0 or len(trace) > n_v + 1: if start == -1: print("-1") sys.exit() break else: trace.append(next) next = tree[next].next() # search loop for i in trace: for j in tree[i].edge_to: if j in trace: index = trace.index(j) if index > i: del trace[i + 1 : index] else: trace = trace[index : i + 1] # making it shorter print(len(trace) - start) for i in range(start, len(trace)): print(trace[i] + 1)
Statement Given is a directed graph G with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i. It is guaranteed that the graph contains no self-loops or multiple edges. Determine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph. Here the null graph is not considered as a subgraph.
[{"input": "4 5\n 1 2\n 2 3\n 2 4\n 4 1\n 4 3", "output": "3\n 1\n 2\n 4\n \n\nThe induced subgraph of G whose vertex set is \\\\{1, 2, 4\\\\} has the edge set\n\\\\{(1, 2), (2, 4), (4, 1)\\\\}. The in-degree and out-degree of every vertex in\nthis graph are both 1.\n\n* * *"}, {"input": "4 5\n 1 2\n 2 3\n 2 4\n 1 4\n 4 3", "output": "-1\n \n\nThere is no induced subgraph of G that satisfies the condition.\n\n* * *"}, {"input": "6 9\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n 5 1\n 5 2\n 6 1\n 6 2", "output": "4\n 2\n 3\n 4\n 5"}]
If there is no induced subgraph of G that satisfies the condition, print `-1`. Otherwise, print an induced subgraph of G that satisfies the condition, in the following format: K v_1 v_2 : v_K This represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \ldots, v_K\\}. (The order of v_1, v_2, \ldots, v_K does not matter.) If there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted. * * *
s569819347
Accepted
p02902
Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 : A_M B_M
import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline().rstrip() # ignore trailing spaces n, m = na() g = [[False] * n for _ in range(n)] gs = [[] for _ in range(n)] for i in range(m): s, t = na() gs[s - 1].append(t - 1) g[s - 1][t - 1] = True ans = 999999 best = None for i in range(n): ds = [9999999] * n prevs = [-1] * n ds[i] = 0 q = [i] qp = 0 while qp < len(q): cur = q[qp] qp += 1 for e in gs[cur]: if ds[e] > ds[cur] + 1: ds[e] = ds[cur] + 1 prevs[e] = cur q.append(e) for j in range(n): if g[j][i]: if ds[j] + 1 < ans: ans = ds[j] + 1 best = [0] * (ds[j] + 1) best[0] = i cur = j r = -1 while cur != i: best[r] = cur r -= 1 cur = prevs[cur] if not best: print(-1) else: print(ans) for x in best: print(x + 1)
Statement Given is a directed graph G with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i. It is guaranteed that the graph contains no self-loops or multiple edges. Determine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph. Here the null graph is not considered as a subgraph.
[{"input": "4 5\n 1 2\n 2 3\n 2 4\n 4 1\n 4 3", "output": "3\n 1\n 2\n 4\n \n\nThe induced subgraph of G whose vertex set is \\\\{1, 2, 4\\\\} has the edge set\n\\\\{(1, 2), (2, 4), (4, 1)\\\\}. The in-degree and out-degree of every vertex in\nthis graph are both 1.\n\n* * *"}, {"input": "4 5\n 1 2\n 2 3\n 2 4\n 1 4\n 4 3", "output": "-1\n \n\nThere is no induced subgraph of G that satisfies the condition.\n\n* * *"}, {"input": "6 9\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n 5 1\n 5 2\n 6 1\n 6 2", "output": "4\n 2\n 3\n 4\n 5"}]
If there is no induced subgraph of G that satisfies the condition, print `-1`. Otherwise, print an induced subgraph of G that satisfies the condition, in the following format: K v_1 v_2 : v_K This represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \ldots, v_K\\}. (The order of v_1, v_2, \ldots, v_K does not matter.) If there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted. * * *
s287253967
Accepted
p02902
Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 : A_M B_M
from collections import deque n, m = map(int, input().split()) g = [[] for _ in range(n)] INF = float("inf") for _ in range(m): a, b = map(int, input().split()) a -= 1 b -= 1 g[a].append(b) res = [] shortest = n + 1 for s in range(n): dist = [-1] * n prev = [-1] * n q = deque() q.append(s) dist[s] = 0 while len(q) != 0: v = q.popleft() for nv in g[v]: if dist[nv] == -1: dist[nv] = dist[v] + 1 prev[nv] = v q.append(nv) for t in range(n): if t == s: continue if dist[t] == -1: continue for nt in g[t]: if nt == s: temp = [s] cur = t while cur != s: temp.append(cur) cur = prev[cur] if shortest > len(temp): shortest = len(temp) res = temp if shortest == n + 1: print(-1) exit() print(len(res)) for v in res: print(v + 1) # def bfs(sv): # dist = [INF] * n # pre = [-1] * n # q = deque() # q.append(sv) # dist[sv] = 0 # while q: # v = q.popleft() # for nv in g[v]: # if dist[nv] == INF: # continue # pre[nv] = v # dist[nv] = dist[v] + 1 # q.append(nv) # print(dist) # best = (INF, -1) # for v in range(n): # if v == sv: # continue # for nv in g[v]: # if nv == sv: # best = min(best, (dist[nv], nv)) # print(sv, best) # # print(best) # if best[0] == INF: # return [0] * (n + 1) # print(pre) # v = best[1] # print('v', v) # res = [] # while v != -1: # res.append(v) # v = pre[v] # print('res', res) # return res # ans = [0] * (n + 1) # for s in range(n): # now = bfs(s) # if len(now) < len(ans): # print('aa') # ans = now # print(ans) # if len(ans) == n + 1: # print(-1) # exit() # print(len(ans)) # for v in ans: # print(v)
Statement Given is a directed graph G with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i. It is guaranteed that the graph contains no self-loops or multiple edges. Determine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph. Here the null graph is not considered as a subgraph.
[{"input": "4 5\n 1 2\n 2 3\n 2 4\n 4 1\n 4 3", "output": "3\n 1\n 2\n 4\n \n\nThe induced subgraph of G whose vertex set is \\\\{1, 2, 4\\\\} has the edge set\n\\\\{(1, 2), (2, 4), (4, 1)\\\\}. The in-degree and out-degree of every vertex in\nthis graph are both 1.\n\n* * *"}, {"input": "4 5\n 1 2\n 2 3\n 2 4\n 1 4\n 4 3", "output": "-1\n \n\nThere is no induced subgraph of G that satisfies the condition.\n\n* * *"}, {"input": "6 9\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n 5 1\n 5 2\n 6 1\n 6 2", "output": "4\n 2\n 3\n 4\n 5"}]
If there is no induced subgraph of G that satisfies the condition, print `-1`. Otherwise, print an induced subgraph of G that satisfies the condition, in the following format: K v_1 v_2 : v_K This represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \ldots, v_K\\}. (The order of v_1, v_2, \ldots, v_K does not matter.) If there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted. * * *
s582479425
Wrong Answer
p02902
Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 : A_M B_M
from collections import deque def main(): a, b = map(int, input().split()) c = [[] for i in range(a)] for i in range(b): x, y = map(int, input().split()) c[x - 1].append(y - 1) d = deque() ans = -1 e = [-1 for i in range(a)] for i in range(a): f = [0 for i in range(a)] if e[i] == -1: d.append(i) while len(d) != 0: x = d.pop() for y in c[x]: e[y] = x if f[y] == 1: ans = y break else: f[y] = 1 d.append(y) if ans > -1: break if ans > -1: break if i == a - 1: print(-1) break y = ans ans2 = [] while 1: ans2.append(e[y] + 1) y = e[y] if y == ans: break print(len(ans2)) for i in ans2: print(i) if __name__ == "__main__": main()
Statement Given is a directed graph G with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i. It is guaranteed that the graph contains no self-loops or multiple edges. Determine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph. Here the null graph is not considered as a subgraph.
[{"input": "4 5\n 1 2\n 2 3\n 2 4\n 4 1\n 4 3", "output": "3\n 1\n 2\n 4\n \n\nThe induced subgraph of G whose vertex set is \\\\{1, 2, 4\\\\} has the edge set\n\\\\{(1, 2), (2, 4), (4, 1)\\\\}. The in-degree and out-degree of every vertex in\nthis graph are both 1.\n\n* * *"}, {"input": "4 5\n 1 2\n 2 3\n 2 4\n 1 4\n 4 3", "output": "-1\n \n\nThere is no induced subgraph of G that satisfies the condition.\n\n* * *"}, {"input": "6 9\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n 5 1\n 5 2\n 6 1\n 6 2", "output": "4\n 2\n 3\n 4\n 5"}]
If there is no induced subgraph of G that satisfies the condition, print `-1`. Otherwise, print an induced subgraph of G that satisfies the condition, in the following format: K v_1 v_2 : v_K This represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \ldots, v_K\\}. (The order of v_1, v_2, \ldots, v_K does not matter.) If there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted. * * *
s552046647
Wrong Answer
p02902
Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 : A_M B_M
0
Statement Given is a directed graph G with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i. It is guaranteed that the graph contains no self-loops or multiple edges. Determine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph. Here the null graph is not considered as a subgraph.
[{"input": "4 5\n 1 2\n 2 3\n 2 4\n 4 1\n 4 3", "output": "3\n 1\n 2\n 4\n \n\nThe induced subgraph of G whose vertex set is \\\\{1, 2, 4\\\\} has the edge set\n\\\\{(1, 2), (2, 4), (4, 1)\\\\}. The in-degree and out-degree of every vertex in\nthis graph are both 1.\n\n* * *"}, {"input": "4 5\n 1 2\n 2 3\n 2 4\n 1 4\n 4 3", "output": "-1\n \n\nThere is no induced subgraph of G that satisfies the condition.\n\n* * *"}, {"input": "6 9\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n 5 1\n 5 2\n 6 1\n 6 2", "output": "4\n 2\n 3\n 4\n 5"}]
If there is no induced subgraph of G that satisfies the condition, print `-1`. Otherwise, print an induced subgraph of G that satisfies the condition, in the following format: K v_1 v_2 : v_K This represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \ldots, v_K\\}. (The order of v_1, v_2, \ldots, v_K does not matter.) If there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted. * * *
s619227362
Wrong Answer
p02902
Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 : A_M B_M
import sys from collections import defaultdict input = sys.stdin.readline def inpl(): return list(map(int, input().split())) N, M = inpl() G = [[] for _ in range(N)] rG = [[] for _ in range(N)] for _ in range(M): a, b = inpl() G[a - 1].append(b - 1) rG[b - 1].append(a - 1) def SCC(G, rG): N = len(G) def dfs(i): nonlocal t, rorder, searched searched[i] = True for j in G[i]: if not searched[j]: dfs(j) rorder[t] = i t += 1 def rdfs(i): nonlocal t, group, g group[i] = g for j in rG[i]: if group[j] == -1: rdfs(j) t = 0 rorder = [-1] * N searched = [0] * N group = [-1] * N for i in range(N): if not searched[i]: dfs(i) g = 0 for i in range(N - 1, -1, -1): if group[rorder[i]] == -1: rdfs(rorder[i]) g += 1 return group, g def check(target): if len(target) == 1: return False init = list(target)[0] * 1 Q = [init] searched = [0] * len(G) searched[init] = 1 while Q: p = Q.pop() for q in G[p]: if searched[q]: continue if not q in target: continue searched[q] = True Q.append(q) if not all([searched[x] for x in target]): return False Q = [init] searched = [0] * N searched[init] = 1 while Q: p = Q.pop() for q in rG[p]: if searched[q]: continue if not q in target: continue searched[q] = True Q.append(q) return all([searched[x] for x in target]) group, g = SCC(G, rG) units = defaultdict(set) for i in range(N): units[group[i]].add(i) for unit in units.values(): if len(unit) == 1: continue target = unit | set() for u in unit: if check(target ^ set([u])): target = target ^ set([u]) print(len(target)) print(*[t + 1 for t in target], sep="\n") break else: print(-1)
Statement Given is a directed graph G with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i. It is guaranteed that the graph contains no self-loops or multiple edges. Determine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph. Here the null graph is not considered as a subgraph.
[{"input": "4 5\n 1 2\n 2 3\n 2 4\n 4 1\n 4 3", "output": "3\n 1\n 2\n 4\n \n\nThe induced subgraph of G whose vertex set is \\\\{1, 2, 4\\\\} has the edge set\n\\\\{(1, 2), (2, 4), (4, 1)\\\\}. The in-degree and out-degree of every vertex in\nthis graph are both 1.\n\n* * *"}, {"input": "4 5\n 1 2\n 2 3\n 2 4\n 1 4\n 4 3", "output": "-1\n \n\nThere is no induced subgraph of G that satisfies the condition.\n\n* * *"}, {"input": "6 9\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n 5 1\n 5 2\n 6 1\n 6 2", "output": "4\n 2\n 3\n 4\n 5"}]
If there is no induced subgraph of G that satisfies the condition, print `-1`. Otherwise, print an induced subgraph of G that satisfies the condition, in the following format: K v_1 v_2 : v_K This represents the induced subgraph of G with K vertices whose vertex set is \\{v_1, v_2, \ldots, v_K\\}. (The order of v_1, v_2, \ldots, v_K does not matter.) If there are multiple subgraphs of G that satisfy the condition, printing any of them is accepted. * * *
s611319401
Wrong Answer
p02902
Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 : A_M B_M
import sys stdin = sys.stdin sys.setrecursionlimit(10**7) def li(): return map(int, stdin.readline().split()) def li_(): return map(lambda x: int(x) - 1, stdin.readline().split()) def lf(): return map(float, stdin.readline().split()) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(stdin.readline()) def nf(): return float(stdin.readline()) def dfs(graph, cur, target, visited, memo=[]): for nex in graph[cur]: if not visited[nex]: visited[nex] = True ret = dfs(graph, nex, target, visited, memo) if ret != -1: memo.append(cur) return cur elif nex == target: memo.append(cur) return cur return -1 n, m = li() graph = [[] for _ in range(n)] for _ in range(m): a, b = li_() graph[a].append(b) for target in range(n): visited = [False] * n memo = [] ans = dfs(graph, target, target, visited, memo) if len(memo) > 0: break if ans == -1: print(-1) else: print(len(memo)) while memo: print(memo.pop() + 1)
Statement Given is a directed graph G with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i. It is guaranteed that the graph contains no self-loops or multiple edges. Determine whether there exists an induced subgraph (see Notes) of G such that the in-degree and out-degree of every vertex are both 1. If the answer is yes, show one such subgraph. Here the null graph is not considered as a subgraph.
[{"input": "4 5\n 1 2\n 2 3\n 2 4\n 4 1\n 4 3", "output": "3\n 1\n 2\n 4\n \n\nThe induced subgraph of G whose vertex set is \\\\{1, 2, 4\\\\} has the edge set\n\\\\{(1, 2), (2, 4), (4, 1)\\\\}. The in-degree and out-degree of every vertex in\nthis graph are both 1.\n\n* * *"}, {"input": "4 5\n 1 2\n 2 3\n 2 4\n 1 4\n 4 3", "output": "-1\n \n\nThere is no induced subgraph of G that satisfies the condition.\n\n* * *"}, {"input": "6 9\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n 5 1\n 5 2\n 6 1\n 6 2", "output": "4\n 2\n 3\n 4\n 5"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s634532671
Accepted
p03610
The input is given from Standard Input in the following format: s
A = input() print(A[::2])
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s720894383
Runtime Error
p03610
The input is given from Standard Input in the following format: s
OddString
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s839016226
Wrong Answer
p03610
The input is given from Standard Input in the following format: s
print(str(input())[1::2])
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s955594939
Accepted
p03610
The input is given from Standard Input in the following format: s
print("".join(input()[::2]))
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s634068126
Runtime Error
p03610
The input is given from Standard Input in the following format: s
class Atc_072b: def __init__(self, s: str) -> str: self.s = s def odd(self): s_odd = "" for i in range(0, len(self.s)): if i % 2 == 0: s_odd += self.s[i] return s_odd s_input = input() print(Atc_072b(s_input).odd()) © 2020 GitHub, Inc.
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s824453853
Accepted
p03610
The input is given from Standard Input in the following format: s
l = input() print(l[::2])
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s243140341
Runtime Error
p03610
The input is given from Standard Input in the following format: s
string = input() i = 1 ans = " for s in string: if i % 2 != 0: ans += s print(ans)
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s075394369
Runtime Error
p03610
The input is given from Standard Input in the following format: s
s = input() print(''.join([x[2*i+1] for x,i in zip(s, range(0,(len(s)+1)/2))])
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s387616836
Runtime Error
p03610
The input is given from Standard Input in the following format: s
s = input() print(s.[1::2])
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s357049147
Runtime Error
p03610
The input is given from Standard Input in the following format: s
# -*- coding: utf-8 -*- S = str(input()) a.[] for i in range(len(S)): if i % 2 == 1: a.append(S[i]) print(a.join())
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s845564917
Accepted
p03610
The input is given from Standard Input in the following format: s
A = list(input()) print("".join(A[::2]))
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s671250779
Accepted
p03610
The input is given from Standard Input in the following format: s
N = list(input())[::2] print("".join(N))
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s030245707
Accepted
p03610
The input is given from Standard Input in the following format: s
print("".join((list(input())[0::2])))
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s461598709
Accepted
p03610
The input is given from Standard Input in the following format: s
N = list(input()) odd = [] for i in range(0, len(N), 2): odd.append(N[i]) mojiretu = "".join(odd) print(mojiretu)
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s621819452
Wrong Answer
p03610
The input is given from Standard Input in the following format: s
input()[::2]
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s923917765
Accepted
p03610
The input is given from Standard Input in the following format: s
print("".join([s for i, s in enumerate(input()) if i % 2 == 0]))
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s299553840
Accepted
p03610
The input is given from Standard Input in the following format: s
# 072b class Atc_072b: def __init__(self, s: str) -> str: self.s = s def odd(self): s_odd = "" for i in range(0, len(self.s)): if i % 2 == 0: s_odd += self.s[i] return s_odd s_input = input() print(Atc_072b(s_input).odd())
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s677212104
Accepted
p03610
The input is given from Standard Input in the following format: s
ognl = input() print("".join([c for i, c in enumerate(ognl) if i % 2 == 0]))
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s584985977
Accepted
p03610
The input is given from Standard Input in the following format: s
print("".join([c for i, c in enumerate(list(input())) if (i + 1) % 2]))
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]