Problem:


Area

For a given polygon g, computes the area of the polygon.

g is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 ≤ i ≤ n-1) are sides of g. The line segment connecting pn and p1 is also a side of the polygon.

Note that the polygon is not necessarily convex.

Input

The input consists of coordinates of the points p1,..., pn in the following format:

n
x1 y1 
x2 y2
:
xn yn

The first integer n is the number of points. The coordinate of a point pi is given by two integers xi and yi. The coordinates of points are given in the order of counter-clockwise visit of them.

Output

Print the area of the polygon in a line. The area should be printed with one digit to the right of the decimal point.

Constraints

3 ≤ n ≤ 100

-10000 ≤ xi, yi ≤ 10000

No point will occur more than once.

Two sides can intersect only at a common endpoint.

Sample Input 1

3
0 0
2 2
-1 1

Sample Output 1

2.0

Sample Input 2

4
0 0
1 1
1 2
0 2

Sample Output 2

1.5



Sample input:
3
0 0
2 2
-1 1


Sample output:
2.0

Submission status: Wrong Answer

Solution code:
from sys import stdin
readline = stdin.readline


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def triangle(a, b, c):
    v1, v2 = b - a, c - a
    s = abs(v1) ** 2 * abs(v2) ** 2 - dot(v1, v2) ** 2
    return s ** 0.5 * 0.5


def polygon(p):
    return sum(triangle(p[0], pi, pj) for pi, pj in zip(p[1:], p[2:]))


n = int(readline())
p = [map(int, readline().split()) for _ in range(n)]
p = [x + y * 1j for x, y in p]
print('{:.1f}'.format(polygon(p)))

Submission status: Wrong Answer

Solution code:
from sys import stdin
readline = stdin.readline


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def is_subconcave(a, b, c):
    return cross(b - a, c - a) < 0


def triangle(a, b, c):
    v1, v2 = b - a, c - a
    s = abs(v1) ** 2 * abs(v2) ** 2 - dot(v1, v2) ** 2
    return s ** 0.5 * 0.5


def concave_polygon(p):
    # search convex vertex
    for i in range(len(p)):
        j, k = i - 1, i - 2
        if not is_subconcave(p[i], p[j], p[k]):
            p = p[i:] + p[:i]
            break

    s = 0
    sub_concave = []
    sub_convex = []
    for i in range(len(p)):
        j, k = i - 1, i - 2
        if is_subconcave(p[k], p[j], p[i]):
            sub_concave.append(p[k])
        else:
            sub_convex.append(p[j])
            if sub_concave:
                s -= convex_polygon(sub_concave + [p[k], p[j]])
                sub_concave = []
    return s + convex_polygon(sub_convex)


def convex_polygon(p):
    return sum(triangle(p[0], pi, pj) for pi, pj in zip(p[1:], p[2:]))


n = int(readline())
p = [map(int, readline().split()) for _ in range(n)]
p = [x + y * 1j for x, y in p]
print('{:.1f}'.format(concave_polygon(p)))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import cmath


def outer_product(v1, v2):
    return v1.real * v2.imag - v1.imag * v2.real


def in_place_sort_points_ccw(points):
    points.sort(key=cmath.phase)


def area_polygon(n, points):
    in_place_sort_points_ccw(points)
    s = sum(outer_product(points[i], points[(i + 1) % n])
            for i in range(n)) / 2.0
    return s


def main():
    n = int(input())
    ps = [complex(*map(float, input().split())) for _ in range(n)]
    s = area_polygon(n, ps)
    print("{:.1f}".format(s))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def cross(a,b):return a[0]*b[1] - a[1]*b[0]
        
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
for i in range(n-1):s += cross(P[i],P[i+1])
print(s/2)

Submission status: Wrong Answer

Solution code:
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for i in range(n-2):
    s += P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0]
print(abs(s)*0.5)

Submission status: Wrong Answer

Solution code:
n = int(input())
P =[]
s = 0
for _ in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for j in range(n):s += P[j][1]*P[j+1][0] - P[j+1][1] * P[j][0]
print(s*0.5)

Submission status: Wrong Answer

Solution code:
n = int(input())
P =[]
s = 0
for _ in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for j in range(n):s += P[j][1]*P[j+1][0] -  P[j][0] * P[j+1][1]
print(s*0.5)

