Problem:


Score : 300 points

Problem Statement

There is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).
You are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.

Constraints

1 \leq W,H \leq 10^9

0\leq x\leq W

0\leq y\leq H

All values in input are integers.

Input

Input is given from Standard Input in the following format:

W H x y

Output

Print the maximum possible area of the part whose area is not larger than that of the other, followed by 1 if there are multiple ways to cut the rectangle and achieve that maximum, and 0 otherwise.

The area printed will be judged correct when its absolute or relative error is at most 10^{-9}.

Sample Input 1

2 3 1 2

Sample Output 1

3.000000 0

The line x=1 gives the optimal cut, and no other line does.

Sample Input 2

2 2 1 1

Sample Output 2

2.000000 1



Sample input:
2 3 1 2


Sample output:
3.000000 0

Submission status: Runtime Error

Solution code:
# -*- coding:utf-8 -*-
"""考え方
よくわからんけど、縦か横の直線で分割する？
あと原点から(x,y)座標へ向けて斜めに分割する奴も考える

"""
def solve():
    W, H, x, y = list(map(int, input().split()))

    # 縦に分割する場合
    ans1 = min(x*H, (W-x)*H)

    # 横に分割する場合
    ans2 = min(W*y, W*(H-y))

    # 斜めに分割する場合
    d = y/x
    if d <= 1:
        # 傾きが1以下の場合
        ans3 = W * (W*d) / 2
    else:
        # 傾きが1より大きい
        d = x/y
        ans3 = H * (H*d) / 2

    ans = max(ans1, ans2, ans3)

    if ans1==ans2 or ans2==ans3 or ans3==ans1:
        is_multi = 1
    else:
        is_multi = 0

    print(ans, is_multi)


if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
import sys

W, H, x, y = map(int, input().split())
# 対角線の交点を通る直線を引いた時最大？
all_area = W * H # 面積
c_x = W / 2
c_y = H / 2
if x - c_x <= 1 / 10 ** 9:
    if y - c_y == 0:
        print(all_area / 2, 1)
    else:
        print(all_area / 2, 0)
    sys.exit(0)
if y - c_y <= 1 / 10 ** 9:
    print(all_area / 2, 0)
    sys.exit(0)
a = (y - c_y) / (x - c_x) # 直線の傾き
b = y - a * x # 切片

# 交わってる部分の判定
left, right, up, bottom = False, False, False, False
if (1 - b) / a >= 0 and (1 - b) / a <= W:
    up = True
if b > 0 and b < H:
    left = True
if a + b > 0 and a + b < H:
    right = True
if -b / a >= 0 and -b / a <= W:
    bottom = True

# 交わってる部分により面積導出
def calcarea(up, bottom, high):
    return (up + bottom) * hight / 2
if left:
    if right:
        area = calcarea(b, a + b, W)
    if up:
        area = calcarea(0, H - W, (1 - b) / a)
    if bottom:
        area = calcarea(0, b, -b / a)
if right:
    if up:
        area = calcarea(0, H - (a + b), W - (1 - b) / a)
    if bottom:
        area = calcarea(0, H - (a + b), W - (-b / a))
if up:
    if bottom:
        area = calcarea(W - (1 - b) / a, W - (-b / a), H)

# 小さい方
if area > all_area - area:
    area = all_area - area
print(area, 0)

Submission status: Runtime Error

Solution code:
W,H,x,y = (int(x) for x in input().split())

ans = 0
flag = 0

if (W / x == 2) and (H / y == 2):
  flag = 1

if (W / x == 2) or (H / y == 2):
  ans = W * H / 2  
else:
  tmp1 = []
  tmp1.append(x * H)
  tmp1.append((W - x) * H)
  
  tmp2 = []
  tmp2.append(W * y)
  tmp2.append(W * (H - y))
  
  if min(tmp1) > min(tmp2):
    ans = min(tmp1)
  else:
    ans = min(tmp2)

print(float(ans), flag)

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int, input().split())
jufuku = 0
if y / x == H / W:
    naname = W * H / 2
    jufuku = 1
    kiri = naname
else:
    # 縦
    tate = min((W - x) * H, x * H)
    # 横
    yoko = min(W * (H - y), W * y)
    if tate == yoko:
        jufuku = 1
    kiri = max(tate, yoko)
print(kiri, jufuku)

Submission status: Runtime Error

Solution code:
li = list(map(int,input().split()))

S1 = min(l1[0] * li[2], l1[0] * (li[1] - li[2]))
S2 = min(li[1] * li[3], li[1] * (li[0] - li[3]))

if S1 == S2:
    print(S1, 1)
else:
    print(min(S1, S2), 0)

Submission status: Runtime Error

Solution code:
import sys

W, H, x, y = map(int, input().split())
# 対角線の交点を通る直線を引いた時最大？
all_area = W * H # 面積
c_x = W / 2
c_y = H / 2
if x - c_x <= 1 / 10 ** 9:
    if y - c_y == 0:
        print(all_area / 2, 1)
    else:
        print(all_area / 2, 0)
    sys.exit(0)
