Submission #1857311


Source Code Expand

import numpy as np
import math
import sys
v = []
try:
    for s in range(6):
        vv = [float(a) for a in raw_input().split()]
        v.append(vv + [0])
    verts = np.array(v)
except:
    print -1
    sys.exit(0)
v1 = verts[1] - verts[0]
v2 = verts[2] - verts[1]
v3 = verts[3] - verts[2]
v4 = verts[4] - verts[3]
v5 = verts[5] - verts[4]
v6 = verts[0] - verts[5]

def is_parallel(a, b):
    if a[0] == 0 and a[1] == 0:
        return False
    if b[0] == 0 and b[1] == 0:
        return False
    if a[0] != 0:
        if b[0] != 0:
            return a[1] / a[0] == b[1] / b[0]
        else:
            return False
    else:
        if b[0] != 0:
            return False
        else:
            return True
if not is_parallel(v1, v4):
    print -1
    sys.exit(0)
if not is_parallel(v2, v5):
    print -1
    sys.exit(0)
if not is_parallel(v3, v6):
    print -1
    sys.exit(0)

n1 = np.array([v1[1], -v1[0], 0])
n2 = np.array([v2[1], -v2[0], 0])
n3 = np.array([v3[1], -v3[0], 0])
r12 = n1.dot(n2)
r23 = n2.dot(n3)
r13 = n1.dot(n3)
if r12 == 0 or r23 == 0 or r13 == 0:
    print -1
    sys.exit(0)
if -r12 * r13 / r23 < 0:
    print -1
    sys.exit(0)


n1[2] = math.sqrt(-r12 * r13 / r23)
n2[2] = math.sqrt(-r12 * r23 / r13)
n3[2] = math.sqrt(-r13 * r23 / r12)
n1 = n1 / np.linalg.norm(n1)
n2 = n2 / np.linalg.norm(n2)
n3 = n3 / np.linalg.norm(n3)
d1 =  np.abs(n1.dot(verts[0]) - n1.dot(verts[3]))
d2 =  np.abs(n2.dot(verts[1]) - n2.dot(verts[4]))
d3 =  np.abs(n3.dot(verts[2]) - n3.dot(verts[5]))
V1= d1 * d2 * d3

n1 = np.array([v1[1], -v1[0], 0])
n2 = np.array([v2[1], -v2[0], 0])
n3 = np.array([v3[1], -v3[0], 0])
r12 = n1.dot(n2)
r23 = n2.dot(n3)
r13 = n1.dot(n3)
n1[2] = -math.sqrt(-r12 * r13 / r23)
n2[2] = -math.sqrt(-r12 * r23 / r13)
n3[2] = -math.sqrt(-r13 * r23 / r12)
n1 = n1 / np.linalg.norm(n1)
n2 = n2 / np.linalg.norm(n2)
n3 = n3 / np.linalg.norm(n3)
d1 =  np.abs(n1.dot(verts[0]) - n1.dot(verts[3]))
d2 =  np.abs(n2.dot(verts[1]) - n2.dot(verts[4]))
d3 =  np.abs(n3.dot(verts[2]) - n3.dot(verts[5]))
V2= d1 * d2 * d3
print min(V1, V2)

Submission Info

Submission Time
Task E - Hexagon
User yocchiman
Language Python (2.7.6)
Score 100
Code Size 2150 Byte
Status AC
Exec Time 536 ms
Memory 12824 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 2
AC × 37
Set Name Test Cases
Sample s0.txt, s1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 040.txt, 041.txt, 042.txt, 043.txt, s0.txt, s1.txt
Case Name Status Exec Time Memory
000.txt AC 536 ms 12824 KB
001.txt AC 91 ms 10540 KB
002.txt AC 91 ms 10540 KB
003.txt AC 90 ms 10540 KB
004.txt AC 89 ms 10540 KB
005.txt AC 89 ms 10540 KB
006.txt AC 92 ms 10540 KB
007.txt AC 91 ms 10540 KB
008.txt AC 90 ms 10540 KB
009.txt AC 90 ms 10540 KB
010.txt AC 92 ms 10540 KB
011.txt AC 91 ms 10540 KB
012.txt AC 91 ms 10540 KB
013.txt AC 90 ms 10540 KB
014.txt AC 90 ms 10540 KB
015.txt AC 91 ms 10540 KB
016.txt AC 92 ms 10540 KB
017.txt AC 91 ms 10540 KB
018.txt AC 91 ms 10540 KB
019.txt AC 90 ms 10540 KB
020.txt AC 90 ms 10540 KB
021.txt AC 92 ms 10540 KB
022.txt AC 89 ms 10540 KB
023.txt AC 91 ms 10540 KB
024.txt AC 90 ms 10540 KB
025.txt AC 90 ms 10540 KB
026.txt AC 91 ms 10540 KB
027.txt AC 90 ms 10540 KB
028.txt AC 92 ms 10540 KB
029.txt AC 91 ms 10540 KB
030.txt AC 90 ms 10540 KB
040.txt AC 92 ms 10540 KB
041.txt AC 92 ms 10540 KB
042.txt AC 90 ms 10540 KB
043.txt AC 90 ms 10540 KB
s0.txt AC 91 ms 10540 KB
s1.txt AC 90 ms 10540 KB