Submission status: Wrong Answer

Solution code:
n = int(input())
P =[]
s = 0
for _ in range(n):P.append([-int(i) for i in input().split()])
P.append(P[0])
for j in range(n):s += P[j][1]*P[j+1][0] -  P[j][0] * P[j+1][1]
print(s*0.5)

Submission status: Wrong Answer

Solution code:
x=range(int(input()))
P=[]
_=0
for _ in x:P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:_+=P[j][0]*P[j+1][1]-P[j][1]*P[j+1][0]
print(_*0.5)

Submission status: Wrong Answer

Solution code:
x=range(int(input()),0,-1)
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:_+=P[j-1][0]*P[j][1]-P[j-1][1]*P[j][0]
print(_*0.5)

Submission status: Wrong Answer

Solution code:
x=range(int(input()),0,-1)
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:_+=P[j-1][0]*P[j][1]-P[j-1][1]*P[j][0]
print(_*0.5-1)

Submission status: Wrong Answer

Solution code:
x=range(int(input())-1,-1,-1)
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:_+=P[j-1][0]*P[j][1]-P[j-1][1]*P[j][0]
print(_*0.5)

Submission status: Wrong Answer

Solution code:
n=int(input())
P=[]
for _ in range(n):P+=[[int(i) for i in input().split()]]
_=0
P+=[P[0]]
for j in range(n-1):_+=P[j+1][1]*(P[j][0]-P[j+2][0])-P[j+1][0]*(P[j][1]-P[j+2][1])
print(_*0.5)

Submission status: Wrong Answer

Solution code:
n=int(input())
P=[]
for _ in range(n):P+=[[int(i) for i in input().split()]]
_=0
P+=[P[0]]
for j in range(n-1):_+=P[j+1][1]*(P[j][0]-P[j+2][0])-P[j+1][0]*(P[j][1]-P[j+2][1])
print(_*0.25)

Submission status: Wrong Answer

Solution code:
class Point():
    def __init__(self, x, y):
        self.x = x
        self.y = y

n = int(input())
points = []
for i in range(n):
    x, y = list(map(int, input().split(' ')))
    points.append(Point(x, y))

area = 0
a = points[0]
for i in range(2, len(points)):
    b, c = points[i-1], points[i]
    area += abs((b.x - a.x)*(c.y - a.y) - (c.x - a.x)*(b.y - a.y))/2
print(area)

Submission status: Wrong Answer

Solution code:
import math

class Vector():
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def inner_product(self, vec):
        return self.x*vec.x + self.y*vec.y

    def outer_product(self, vec):
        return self.x*vec.y - self.y*vec.x

    def norm(self):
        return math.sqrt(self.x**2 + self.y**2)

n = int(input())
points = []
for i in range(n):
    x, y = list(map(int, input().split(' ')))
    points.append(Vector(x, y))
points.append(points[0])

area = 0
for i in range(n-1):
    a, b = points[i], points[i+1]
    if (a.x == 0 and a.y == 0) or (b.x == 0 and b.y == 0): continue
    theta = math.atan2(a.outer_product(b), a.inner_product(b))
    if theta > 0:
        area += abs(a.outer_product(b))/2
    elif theta < 0:
        area -= abs(a.outer_product(b))/2
print(area)

Submission status: Wrong Answer

Solution code:
import math

def vec(s,e):
    return (e[0]-s[0], e[1]-s[1])

def dot(p,q):
    return p[0]*p[1] + q[0]*q[1]

def is_obtuse(p,q,r):
    b = vec(q,r)
    a = vec(q,p)
    c = (-b[1],b[0])
    bc = dot(a,b)
    pc = dot(c,b)
    return math.atan2(pc,bc) < 0

def dist(p,q):
    return ((p[0]-q[0])**2 + (p[1]-q[1])**2)**0.5

def area(p,q,r):
    a = dist(p,q)
    b = dist(q,r)
    c = dist(r,p)
    z = (a+b+c)/2
    return (z*(z-a)*(z-b)*(z-c))**0.5

n = int(input())

v = []
for _ in range(n):
    v.append([int(x) for x in input().split()])