if y - c_y <= 1 / 10 ** 9:
    print(all_area / 2, 0)
    sys.exit(0)
a = (y - c_y) / (x - c_x) # 直線の傾き
b = y - a * x # 切片

# 交わってる部分の判定
left, right, up, bottom = False, False, False, False
if (1 - b) / a >= 0 and (1 - b) / a <= W:
    up = True
if b >= 0 and b <= H:
    left = True
if a + b >= 0 and a + b <= H:
    right = True
if -b / a >= 0 and -b / a <= W:
    bottom = True

# 交わってる部分により面積導出
def calcarea(up, bottom, high):
    return (up + bottom) * hight / 2
if left:
    if right:
        area = calcarea(b, a + b, W)
    if up:
        area = calcarea(0, H - W, (1 - b) / a)
    if bottom:
        area = calcarea(0, b, -b / a)
if right:
    if up:
        area = calcarea(0, H - (a + b), W - (1 - b) / a)
    if bottom:
        area = calcarea(0, H - (a + b), W - (-b / a))
if up:
    if bottom:
        area = calcarea(W - (1 - b) / a, W - (-b / a), H)

# 小さい方
if area > all_area - area:
    area = all_area - area
print(area, 0)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
W, H, x, y = map(int, input().split())
f = "0"
if (W/x == H/y or x == y) and (W != x and H != y and W != 0 and H != 0):
    f="1"
print(str(W*H/2) + " " + f)

Submission status: Runtime Error

Solution code:
W,H,x,y = (int(x) for x in input().split())

ans = 0
flag = 0

if (W / x == 2) and (H / y == 2):
  flag = 1

if (W / x == 2) or (H / y == 2):
  ans = W * H / 2  
elif y == 0 or y == H:
  ans = x * H
elif x == 0 or x == W:
  ans = W * y
else:
  tmp1 = []
  tmp1.append(x * H)
  tmp1.append((W - x) * H)
  
  tmp2 = []
  tmp2.append(W * y)
  tmp2.append(W * (H - y))
  
  if min(tmp1) > min(tmp2):
    ans = min(tmp1)
  else:
    ans = min(tmp2)

print(float(ans), flag)

Submission status: Runtime Error

Solution code:
W,H,x,y=map(int,input().split())
men=W*H/2
a=float(y/x)
b=float(H/W)
W2=float(W/2)
H2=float(H/2)
cross=0
if a == b or x == W2 or y == H2:
    if a == b and x == W2:
        cross=1
    elif a == b and y == H2:
        cross=1
    elif x == W2 and y == H2:
        cross=1
    print("{0:.6f}".format(men),cross)
elif a > b:
    anx=float(H/a)
    men=(anx*H)/2
    print("{0:.6f}".format(men),cross)
else:
    any=float(W*a)
    men=(W*any)/2
    print("{0:.6f}".format(men),cross)

Submission status: Runtime Error

Solution code:
w, h, x, y = map(int, input().split())

x1 = w - x
y1 = h - y

s = w * h / 2
s1 = x * h / 1
s2 = x1 * h / 1
s3 = y * w / 1 
s4 = y1 * w / 1

if s == s1:
	ans = s1
elif s == s2:
	ans = s2
elif s == s3:
	ans = s3
elif s == s4:
	ans = s4

cnt = 0

if s1 == ans:
	cnt += 1
if s2 == ans:
	cnt += 1
if s3 == ans:
	cnt += 1
if s4 == ans:
	cnt += 1

print(ans, end=" ")
if (cnt > 1):
	print(1)
else:
	print(0)

Submission status: Runtime Error

Solution code:
w, h, x, y = map(int, input().split())
l = []
for h_i in range(1, h+1):
    for w_i in range(1, w+1):

        # 三角形(0, w, y)の面積
        #t_wy = (w_i*y) / 2

        # 三角形(0, x, h)の面積
        #t_xh = (x*h_i) / 2
        
        # 長方形の面積
        s_wy = w_i*y
        s_xh = x*h_i

        if w_i <= x:
            l.extend([s_wy, s_xh])
        #print('wの面積', t_wy) 
        #print('hの面積', t_xh)
        #print('wの長方形', s_wy) 
        #print('hの長方形', s_xh)
        #print('w, h', w_i, h_i)
print(l)

print(max(l))

# maxが複数あるか
if len([i for i, x in enumerate(l) if x == max(l)]) >= 1:
    print(0)
else:
    print(1)

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int,input().split())
buf_x = W-x
buf_y = H-y
if buf_x >= x:
  ver_area = H*x
else:
  ver_area = H*buf_x
if buf_y >= y:
  hori_area = W*y
else:
  hori_area = W*buf_y

if H/W == y/x:
  print(float(ver_area),1)
else:
  if ver_area <= hori_area:
    print(float(hori_area),0)
  else:
    print(float(ver_area),0)

Submission status: Runtime Error

Solution code:
w,h,x,y = map(int,input().split())

a = min(x,w-x)
s = h*a

b = min(y, h-y)
t = w*b

result = 0

if x == w/2 and y == h/2:
    result = 1