sub_area = 0
v_ignore = [0 for _ in range(n)]

for i in range(n-2):
    if is_obtuse(v[i],v[i+1],v[i+2]):
        sub_list += area(v[i],v[i+1],v[i+2])
        v_ignore[i+1] = 1
    else:
        pass

v_cover = []

for i,x in enumerate(v_ignore):
    if x == 0:
        v_cover.append(v[i])

cover_area = 0

for i in range(1,len(v_cover)-1):
    cover_area += area(v_cover[0],v_cover[i],v_cover[i+1])

print(cover_area - sub_area)

Submission status: Wrong Answer

Solution code:
import math

def vec(s,e):
    return (e[0]-s[0], e[1]-s[1])

def dot(p,q):
    return p[0]*p[1] + q[0]*q[1]

def is_obtuse(p,q,r):
    b = vec(q,r)
    a = vec(q,p)
    c = (-b[1],b[0])
    bc = dot(a,b)
    pc = dot(c,b)
    return math.atan2(pc,bc) < 0

def dist(p,q):
    return ((p[0]-q[0])**2 + (p[1]-q[1])**2)**0.5

def area(p,q,r):
    a = dist(p,q)
    b = dist(q,r)
    c = dist(r,p)
    z = (a+b+c)/2
    return (z*(z-a)*(z-b)*(z-c))**0.5

n = int(input())

v = []
for _ in range(n):
    v.append([int(x) for x in input().split()])

sub_area = 0
v_ignore = [0 for _ in range(n)]

for i in range(n-2):
    if is_obtuse(v[i],v[i+1],v[i+2]):
        sub_list += area(v[i],v[i+1],v[i+2])
        v_ignore[i+1] = 1
    else:
        pass

v_cover = []

for i,x in enumerate(v_ignore):
    if x == 0:
        v_cover.append(v[i])

cover_area = 0

for i in range(1,len(v_cover)-1):
    cover_area += area(v_cover[0],v_cover[i],v_cover[i+1])

print(round(cover_area - sub_area,1))

Submission status: Wrong Answer

Solution code:
import math

def vec(s,e):
    return (e[0]-s[0], e[1]-s[1])

def dot(p,q):
    return p[0]*p[1] + q[0]*q[1]

def is_obtuse(p,q,r):
    b = vec(q,r)
    a = vec(q,p)
    c = (-b[1],b[0])
    bc = dot(a,b)
    pc = dot(c,b)
    return math.atan2(pc,bc) < 0

def dist(p,q):
    return ((p[0]-q[0])**2 + (p[1]-q[1])**2)**0.5

def area(p,q,r):
    a = dist(p,q)
    b = dist(q,r)
    c = dist(r,p)
    z = (a+b+c)/2
    return (z*(z-a)*(z-b)*(z-c))**0.5

n = int(input())

v = []
for _ in range(n):
    v.append([float(x) for x in input().split()])

sub_area = 0
v_ignore = [0 for _ in range(n)]

for i in range(n-2):
    if is_obtuse(v[i],v[i+1],v[i+2]):
        sub_list += area(v[i],v[i+1],v[i+2])
        v_ignore[i+1] = 1
    else:
        pass

v_cover = []

for i,x in enumerate(v_ignore):
    if x == 0:
        v_cover.append(v[i])

cover_area = 0

for i in range(1,len(v_cover)-1):
    cover_area += area(v_cover[0],v_cover[i],v_cover[i+1])

print(round(cover_area - sub_area,1))

Submission status: Accepted

Solution code:
from sys import stdin
readline = stdin.readline


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def triangle(a, b, c):
    v1, v2 = b - a, c - a
    s = abs(v1) ** 2 * abs(v2) ** 2 - dot(v1, v2) ** 2
    return s ** 0.5 * 0.5


def polygon(p):
    return 0.5 * sum(cross(p[i - 1], p[i]) for i in range(len(p)))


n = int(readline())
p = [map(int, readline().split()) for _ in range(n)]
p = [x + y * 1j for x, y in p]
print('{:.1f}'.format(polygon(p)))

Submission status: Accepted

Solution code:
n = int(input())
points = [tuple(map(int, input().split())) for _ in range(n)]
result = 0
px, py = points[0]
while points:
    x, y = points.pop()
    result += x * py - px * y
    px, py = x, y