u = 0
if x == 0 or x == w or y == 0 or y == h:
    u = h*w/2

v = 0
if y/x == h/w or y == -h/w + h:
    v = h*w/2

print(max(s,t,u,v),result)

Submission status: Runtime Error

Solution code:
a,b,c,d = list(map(int,input().split()))
sum = 0
sum = a*b
if (a//2 is c) and (b//2 is d):
  　print(sum/2)
    print("1")
else:
  　print(sum/2-0.000001)
    print("0")

Submission status: Runtime Error

Solution code:
W,H,x,y=map(int,input().split())
men=W*H/2
a=float(y/x)
b=float(H/W)
W2=float(W/2)
H2=float(H/2)
cross=0
if a == b or x == W2 or y == H2:
    if a == b and x == W2:
        cross=1
    elif a == b and y == H2:
        cross=1
    elif x == W2 and y == H2:
        cross=1
    print("{0:.6f}".format(men),cross)
elif a > b:
    anx=float(H/a)
    print("{0:.6f}".format(anx*H/2),cross)
else:
    any=float(W*a)
    print("{0:.6f}".format(W*any/2),cross)

Submission status: Runtime Error

Solution code:
W,H,x,y = (int(x) for x in input().split())

ans = 0
flag = 0

if (W / x == 2) and (H / y == 2):
  ans = W * H / 2
  flag = 1  
elif W / x == 2 or y == 0 or y == H:
  ans = x * H
elif H / y == 2 or x == 0 or x == W:
  ans = W * y
else:
  tmp1 = []
  tmp1.append(x * H)
  tmp1.append((W - x) * H)
  
  tmp2 = []
  tmp2.append(W * y)
  tmp2.append(W * (H - y))
  
  if min(tmp1) > min(tmp2):
    ans = min(tmp1)
  else:
    ans = min(tmp2)

print(float(ans), flag)

Submission status: Runtime Error

Solution code:
W,H,x,y = map(int,input().split())
temp1 = [(W-x)*H,x*H]
temp2 = [W*y,W*(H-y)]

ans = max(min(temp1),min(temp2))
if  (W/2 == x and H/2 == y):
    print(W*H/2,1)
elif H/W == y/x:
    print(W*H/2,0)
elif x == 0 or x == W or y == 0 or y == H:
    print(W*H/2,0)
elif min(temp1) == min(temp2):
    print(ans,1)
else:
    print(ans,0)

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int, input().split())

if (W == x and H == Y):
    res1 = W * H / 2
    res2 = 0
else:
    tate1 = (W - x) * H
    tate2 = x * H 
    tate = min(tate1, tate2)

    yoko1 = W * (H - y)
    yoko2 = W * y
    yoko = min(yoko1, yoko2)

    res1 = max(yoko, tate)
    res2 = int(yoko == tate)

print(res1, res2)

Submission status: Runtime Error

Solution code:
w,h,x,y=map(int,input().split())

if w==x:
    print('{:6f}'.format(min(w*(h-y),w*y)),0)
elif h==x:
    print('{:6f}'.format(min((w-x)*h,x*h)),0)
elif (w-x)*h==w*(h-y):
    print('{:6f}'.format((w-x)*h,1)
elif min((w-x)*h,x*h)>min(w*(h-y),w*y):
    print('{:6f}'.format(min((w-x)*h,x*h)),0)
else:
    print('{:6f}'.format(min(w*(h-y),w*y)),0)

Submission status: Runtime Error

Solution code:
W,H,x,y= map(int,input().split())
max=W*H/2
if x=W or y=H:
  check=0
else:
  check=1

print(max,check)

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int,input().split(" "))
S = W * H

Ss, Ss_Sub = [], []

for i in range(1,x+1): Ss.append(i * H)
for i in range(1,y+1): Ss.append(i * W)
for i in range(len(Ss)): Ss_Sub.append(abs(S - Ss[i] - Ss[i]))

print('{:.6f}'.format(Ss[Ss_Sub.index(min(Ss_Sub))]))

if len([n for n, v in enumerate(Ss_Sub) if v == min(Ss_Sub)]) > 1:
    print("1")
else:
    print("0")

Submission status: Runtime Error

Solution code:
import sys

W, H, x, y = map(int, input().split())
# 対角線の交点を通る直線を引いた時最大？
all_area = W * H # 面積
c_x = W / 2
c_y = H / 2
if x - c_x == 0:
    if y - c_y == 0:
        print(all_area / 2, 1)
    else:
        print(all_area / 2, 0)
    sys.exit(0)
if y - c_y == 0:
    print(all_area / 2, 0)
    sys.exit(0)
a = (y - c_y) / (x - c_x) # 直線の傾き
b = y - a * x # 切片

# 交わってる部分の判定
left, right, up, bottom = False, False, False, False
if (1 - b) / a >= 0 and (1 - b) / a <= W:
    up = True
if b >= 0 and b <= H:
    left = True
if a + b >= 0 and a + b <= H:
    right = True
if -b / a >= 0 and -b / a <= W:
    bottom = True

# 交わってる部分により面積導出
def calcarea(up, bottom, high):
    return (up + bottom) * hight / 2
if left:
    if right:
        area = calcarea(b, a + b, W)
    if up:
        area = calcarea(0, H - W, (1 - b) / a)
    if bottom:
        area = calcarea(0, b, -b / a)
if right:
    if up:
        area = calcarea(0, H - (a + b), W - (1 - b) / a)
    if bottom:
        area = calcarea(0, H - (a + b), W - (-b / a))
if up:
    if bottom:
        area = calcarea(W - (1 - b) / a, W - (-b / a), H)

# 小さい方
if area > all_area - area:
    area = all_area - area
print(area, 0)

Submission status: Runtime Error

Solution code:

import numpy as np
W,H,x,y = map(int,input().split())

min_s = W*H
for i in range(W):
    s = abs(W*H - 2 * (i*H))
    if min_s > s:
        min_s = s
        ts = i*H

min_s2 = W*H
flag = 0 
for d in range(360):
    if(d == 90 or d == 270):
        continue
    rad = np.deg2rad(d)
    a = np.tan(rad)
    h = a*W - 2*a*x + 2*y
    men = (a*x-y+h/2)*W
    s = abs(W*H - 2 * men)
    if min_s2 > s:
        min_s2 = s
        ts2 = men
    elif min_s2 == s:
        flag = 1

flag2 = 0
if ts2 == ts: 
    flag2 = 1
    
if min_s2 > min_s:
    print(ts,flag2)
else:
    print(ts2,flag)

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int, input().split())
# ansx = min([(W-x)*H,x*H])
# ansy = min([(H-y)*W,y*W])
if W/2 == y or H/2 == x or (W%x ==0 and H%y==0):
    print(W*H//2,1)
else:
    # print(max(ansx,ansy),0)
    print(W*H//2,0)

Submission status: Runtime Error

Solution code:
W,H,x,y = (int(x) for x in input().split())

ans = 0
flag = 0

if (W / x == 2) and (H / y == 2):
  ans = W * H / 2
  flag = 1  
elif W / x == 2:
  ans = x * H
elif H / y == 2:
  ans = W * y
else:
  tmp1 = []
  tmp1.append(x * H)
  tmp1.append((W - x) * H)
  
  tmp2 = []
  tmp2.append(W * y)
  tmp2.append(W * (H - y))
  
  if min(tmp1) > min(tmp2):
    ans = min(tmp1)
  else:
    ans = min(tmp2)

print(float(ans), flag)

Submission status: Runtime Error

Solution code:
import math
W, H, x, y = map(int, input().split(' '))

f_x, i_x = math.modf(W / x)
f_y, i_y = math.modf(H / y)

if f_x == 0 and f_y == 0:
    print(float(W * y), 1)
elif f_x == 0:
    print(float(H * x), 0)
elif f_y == 0:
    print(float(H * x), 0)

Submission status: Runtime Error

Solution code:
import sys
W, H, x, y = map(int, input().split())

area = max(min((W - x) * H, x * H), min((H - y) * W, y * W))

num = 0

if (x, y) == (0, 0) or (x, y) == (W, H) or (x, y) == (W, 0) or (x, y) == (0, H):
    print((W * H) / 2, 0)
    sys.exit()

#直線上も加えよう
if abs(W / x) == abs(H / y) or y == H - (H / W) * x:
    print(W * H / 2, 0)
    sys.exit()
    


if min((W - x) * H, x * H) == min((H - y) * W, y * W):
    num = 1
else:
    num = 0

print(area, num)

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int, input().split())

if W/2 == x and H/2 == y:
    ans_men = (W * H) / 2
    dif = 1
elif W/2 == x or H/2 == y:
    ans_men = (W * H) / 2
    dif = 0

print(ans_men, dif)

Submission status: Runtime Error

Solution code:
W,H,x,y = (int(i) for i in input().split())

is_double = 0
if x == W/2 and y == H/2:
    is_double = 1

res = min(x*H,(W-x)*H)
res2 = min((H-y)*W,y*W)

print("{} {}".format(max([res,res2,res3]),is_double))

Submission status: Runtime Error

Solution code:
W, H, x, y = [int(x) for x in input().split()]

l = [x*H, y*W, W*H - x*H, W*H - y*W]
l.sort()
res = '0' if l[0] != l[1] else '1'
print(f'{l[1]:.6f} {res}')

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int, input().split())

def calculate(W, H, x, y):
	total_area = W*H
	way = 0
	if(x==W/2 or y==H/2):
		area = total_area/2
	if(x==W/2 and y==H/2):
		way = 1
	return area, way

area, way = calculate(W, H, x, y)

print("%f %d" % (area, way))

Submission status: Runtime Error

Solution code:
w, h, x, y = map(int, input().split())

mina = float(min(w * h - x * h, x * h))
minb = float(min(w * h - w * y, w * y))

if x * y != 0:
    a = float(y / x)
    tmp = a * x
    area = x * tmp * 0.5
    if tmp > h:
        tmp = h / a
        area = tmp * y * 0.5

    minc = min(w * h - area, area)

if mina == minb == minc:
    print(mina, 1)