print(abs(result) / 2)

Submission status: Accepted

Solution code:
n = int(input())
points = [complex(*map(int, input().split())) for _ in range(n)]
result, prev = 0, points[0]
while points:
    point = points.pop()
    result += point.real * prev.imag - prev.real * point.imag
    prev = point
print(abs(result) / 2)

Submission status: Accepted

Solution code:
n = input()
p = [map(int, raw_input().split()) for i in xrange(n)]
print abs(sum(p[i][0]*p[i-1][1] - p[i][1]*p[i-1][0] for i in xrange(n))) / 2.

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import cmath


def outer_product(v1, v2):
    return v1.real * v2.imag - v1.imag * v2.real


def area_polygon(n, points):
    s = sum(outer_product(points[i], points[(i + 1) % n])
            for i in range(n)) / 2.0
    return s


def main():
    n = int(input())
    ps = [complex(*map(float, input().split())) for _ in range(n)]
    s = area_polygon(n, ps)
    print("{:.1f}".format(s))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(raw_input())
S = float(0)
x = []
y = []
for _ in range(n):
  xi,yi = map(float, raw_input().split())
  x.append(xi)
  y.append(yi)
for i in range(n):
  S += x[i] * y[(i+1) % n] - x[(i+1) % n] * y[i]
S = S / 2
print "%.1f" % S

Submission status: Accepted

Solution code:
p=[complex(*map(int,input().split())) for _ in range(int(input()))]
s,pre=0,p[0]
while p:
    now=p.pop()
    s+=now.real*pre.imag-now.imag*pre.real
    pre=now
print(abs(s)/2)

Submission status: Accepted

Solution code:
def area(p,q):
    return (p[0]*q[1]-p[1]*q[0])*0.5

n=int(input())
point=[]
x_1,y_1=[int(i) for i in input().split(" ")]

for i in range(n-1):
    x,y=[int(k) for k in input().split(" ")]
    point.append([x-x_1,y-y_1])



a=0


for i in range(n-2):
    a+=area(point[i],point[i+1])

print(a)

Submission status: Accepted

Solution code:
def cross(a,b):return a[0]*b[1] - a[1]*b[0]
        
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
P = P*2
for i in range(n):s += cross(P[i],P[i+1])
print(abs(s)/2)

Submission status: Accepted

Solution code:
def cross(a,b):return a[0]*b[1] - a[1]*b[0]
        
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for i in range(n):s += cross(P[i],P[i+1])
print(abs(s)*0.5)

Submission status: Accepted

Solution code:
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for i in range(n):s += P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0]
print(abs(s)*0.5)

Submission status: Accepted

Solution code:
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for i in range(n):
    j = i+1
    s += P[i][0]*P[j][1] - P[i][1]*P[j][0]
print(abs(s)*0.5)

Submission status: Accepted

Solution code:
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for i in range(n):
    a = P[i][0] ; b = P[i][1]; c = P[i+1][0] ; d = P[i+1][1]
    s += a * d - b * c
print(abs(s)*0.5)

Submission status: Accepted

Solution code:
n = int(input())
P =[]
s = 0
x0,y0 = [int(i) for i in input().split()]
for i in range(n-1):
    x,y = [int(i) for i in input().split()]
    P.append([x-x0,y-y0])
for i in range(n-2):
    s += P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0]
print(abs(s)*0.5)

Submission status: Accepted

Solution code:
n = int(input())
P =[]
s = 0
for i in range(n):P.append(input().split())
P.append(P[0])
for i in range(n):s += int(P[i][0])*int(P[i+1][1]) - int(P[i][1])*int(P[i+1][0])
print(abs(s)*0.5)

Submission status: Accepted

Solution code:
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for i in range(n):s += (P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0])
print(abs(s)*0.5)

Submission status: Accepted

Solution code:
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for i in range(n):s += (P[i][0])*P[i+1][1] - (P[i][1])*P[i+1][0]
print(abs(s)*0.5)

Submission status: Accepted

Solution code:
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for i in range(n):s += P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0]
print(s*0.5)

Submission status: Accepted

Solution code:
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for j in range(n):s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]
print(s*0.5)