else:
    print(max(mina, minb, minc), 0)

Submission status: Runtime Error

Solution code:
w,h,x,y = map(int, input().split())

# 横
men1 = w * y
men2 = w * (h-y)

# 縦
men3 = x * h
men4 = (w-x) * h


#print("{0} {1} {2} {3}".format(str(men1), str(men2), str(men3), str(men4)))
out1 = max(min(men1, men2), min(men3, men4))
if min(men1, men2) == min(men3, men4):
    out2 = 1
elif (h / w) == (y / x):
    out2 = 1
else:
    out2 = 0

print("{0} {1}".format(out1, out2))

Submission status: Runtime Error

Solution code:
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()

# N = int(input())
# L = [int(x) for x in input().split()]
W, H, x, y = map(int, input().split())
# S = input()

ko = [-1] * 3
ko[0] = min(x * H, (W - x) * H)
ko[1] = min(y * W, (H - y) * W)
if (x, y) == (0, 0) or (x, y) == (0, H) or (x, y) == (W, 0) or (x, y) == (W, H) or y / x == H / W:
    ko[2] = (W * H) / 2

maxm = max(ko)
print(maxm, 1 if ko.count(maxm) > 1 else 0)

Submission status: Runtime Error

Solution code:
w, h, x, y = map(float, input().split())

min_1 = min((w - x) * h, x * h)
min_2 = min((h - y) * w, y * w)
min_3 = 0
if w / x == h / y:
    min_3 = w * h / 2

if w / x == h / y:
    print('{:.6f} {}'.format(min_3, 1))
elif min_1 == min_2:
    print('{:.6f} {}'.format(min_1, 1))
else:
    print('{:.6f} {}'.format(max(min_1, min_2), 0))

Submission status: Runtime Error

Solution code:
#c.py
w,h,x,y = map(int,input().split())
min(w * y,(w*h)-w*y)
min(h * x,(w*h)-h*x)
if x > w//2 and y > h//2:
    m = 
if w//2 == x and h//2 == y:
    print(w*h/2,0)
else:
    ans = max(min(w*y,(w*h)-w*y),min(h*x,(w*h)-h*x))
    print(ans,1)

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int, input().split())

def calculate(W, H, x, y):
	total_area = W*H
	if(x==W/2 or y==H/2):
		area = total_area/2
	if(x==W/2 and y==H/2):
		way = 1
	else:
		way = 0
	return area, way

area, way = calculate(W, H, x, y)

print("%f %d" % (area, way))

Submission status: Runtime Error

Solution code:

AtCoder Beginner Contest 130
 日本語 
 consomme (Contestant) 
コンテスト時間: 2019-06-16(日) 21:00 ~ 2019-06-16(日) 22:40 AtCoderホームへ戻る
 トップ
 問題
 質問
 提出
 提出一覧
 順位表
 コードテスト
提出 #5970753

ソースコード 

Copy
Copy
W ,H, x, y=map(float, input().split())
 
#sqA
sqA = min(H * x, H * (W - x))
#sqB
sqB = min(y * W, (H - y) * W)
 
#print(sqA)
#print(sqB)
 
if sqA == sqB:
   #print('{0:.6f}'.format(max(sqA,sqB))+ ' ' + "1")
   print(max(sqA,sqB)+ ' ' + "1")
else:
   #print('{0:.6f}'.format(max(sqA,sqB))+ ' ' + "0")
   print(max(sqA,sqB)+ ' ' + "0")
W ,H, x, y=map(float, input().split())

#sqA
sqA = min(H * x, H * (W - x))
#sqB
sqB = min(y * W, (H - y) * W)

#print(sqA)
#print(sqB)

if sqA == sqB:
   #print('{0:.6f}'.format(max(sqA,sqB))+ ' ' + "1")
   print(max(sqA,sqB)+ ' ' + "1")
else:
   #print('{0:.6f}'.format(max(sqA,sqB))+ ' ' + "0")
   print(max(sqA,sqB)+ ' ' + "0")
提出情報
提出日時	2019-06-16 21:41:46
問題	C - Rectangle Cutting
ユーザ	consomme
言語	Python3 (3.4.3)
得点	0
コード長	345 Byte
結果	
テストケース
セット名	得点 / 配点	テストケース
Sample	0 / 0	C001_scrambled, C002_scrambled
All	0 / 300	C003_scrambled, C004_scrambled, C005_scrambled, C006_scrambled, C007_scrambled, C008_scrambled, C009_scrambled, C010_scrambled, C011_scrambled, C012_scrambled, C013_scrambled, C014_scrambled
ケース名	結果	実行時間	メモリ
C001_scrambled	
C002_scrambled	
C003_scrambled	
C004_scrambled	
C005_scrambled	
C006_scrambled	
C007_scrambled	
C008_scrambled	
C009_scrambled	
C010_scrambled	
C011_scrambled	
C012_scrambled	
C013_scrambled	
C014_scrambled	
FacebookTwitterHatena共有
ルール 用語集
利用規約 プライバシーポリシー 個人情報保護方針 企業情報 よくある質問 お問い合わせ 資料請求
Copyright Since 2012 ©AtCoder Inc. All rights reserved.
 ページトップ

Submission status: Runtime Error

Solution code:
w,h,x,y=map(int,input().split())
area=0
count=0
if w/x==2:
    if h/y==2:
        count=1
        area=h*x
    else:
        count=0
        area=h*x
if h/y==2:
    if w/x==2:
        count=1
        area=w*y
    else:
        count=0
        area=w*y
if x>y and w/x!=2 and h/y!=2:
    count=0
    area=w*y
if x<y and w/x!=2 and h/y!=2:
    count=0
    area=h*x
if x==y and w/x!=2 and h/y!=2:
    if w==h:
        count=1
        area=h*x
    if w>h:
        count=0
        area=h*x
    if w>h:
        count=0
        area=w*y
area='{:.9g}'.format(area)
l=[]
l.append(str(area))
l.append(" ")
l.append(str(count))
print(''.join(l))

Submission status: Runtime Error

Solution code:
W,H,x,y = (int(x) for x in input().split())

ans = 0
flag = 0
if (W / x == 2) and (H / y == 2):
  ans = W * H / 2
  flag = 1  
else:
  tmp1 = []
  tmp1.append(x * H)
  tmp1.append((W - x) * H)
  
  tmp2 = []
  tmp2.append(W * y)
  tmp2.append(W * (H - y))
  
  if min(tmp1) > min(tmp2):
    ans = min(tmp1)
  else:
    ans = min(tmp2)

print(float(ans), flag)

Submission status: Runtime Error

Solution code:
w, h, x, y= map(int,input().split())

f = 0
if x <= w/2 and y <= h/2:
    if y/x == h/w and x == w/2 and y == h/2:
        s = h*w/2
        f = 1
    elif y/x == h/w and (x < w/2 or y < h/2):
        s = h*w/2
    else:
        s1 = x*h
        s2 = w*y
        s = max(s1,s2)
        if s1 == s2:
            f=1
    print(s,f)
elif x > w/2 and y <= h/2:
    if (h-y)/x == h/w:
        s = h*w/2
    else:
        s1 = (w-x)*h
        s2 = w*y
        s = max(s1,s2)
        if s1 == s2:
            f=1
    print(s,f)
elif x > w/2 and y > h/2:
    if y/x == h/w:
        s = h*w/2
    else:
        s1 = (w-x)*h
        s2 = w*(h-y)
        s = max(s1,s2)
        if s1 == s2:
            f=1
    print(s,f)
elif x <= w/2 and y > h/2:
    if (h-y)/x == h/w:
        s = h*w/2
    else:
        s1 = x*h
        s2 = w*(h-y)
        s = max(s1,s2)
        if s1 == s2:
            f=1
    print(s,f)

Submission status: Runtime Error

Solution code:
import sys

W, H, x, y = map(int, input().split())
# 対角線の交点を通る直線を引いた時最大？
all_area = W * H # 面積
c_x = W / 2
c_y = H / 2
if x - c_x == 0:
    if y - c_y == 0:
        print(all_area / 2, 1)
    else:
        print(all_area / 2, 0)
    sys.exit(0)
if y - c_y == 0:
    print(all_area / 2, 0)
a = (y - c_y) / (x - c_x) # 直線の傾き
b = y - a * x # 切片

# 交わってる部分の判定
left, right, up, bottom = False, False, False, False
if (1 - b) / a >= 0 and (1 - b) / a <= W:
    up = True
if b >= 0 and b <= H:
    left = True
if a + b >= 0 and a + b <= H:
    right = True
if -b / a >= 0 and -b / a <= W:
    bottom = True

# 交わってる部分により面積導出
def calcarea(up, bottom, high):
    return (up + bottom) * hight / 2
if left:
    if right:
        area = calcarea(b, a + b, W)
    if up:
        area = calcarea(0, H - W, (1 - b) / a)
    if bottom:
        area = calcarea(0, b, -b / a)
if right:
    if up:
        area = calcarea(0, H - (a + b), W - (1 - b) / a)
    if bottom:
        area = calcarea(0, H - (a + b), W - (-b / a))
if up:
    if bottom:
        area = calcarea(W - (1 - b) / a, W - (-b / a), H)

# 小さい方
if area > all_area - area:
    area = all_area - area
print(area, 0)

Submission status: Runtime Error

Solution code:
W ,H, x, y=map(float, input().split())

#sqA
sqA = min(H * x, H * (W - x))
#sqB
sqB = min(y * W, (H - y) * W)

#print(sqA)
#print(sqB)

if sqA == sqB:
   #print('{0:.6f}'.format(max(sqA,sqB))+ ' ' + "1")
   print(max(sqA,sqB)+ ' ' + "1")
else:
   #print('{0:.6f}'.format(max(sqA,sqB))+ ' ' + "0")
   print(max(sqA,sqB)+ ' ' + "0")

Submission status: Runtime Error

Solution code:
w,h,x,y=map(int,input().split())
if w%x==0 and h%y==0:
    print(x*h) 
    print(1)