Submission status: Accepted

Solution code:
n = int(input())
P =[]
s = 0
for _ in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for j in range(n):s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]
print(s*0.5)

Submission status: Accepted

Solution code:
def area(p,q):return p[0]*q[1]-p[1]*q[0]
 
n=int(input())
point=[]
x_1,y_1=[int(i) for i in input().split(" ")]
 
for i in range(n-1):
    x,y=[int(k) for k in input().split(" ")]
    point.append([x-x_1,y-y_1])
a=0
for i in range(n-2):a+=area(point[i],point[i+1])
print(a*0.5)

Submission status: Accepted

Solution code:
def area(p,q):return p[0]*q[1]-p[1]*q[0]
 
n=int(input())
point=[]
x_1,y_1=[int(i) for i in input().split(" ")]
 
for _ in range(n-1):
    x,y=[int(k) for k in input().split(" ")]
    point.append([x-x_1,y-y_1])
a=0
for j in range(n-2):a+=area(point[j],point[j+1])
print(a*0.5)

Submission status: Accepted

Solution code:
def area(p,q):return p[0]*q[1]-p[1]*q[0]
 
n=int(input())
point=[]
x_1,y_1=[int(i) for i in input().split(" ")]
 
for _ in range(n-1):
    x,y=[int(i) for i in input().split(" ")]
    point.append([x-x_1,y-y_1])
a=0
for i in range(n-2):a+=area(point[i],point[i+1])
print(a*0.5)

Submission status: Accepted

Solution code:
n=int(input())
point=[]
x_1,y_1=[int(i) for i in input().split(" ")]
 
for _ in range(n-1):
    x,y=[int(i) for i in input().split(" ")]
    point.append([x-x_1,y-y_1])
a=0
for i in range(n-2):a+=point[i][0]*point[i+1][1] - point[i][1]*point[i+1][0]
print(a*0.5)

Submission status: Accepted

Solution code:
def area(p,q):return p[0]*q[1]-p[1]*q[0]
n = int(input())
P =[]
s = 0
for _ in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for i in range(n):s += P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0]
print(s*0.5)

Submission status: Accepted

Solution code:
n = int(input())
P =[]
s = 0
for _ in range(n):P.append(list(map(int,input().split())))
P.append(P[0])
for j in range(n):s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]
print(s*0.5)

Submission status: Accepted

Solution code:
n = int(input())
P =[]
s = 0
for _ in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for j in range(n):s += - P[j][1]*P[j+1][0] + P[j+1][1] * P[j][0]
print(s*0.5)

Submission status: Accepted

Solution code:
n = int(input())
P =[]
s = 0
for _ in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for j in range(n):s += P[j][1]*P[j+1][0] - P[j+1][1] * P[j][0]
print(s*-0.5)

Submission status: Accepted

Solution code:
n = int(input())
P =[]
s = 0
for _ in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for j in range(n):s += P[j][1]*P[j+1][0] -  P[j][0] * P[j+1][1]
print(s*-0.5)

Submission status: Accepted

Solution code:
n = int(input())
P =[]
s = 0
for _ in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for j in range(n):s -= P[j][1]*P[j+1][0] -  P[j][0] * P[j+1][1]
print(s*0.5)

Submission status: Accepted

Solution code:
n = int(input())
P =[]
s = 0
for _ in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for j in range(n):s += P[j][1]*P[j+1][0] -  P[j][0] * P[j+1][1]
print(-s*0.5)

Submission status: Accepted

Solution code:
n = int(input())
x = range(n)
P =[]
s = 0
for _ in x:P.append([int(i) for i in input().split()])
P.append(P[0])
for j in x:s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]
print(s*0.5)

Submission status: Accepted

Solution code:
n = int(input())
x = range(n)
P =[]
s = 0
for _ in x:P.append([int(i) for i in input().split()])
P+=[P[0]]
for j in x:s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]
print(s*0.5)

Submission status: Accepted

Solution code:
n = int(input())
x = range(n)
P =[]
s = 0
for _ in x:P += [[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]
print(s*0.5)

Submission status: Accepted

Solution code:
n = int(input())
P =[]
s = 0
for _ in range(n):P += [[int(i) for i in input().split()]]
for j in range(n-1):s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]
s += P[-1][0]*P[0][1] - P[-1][1]*P[0][0]
print(s*0.5)