elif w%x==0 and h%y!=0:
    print(x*h)
    print(0)
elif w%x!=0 and h%y==0:
    print(y*w)
    print(0)
else:
    print(x*y)
    print(0)

Submission status: Runtime Error

Solution code:
w, h, x, y = map(int, input().split())

if x > w / 2:
    x = w - x
if y > h / 2:
    y = h - y


if x / w > y / h:
    a = []
    a.append(w * w * y / x / 2)
    a.append(h * h * x / (h - y) / 2)
    a.append(w * w * y / (w - x) / 2)
    a.append(h * h  * (w - x) / (h - y) / 2)
    a.append(x * h)
    a.append(y * w)
else:
    a = []
    a.append(h * h * x / y / 2)
    a.append(h * (h - y) * x / y / 2)
    a.append(w * w * y / (w - x) / 2)
    a.append(w * w * (h - y) / (w - x) / 2)
    a.append(x * h)
    a.append(y * w)

m = max(a)

counter = 0
for i in range(6):
    if a[i] == m:
        counter += 1
if counter >= 2:
    flag = 1
else:
    flag = 0

print(m, flag)

Submission status: Runtime Error

Solution code:
import sys

W, H, x, y = map(int, input().split())
# 対角線の交点を通る直線を引いた時最大？
all_area = W * H # 面積
c_x = W / 2
c_y = H / 2
if x - c_x == 0:
    if y - c_y == 0:
        print(all_area / 2, 1)
    else:
        print(all_area / 2, 0)
    sys.exit(0)
a = (y - c_y) / (x - c_x) # 直線の傾き
b = y - a * x # 切片

# 交わってる部分の判定
left, right, up, bottom = False, False, False, False
if (1 - b) / a >= 0 and (1 - b) / a <= W:
    up = True
if b >= 0 and b <= H:
    left = True
if a + b >= 0 and a + b <= H:
    right = True
if -b / a >= 0 and -b / a <= W:
    bottom = True

# 交わってる部分により面積導出
def calcarea(up, bottom, high):
    return (up + bottom) * hight / 2
if left:
    if right:
        area = calcarea(b, a + b, W)
    if up:
        area = calcarea(0, H - W, (1 - b) / a)
    if bottom:
        area = calcarea(0, b, -b / a)
if right:
    if up:
        area = calcarea(0, H - (a + b), W - (1 - b) / a)
    if bottom:
        area = calcarea(0, H - (a + b), W - (-b / a))
if up:
    if bottom:
        area = calcarea(W - (1 - b) / a, W - (-b / a), H)

# 小さい方
if area > all_area - area:
    area = all_area - area
print(area)

Submission status: Runtime Error

Solution code:
w,h,x,y=map(int,input().split())
tl=set([(w-x)*h,w*(h-y),x*h,w*y])

if (w-x)*h==w*(h-y):
    print('{:6f}'.format((w-x)*h),1)
elif min((w-x)*h,x*h)>min(w*(h-y),w*y):
    print('{:6f}'.format(min((w-x)*h,x*h)),0)
else:
    print('{:6f}'.format(min(w*(h-y),w*y),0)

Submission status: Runtime Error

Solution code:
w, h, x, y = [int(s) for s in input().split(" ")]

a = w * h

print("%f %d" % (a * 0.5, int(w // 2 == x and h // 2 == y))

Submission status: Runtime Error

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
    return list(map(int,input().split()))
def m():
    return map(int,input().split())
def onem():
    return int(input())
def s(x):
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x):
    return " ".join(map(str,x))

w,h,x,y= m()

if w/2 = x and h/2 == y:
    print("{0} {1}".format(w*h/2,1))
else:
    print("{0} {1}".format(w*h/2,0))

Submission status: Runtime Error

Solution code:
w,h,x,y = map(int, input().split())
x_min = x if x*2<w else w-x
y_min = y if y*2<w else w-y
if x_min>y_min:
    s = x_min*h
    if y_min/x_min==h/w:
        ans=1
    else:
        ans=0
elif (x_min==0)&(y_min==0):
    s = w*h/2
    ans=0
elif x_min==0:
    s = y_min*w
    ans=0
else:
    s = y_min*h
    if y_min/x_min==h/w:
        ans=1
    else:
        ans=0
print(float(s),ans)

Submission status: Runtime Error

Solution code:
W=int(input())
H=int(input())
x=int(input())
y=int(input())
s=0

if x==y:
  s=W*H/2
  s=float(s)
  print('{0:.6f} 1'.format(s))
else:
  s_1=(W-x)*H
  s_1=float(s_1)
  if s_1>W*H/2:
    s_1=W*H-s_1
  s_2=W*(H-y)
  s_2=float(s_2)
  if s_2>W*H/2:
    s_2=W*H-s_2
  if s_1<s_2:
    print('{0:.6f} 0'.format(s_2))
  else:
    print('{0:.6f} 0'.format(s_1))

Submission status: Runtime Error

Solution code:
w, h, x, y = [int(s) for s in input().split(" ")]

a = w * h

print("%d %d" % (a * 0.5, int(w // 2 == x and h // 2 == y))

Submission status: Runtime Error

Solution code:
W,H,x,y = (int(x) for x in input().split())

ans = 0
flag = 0
if (W / x == 2) and (H / y == 2):
  ans = W * H / 2
  flag = 1  
else:
  ans1 = 0
  if (W - x) > x:
    ans1 = x * H
  else:
    ans1 = (W - x) * H

  ans2 = 0
  if (H - y) > y:
    ans2 = W * y
  else:
    ans2 = W * (H - y)
  
  if ans1 < ans2:
    ans = ans2
  else:
    ans = ans1 

print(float(ans), flag)

Submission status: Runtime Error

Solution code:
w, h, x, y=map(int, input().split())
centX=w/2
centY=h/2
if x==centX and y==centY
    print(w*h/2, " ", "1")
else: print(w*h/2, " ", "0")

Submission status: Runtime Error

Solution code:
w, h, x, y= map(int,input().split())

f = 0
if x <= w/2 and y <= h/2:
    if y/x == h/w and x == w/2 and y == h/2:
        s = h*w/2
        f = 1
    elif y/x == h/w:
        s = h*w/2
    else:
        s1 = x*h
        s2 = w*y
        s = max(s1,s2)
        if s1 == s2:
            f=1
    print(s,f)
elif x > w/2 and y <= h/2:
    if (h-y)/x == h/w:
        s = h*w/2
    else:
        s1 = (w-x)*h
        s2 = w*y
        s = max(s1,s2)
        if s1 == s2:
            f=1
    print(s,f)
elif x > w/2 and y > h/2:
    if y/x == h/w:
        s = h*w/2
    else:
        s1 = (w-x)*h
        s2 = w*(h-y)
        s = max(s1,s2)
        if s1 == s2:
            f=1
    print(s,f)
elif x <= w/2 and y > h/2:
    if (h-y)/x == h/w:
        s = h*w/2
    else:
        s1 = x*h
        s2 = w*(h-y)
        s = max(s1,s2)
        if s1 == s2:
            f=1
    print(s,f)

Submission status: Runtime Error

Solution code:
import sys

list = list(map(int, input().split()))
length_list = map(int, input().split())

N = list[0]
X = list[1]

i = 1
total = 0

for len in length_list:
  total = total + len
  if total <= X:
    i = i + 1
    if i == N + 1:
      print(i)
  else:
    print(i)
    sys.exit()

Submission status: Runtime Error

Solution code:
def solve():
    w, h, x, y = map(float, input().split())
    ans = []
    if y != 0:
        ans.append(sorted((w * y, w * (h - y)))[0])
    if x != 0:
        ans.append(sorted((h * x, h * (w - x)))[0])
    print(max(ans), len(ans) - len(set(ans)))
solve()

Submission status: Runtime Error

Solution code:
W,H,x,y = (int(x) for x in input().split())

ans = 0
flag = 0
if (W / x == 2) and (H / y == 2):
  ans = W * H / 2
  flag = 1  
else:
  ans1 = 0
  if (W - x) > x:
    ans1 = x * H
  else:
    ans1 = (W - x) * H

    ans2 = 0
  if (H - y) > y:
    ans2 = W * y
  else:
    ans2 = W * (H - y)
  
  if ans1 < ans2:
    ans = ans2
  else:
    ans = ans1 

print(float(ans), flag)

Submission status: Runtime Error

Solution code:
W, H, x, y = map(int, input().split())


ans1_1 = W * (H - y)
ans1_2 = W * y

ans2_1 = x * H
ans2_2 = (W - x) * H

if (x == 0 and y == 0) or (x == W and y == H) or (x == 0 and y == H) or (x == W and y == 0):
    print(W * H / 2, 0)
    
elif x == 0 or x == W 
    print(W * (y + (H - y))/2, 0)
    
elif y == 0 or y == H:
    print(H * (x + (W - x))/2, 0)
    
elif abs(ans1_1 - ans1_2) <  abs(ans2_1 - ans2_2):
    
    print(min(ans1_1, ans1_2), 0)
    
elif abs(ans1_1 - ans1_2) ==  abs(ans2_1 - ans2_2):
    
    print(min(ans1_1, ans1_2), 1)
    
else:
    print(min(ans2_1, ans2_2), 0)

Submission status: Runtime Error

Solution code:
a = input().split(" ")
w = int(a[0])
h = int(a[1])
x = int(a[2])
y = int(a[3])
s = w * h / 2
if w % 2 == 0:
    if h %  2 == 0:
        if x == int(w/2):
            if y == int(h/2):
                how = 1
else:
    how = 0
print(str(s) + " " + str(how))

Submission status: Runtime Error

Solution code:
W,H,x,y = (int(i) for i in input().split())

is_double = 0
if x == W//2 and y == H//2:
    is_double = 1

if x>=W//2:
    res = (W-x)*H
else:
    res = x*H

if y>=H//2:
    res2 = (H-y)*W
else:
    res2 = y*W

if x==y*W/H or x==(H-y)*W/H:
    res3 = H*W/2

print("{} {}".format(max([res,res2,res3]),is_double))