Submission status: Accepted

Solution code:
n = int(input())
x = range(n)
P =[]
s = 0
for i in x:P += [[int(i) for i in input().split()]]
P+=[P[0]]
for i in x:s += P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0]
print(s*0.5)

Submission status: Accepted

Solution code:
x = range(int(input()))
P =[]
s = 0
for i in x:P += [[int(i) for i in input().split()]]
P+=[P[0]]
for i in x:s += P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0]
print(s*0.5)

Submission status: Accepted

Solution code:
x=range(int(input()))
P=[]
s=0
for i in x:P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for i in x:s+=P[i][0]*P[i+1][1]-P[i][1]*P[i+1][0]
print(s*0.5)

Submission status: Accepted

Solution code:
n = int(input())
x = range(n)
P =[]
n = 0
for _ in x:P += [[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:n += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]
print(n*0.5)

Submission status: Accepted

Solution code:
x=range(int(input()))
P=[]
s=0
for _ in x:P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:s+=P[j][0]*P[j+1][1]-P[j][1]*P[j+1][0]
print(s*0.5)

Submission status: Accepted

Solution code:
x=range(int(input()))
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
_=0
P+=[P[0]]
for j in x:_+=P[j][0]*P[j+1][1]-P[j][1]*P[j+1][0]
print(_*0.5)

Submission status: Accepted

Solution code:
x=range(int(input())-1,-1,-1)
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:_+=P[j][0]*P[j+1][1]-P[j][1]*P[j+1][0]
print(_*0.5)

Submission status: Accepted

Solution code:
x=range(int(input()),0,-1)
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:_+=P[j-1][0]*P[j][1]-P[j-1][1]*P[j][0]
print(_*0.5-0.5)

Submission status: Accepted

Solution code:
x=range(int(input()))
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
_=0
P+=[P[0]]
for j in x:
    k = j+1
    _+=P[j][0]*P[k][1]-P[j][1]*P[k][0]
print(_*0.5)

Submission status: Accepted

Solution code:
x=range(int(input()))
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
_=0
P+=[P[0]]
for j in x:
    i = j+1
    _+=P[j][0]*P[i][1]-P[j][1]*P[i][0]
print(_*0.5)

Submission status: Accepted

Solution code:
x=range(int(input()))
f=lambda a,d,b,c : a*d - b*c 
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
_=0
P+=[P[0]]
for j in x:_+=f(P[j][0],P[j+1][1],P[j][1],P[j+1][0])
print(_*0.5)

Submission status: Accepted

Solution code:
x=range(int(input()))
f=lambda a,b,c,d : a*d - b*c 
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
_=0
P+=[P[0]]
for j in x:_+=f(P[j][0],P[j][1],P[j+1][0],P[j+1][1])
print(_*0.5)

Submission status: Accepted

Solution code:
x=range(int(input()))
P=[]
Q=[]
for _ in x:P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:Q+=[P[j][0]*P[j+1][1]-P[j][1]*P[j+1][0]]
print(sum(Q)*0.5)

Submission status: Accepted

Solution code:
x=range(int(input()))
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
_=0
P+=[P[0]]
for j in x:_+=P[j][0]*P[j+1][1]-P[j+1][0]*P[j][1]
print(_*0.5)

Submission status: Accepted

Solution code:
x=range(int(input()))
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
_=0
P+=[P[0]]
for j in x:_+=P[j+1][1]*P[j][0]-P[j][1]*P[j+1][0]
print(_*0.5)

Submission status: Accepted

Solution code:
x=range(int(input()))
P=[]
for _ in reversed(x):P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:_+=P[j+1][1]*P[j][0]-P[j][1]*P[j+1][0]
print(_*0.5)

Submission status: Accepted

Solution code:
x=range(int(input())-1,-1,-1)
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:_+=P[j+1][1]*P[j][0]-P[j][1]*P[j+1][0]
print(_*0.5)

Submission status: Accepted

Solution code:
# Aizu Problem CGL_3_A: Area
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def poly_area(polygon, M):
    A = 0
    for i in range(M):
        x1, y1 = polygon[i][0], polygon[i][1]
        x2, y2 = polygon[(i+1)%M][0], polygon[(i+1)%M][1]
        A += (x1 * y2 - x2 * y1)
    return abs(A / 2)

N = int(input())
P = [[int(_) for _ in input().split()] for __ in range(N)]
print(poly_area(P, N))

Submission status: Accepted

Solution code:


n=int(input())

xy=[]
answer=0

for i in range(n):
    xy.append(list(map(float,input().split())))

for i in range(0,n):
    answer+=(xy[i][0]-xy[i-1][0])*(xy[i][1]+xy[i-1][1])

print(abs(answer)/2)

Submission status: Accepted

Solution code:
import math

class Vector():
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def inner_product(self, vec):
        return self.x*vec.x + self.y*vec.y

    def outer_product(self, vec):
        return self.x*vec.y - self.y*vec.x

    def norm(self):
        return math.sqrt(self.x**2 + self.y**2)

n = int(input())
points = []
for i in range(n):
    x, y = list(map(int, input().split(' ')))
    points.append(Vector(x, y))
points.append(points[0])

area = 0
for i in range(n):
    a, b = points[i], points[i+1]
    if (a.x == 0 and a.y == 0) or (b.x == 0 and b.y == 0): continue
    theta = math.atan2(a.outer_product(b), a.inner_product(b))
    if theta > 0:
        area += abs(a.outer_product(b))/2
    elif theta < 0:
        area -= abs(a.outer_product(b))/2
print(area)

Submission status: Accepted

Solution code:
def area(p,q,r):
    a = (q[0]-p[0], q[1]-p[1])
    b = (r[0]-p[0], r[1]-p[1])
    return (a[0]*b[1] - b[0]*a[1]) / 2

n = int(input())

v = []
for _ in range(n):
    v.append([float(x) for x in input().split()])

v = list(reversed(v))

s = 0

for i in range(1,n-1):
    s += area(v[0],v[i],v[i+1])

print(-1 * round(s,1))

Submission status: Accepted

Solution code:
p= []
n= int(input())

for i in range(n):
    x,y = map(float,input().split())
    p.append(complex(x,y))


n=len(p)
sum=0.0
for i in range(1,n-1):
    a,b= p[i]-p[0], p[i+1]-p[0]
    s= (a.conjugate()* b).imag
    sum+= s
print("%.1f" % (abs(sum)/2.0))

Submission status: Accepted

Solution code:
n = int(input())
a = []
for _ in range(n):
    x, y = map(int, input().split())
    a.append(complex(x, y))
ans = 0.0
p = a[0]
for i in range(n - 2):
    q, r = a[i + 1], a[i + 2]
    ans += (((q - p).conjugate() * (r - p)).imag) / 2
print(abs(ans))

Submission status: Accepted

Solution code:
def cross_product(a,b):
  return (a.conjugate()*b).imag
P = [] #頂点列
n = int(input())
for i in range(n):
    x,y = map(float,input().split())
    P.append(complex(x,y))
N=len(P)#頂点の個数
total = 0.0
for i in range(1,N-1):
    a,b,c = P[0],P[i],P[i+1]
    total += cross_product(b-a,c-a)
print('{:.1f}'.format(abs(total)/2.0))

Submission status: Accepted

Solution code:
import math
import cmath
def dot(a:complex,b:complex):
  return (a.conjugate()*b).real
def cross(a:complex,b:complex):
  return (a.conjugate()*b).imag
p=[]
n=int(input())
for i in range(n):
  x,y=map(float,input().split())
  p.append(complex(x,y))
S=0
for i in range(1,len(p)-1):
  S+=cross(p[i]-p[0],p[i+1]-p[0])
print(abs(S)/2)

Submission status: Accepted

Solution code:
def get_area(ps):
    """頂点集合psから成る多角形の面積を求める。"""
    n = len(ps)
    ans = 0
    for i in range(n):
        p1 = ps[i]
        p2 = ps[i - 1]
        ans += (p1[0] * p2[1] - p2[0] * p1[1]) / 2
    return abs(ans)


n = int(input())
ps = [list(map(int, input().split())) for i in range(n)]

print(get_area(ps))