s_id
stringlengths 10
10
| p_id
stringlengths 6
6
| u_id
stringlengths 10
10
| date
stringlengths 10
10
| language
stringclasses 1
value | original_language
stringclasses 11
values | filename_ext
stringclasses 1
value | status
stringclasses 1
value | cpu_time
int64 0
100
| memory
stringlengths 4
6
| code_size
int64 15
14.7k
| code
stringlengths 15
14.7k
| problem_id
stringlengths 6
6
| problem_description
stringlengths 358
9.83k
| input
stringlengths 2
4.87k
| output
stringclasses 807
values | __index_level_0__
int64 1.1k
1.22M
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s316939428
|
p00012
|
u995990363
|
1530852344
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5592
| 1,214
|
import sys
class P(object):
def __init__(self, x, y):
self.x = x
self.y = y
def __repr__(self):
return 'P:{0:.3f} {1:.3f}'.format(self.x, self.y)
class Line(object):
def __init__(self, p1, p2):
self.p1 = p1
self.p2 = p2
self.epsilon = 1e-8
def is_over(self, p):
if abs(self.p2.x - self.p1.x) < self.epsilon:
return self.p1.x > p.x
elif abs(self.p2.y - self.p1.y) < self.epsilon:
return self.p1.y > p.y
else:
a = (self.p2.y - self.p1.y) / (self.p2.x - self.p1.x)
b = self.p1.y
y = a * (p.x - self.p1.x) + b
return y > p.y
def run():
for i in sys.stdin:
x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, i.split()))
p1, p2, p3, p = P(x1, y1), P(x2, y2), P(x3, y3), P(xp, yp)
l_12 = Line(p1, p2)
l_23 = Line(p2, p3)
l_31 = Line(p3, p1)
res = l_12.is_over(p3) == l_12.is_over(p)
res &= l_23.is_over(p1) == l_23.is_over(p)
res &= l_31.is_over(p2) == l_31.is_over(p)
if res:
print('YES')
else:
print('NO')
if __name__ == '__main__':
run()
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,502
|
s780464984
|
p00012
|
u244742296
|
1409835655
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7000
| 1,354
|
# -*- coding: utf-8 -*-
import sys
import cmath
import math
class Point(object):
def __init__(self, x, y):
self.point = complex(x, y)
def __str__(self):
return "x = {0}, y = {1}".format(self.point.real, self.point.imag)
class Triangle(Point):
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
# 3辺の長さ
self.edgeA = abs(b.point-c.point)
self.edgeB = abs(c.point-a.point)
self.edgeC = abs(a.point-b.point)
# 3角の大きさ
self.angleA = Triangle.angle(self.edgeA, self.edgeB, self.edgeC)
self.angleB = Triangle.angle(self.edgeB, self.edgeC, self.edgeA)
self.angleC = Triangle.angle(self.edgeC, self.edgeA, self.edgeB)
# 角度を求める
def angle(A, B, C):
return cmath.acos( (B*B+C*C-A*A)/(2*B*C) ).real
eps = 0.0001
for line in sys.stdin:
line = [float(x) for x in line.split()]
p1 = Point(line[0], line[1])
p2 = Point(line[2], line[3])
p3 = Point(line[4], line[5])
P = Point(line[6], line[7])
t1 = Triangle(p1, p2, P)
t2 = Triangle(p2, p3, P)
t3 = Triangle(p3, p1, P)
if (math.degrees(t1.angleC + t2.angleC + t3.angleC) <= 360+eps) and (math.degrees(t1.angleC + t2.angleC + t3.angleC) >= 360-eps):
print("YES")
else:
print("NO")
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,503
|
s998084633
|
p00012
|
u579833671
|
1410771055
|
Python
|
Python
|
py
|
Accepted
| 20
|
4476
| 848
|
import math
def helon(x1, y1, x2, y2, x3, y3):
a = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
b = math.sqrt((x3 - x2)**2 + (y3 - y2)**2)
c = math.sqrt((x1 - x3)**2 + (y1 - y3)**2)
s = (a + b + c) / 2
return(math.sqrt(s * (s - a) * (s - b) * (s - c)))
while(True):
try:
input = map(float, raw_input().split())
S = []
S.append(helon(input[0], input[1], input[2], input[3], input[4], input[5]))
S.append(helon(input[0], input[1], input[2], input[3], input[6], input[7]))
S.append(helon(input[0], input[1], input[4], input[5], input[6], input[7]))
S.append(helon(input[2], input[3], input[4], input[5], input[6], input[7]))
if(math.fabs(S[0] - S[1] - S[2] - S[3]) < 1e-7):
print("YES")
else:
print("NO")
except Exception:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,504
|
s482319853
|
p00012
|
u912237403
|
1415708615
|
Python
|
Python
|
py
|
Accepted
| 20
|
4244
| 300
|
import sys
def side(p1, p2, p3): return (p3[1]-p1[1])*(p2[0]-p1[0])-(p2[1]-p1[1])*(p3[0]-p1[0])>0
for s in sys.stdin:
x = map(float, s.split())
p1 = x[0:2]
p2 = x[2:4]
p3 = x[4:6]
p0 = x[6:]
print ["NO","YES"][(side(p1, p2, p0)==side(p2, p3, p0) and side(p2, p3, p0)==side(p3, p1, p0))]
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,505
|
s588862989
|
p00012
|
u912237403
|
1415708888
|
Python
|
Python
|
py
|
Accepted
| 10
|
4244
| 279
|
import sys
def side(p1, p2, p3): return (p3[1]-p1[1])*(p2[0]-p1[0])-(p2[1]-p1[1])*(p3[0]-p1[0])>0
for s in sys.stdin:
x = map(float, s.split())
p1 = x[0:2]
p2 = x[2:4]
p3 = x[4:6]
p0 = x[6:]
print ["NO","YES"][(side(p1, p2, p0)==side(p2, p3, p0)==side(p3, p1, p0))]
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,506
|
s828433173
|
p00012
|
u506132575
|
1416116600
|
Python
|
Python
|
py
|
Accepted
| 10
|
4264
| 509
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
def dot_z(v1,v2):
if v1[0]*v2[1]-v1[1]*v2[0] > 0:
return 1
else:
return -1
def diff_p(p1,p2):
return [ p2[0]-p1[0], p2[1]-p1[1] ]
for s in sys.stdin:
d = map(float , s.split() )
a = [d[0],d[1]]
b = [d[2],d[3]]
c = [d[4],d[5]]
p = [d[6],d[7]]
e1 = dot_z(diff_p(a,b),diff_p(b,p))
e2 = dot_z(diff_p(b,c),diff_p(c,p))
e3 = dot_z(diff_p(c,a),diff_p(a,p))
if abs(e1+e2+e3) == 3 :
print "YES"
else:
print "NO"
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,507
|
s426844946
|
p00012
|
u633068244
|
1416815641
|
Python
|
Python
|
py
|
Accepted
| 20
|
4248
| 340
|
def S(x1,y1,x2,y2,x3,y3):
return abs(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2.0
while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split())
flag = S(x1,y1,x2,y2,xp,yp)+S(x1,y1,x3,y3,xp,yp)+S(x3,y3,x2,y2,xp,yp)-S(x1,y1,x2,y2,x3,y3) > 0.0000001
print "NO" if flag else "YES"
except:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,508
|
s768883549
|
p00012
|
u633068244
|
1416815845
|
Python
|
Python
|
py
|
Accepted
| 10
|
4240
| 307
|
while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split())
S = lambda x1,y1,x2,y2,x3=xp,y3=yp:abs(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2.0
print "NO" if S(x1,y1,x2,y2)+S(x1,y1,x3,y3)+S(x3,y3,x2,y2)-S(x1,y1,x2,y2,x3,y3) > 0.0000001 else "YES"
except:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,509
|
s076235194
|
p00012
|
u567380442
|
1423055030
|
Python
|
Python3
|
py
|
Accepted
| 40
|
6756
| 473
|
import sys
f = sys.stdin
def take2(iterable):
i = iter(iterable)
while True:
yield next(i), next(i)
def cross(a, b):
return a.real * b.imag - a.imag * b.real
def in_triangle(a, b, c, p):
v1 = cross(a - b, b - p)
v2 = cross(b - c, c - p)
v3 = cross(c - a, a - p)
return 0 < v1 * v2 and 0 < v2 * v3
for line in f:
a, b, c, p = [x + y *1j for x, y in take2(map(float, line.split()))]
print('YES' if in_triangle(a,b,c,p) else 'NO')
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,510
|
s853935513
|
p00012
|
u540744789
|
1426591895
|
Python
|
Python
|
py
|
Accepted
| 20
|
4256
| 395
|
def S(x1,y1,x2,y2,x3,y3):
return ((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1))/2.0
import sys
for dataset in sys.stdin:
x1,y1,x2,y2,x3,y3,xp,yp=map(float,dataset.split(" "))
ABP=S(x1,y1,x2,y2,xp,yp)
BCP=S(x2,y2,x3,y3,xp,yp)
CAP=S(x3,y3,x1,y1,xp,yp)
if ABP>0 and BCP>0 and CAP>0:
print 'YES'
elif ABP<0 and BCP<0 and CAP<0:
print 'YES'
else:
print 'NO'
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,511
|
s118730724
|
p00012
|
u162387221
|
1431319110
|
Python
|
Python
|
py
|
Accepted
| 20
|
4240
| 435
|
def CrossProduct(x1, y1, x2, y2, xp, yp):
x2 -= x1
xp -= x1
y2 -= y1
yp -= y1
vec = (x2*yp-xp*y2)
return True if vec > 0 else False
while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split())
except EOFError:
break
if CrossProduct(x1, y1, x2, y2, xp, yp) == CrossProduct(x2, y2, x3, y3, xp, yp) == CrossProduct(x3, y3, x1, y1, xp, yp):
print 'YES'
else:
print 'NO'
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,512
|
s481792042
|
p00012
|
u879226672
|
1431605893
|
Python
|
Python
|
py
|
Accepted
| 20
|
4244
| 468
|
# coding: utf-8
while True:
try:
x1 ,y1, x2, y2, x3, y3, xp, yp = map(float,raw_input().split())
# ?????????z????????????????¨?????????????
c1 = (x2-x1) * (yp-y2) - (y2-y1) * (xp-x2)
c2 = (x3-x2) * (yp-y3) - (y3-y2) * (xp-x3)
c3 = (x1-x3) * (yp-y1) - (y1-y3) * (xp-x1)
if all((c1>0,c2>0,c3>0)) or all((c1<0,c2<0,c3<0)):
print 'YES'
else:
print 'NO'
except EOFError:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,513
|
s920877240
|
p00012
|
u067299340
|
1432879119
|
Python
|
Python
|
py
|
Accepted
| 10
|
4244
| 257
|
import sys
for x0,y0,x1,y1,x2,y2,xp,yp in[map(float,l.split()) for l in sys.stdin]:
a=(x1-x0)*(y1-yp)-(y1-y0)*(x1-xp)
b=(x2-x1)*(y2-yp)-(y2-y1)*(x2-xp)
c=(x0-x2)*(y0-yp)-(y0-y2)*(x0-xp)
print "YES" if a<0 and b<0 and c<0 or a>0 and b>0 and c>0 else "NO"
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,514
|
s529335989
|
p00012
|
u067299340
|
1432879721
|
Python
|
Python
|
py
|
Accepted
| 20
|
4244
| 206
|
import sys
for a,b,c,d,e,f,g,h in[map(float,l.split()) for l in sys.stdin]:
A=(c-a)*(d-h)-(d-b)*(c-g)
B=(e-c)*(f-h)-(f-d)*(e-g)
C=(a-e)*(b-h)-(b-f)*(a-g)
print "YES"if A*B>0 and B*C>0 and C*A>0 else"NO"
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,515
|
s666917270
|
p00012
|
u067299340
|
1432879731
|
Python
|
Python
|
py
|
Accepted
| 10
|
4244
| 206
|
import sys
for a,b,c,d,e,f,g,h in[map(float,l.split()) for l in sys.stdin]:
A=(c-a)*(d-h)-(d-b)*(c-g)
B=(e-c)*(f-h)-(f-d)*(e-g)
C=(a-e)*(b-h)-(b-f)*(a-g)
print "YES"if A*B>0 and B*C>0 and C*A>0 else"NO"
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,516
|
s945368892
|
p00012
|
u067299340
|
1432880059
|
Python
|
Python
|
py
|
Accepted
| 10
|
4240
| 179
|
import sys
for a,b,c,d,e,f,g,h in[map(float,l.split()) for l in sys.stdin]:print["NO","YES"][((c-a)*(d-h)-(d-b)*(c-g)>0)==((e-c)*(f-h)-(f-d)*(e-g)>0)==((a-e)*(b-h)-(b-f)*(a-g)>0)]
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,517
|
s702162953
|
p00012
|
u379956761
|
1434729024
|
Python
|
Python3
|
py
|
Accepted
| 30
|
6816
| 591
|
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import sys
import math
for data in sys.stdin:
x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, data.split()))
abV = (x1 - x2, y1 - y2)
bpV = (x2 - xp, y2 - yp)
bcV = (x2 - x3, y2 - y3)
cpV = (x3 - xp, y3 - yp)
caV = (x3 - x1, y3 - y1)
apV = (x1 - xp, y1 - yp)
c1 = abV[0] * bpV[1] - abV[1] * bpV[0]
c2 = bcV[0] * cpV[1] - bcV[1] * cpV[0]
c3 = caV[0] * apV[1] - caV[1] * apV[0]
if (c1 < 0 and c2 < 0 and c3 < 0) or (c1 > 0 and c2 > 0 and c3 > 0):
print("YES")
else:
print("NO")
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,518
|
s182523455
|
p00012
|
u140201022
|
1443020279
|
Python
|
Python
|
py
|
Accepted
| 10
|
6356
| 249
|
while 1:
try:
x1,y1,x2,y2,x3,y3,xp,yp=map(float,raw_input().split())
print 'YES' if ((x2-x1)*(y2-yp)-(y2-y1)*(x2-xp)>0)==((x3-x2)*(y3-yp)-(y3-y2)*(x3-xp)>0)==((x1-x3)*(y1-yp)-(y1-y3)*(x1-xp)>0) else 'NO'
except:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,519
|
s272022408
|
p00012
|
u071010747
|
1445230312
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7384
| 514
|
# -*- coding:utf-8 -*-
def main():
while True:
try:
ax,ay,bx,by,cx,cy,px,py=map(float,input().split())
A=(bx-ax)*(py-ay)-(by-ay)*(px-ax)
B=(cx-bx)*(py-by)-(cy-by)*(px-bx)
C=(ax-cx)*(py-cy)-(ay-cy)*(px-cx)
if ((A<=0)and(B<=0)and(C<=0))or((A>0)and(B>0)and(C>0)):
print("YES")
else:
print("NO")
except:
break
if __name__ == '__main__':
main()
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,520
|
s381603833
|
p00012
|
u489809100
|
1446481651
|
Python
|
Python
|
py
|
Accepted
| 0
|
6300
| 498
|
while True:
try:
point = map(float,raw_input().split())
z1 = (point[4] - point[2]) * (point[7] - point[3]) - (point[5] - point[3]) * (point[6] - point[2])
z2 = (point[0] - point[4]) * (point[7] - point[5]) - (point[1] - point[5]) * (point[6] - point[4])
z3 = (point[2] - point[0]) * (point[7] - point[1]) - (point[3] - point[1]) * (point[6] - point[0])
if z1 > 0 and z2 > 0 and z3 > 0 or z1 < 0 and z2 < 0 and z3 < 0:
print "YES"
else:
print "NO"
except EOFError:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,521
|
s749966678
|
p00012
|
u777299405
|
1447733827
|
Python
|
Python3
|
py
|
Accepted
| 40
|
7340
| 423
|
while True:
try:
ax, ay, bx, by, cx, cy, px, py = map(float, input().split())
a = (bx - ax) * (py - ay) - (by - ay) * (px - ax)
b = (cx - bx) * (py - by) - (cy - by) * (px - bx)
c = (ax - cx) * (py - cy) - (ay - cy) * (px - cx)
if (a < 0 and b < 0 and c < 0) or (a > 0 and b > 0 and c > 0):
print("YES")
else:
print("NO")
except:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,522
|
s601258296
|
p00012
|
u529386725
|
1454764748
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7416
| 504
|
def cross(x, y):
return (x.conjugate() * y).imag
def inside_triangle(p, x, y, z):
a = cross(y-x, p-y)
b = cross(z-y, p-z)
c = cross(x-z, p-x)
if a*b > 0 and b*c > 0:
return True
return False
import sys
for line in sys.stdin:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
x = complex(x1, y1)
y = complex(x2, y2)
z = complex(x3, y3)
p = complex(xp, yp)
if inside_triangle(p, x, y, z):
print('YES')
else:
print('NO')
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,523
|
s764194900
|
p00012
|
u512342660
|
1455277604
|
Python
|
Python
|
py
|
Accepted
| 10
|
6464
| 863
|
#! -*- coding:utf-8 -*-
#????????????P????????????3???A,B,C????????£???????????????????§???¢???
#?????´?????????????????´???????????????????????????????????°?????????
#????????????????????????????????¨?????????
#?????????????????§?¨???????
import sys
for line in sys.stdin:
#1:A,2:B,3:C
ax,ay,bx,by,cx,cy,px,py = map(float,line.split())
# AB
abx = bx-ax
aby = by-ay
#BP
bpx = px-bx
bpy = py-by
#BC
bcx = cx-bx
bcy = cy-by
#CP
cpx = px-cx
cpy = py-cy
#CA
cax = ax-cx
cay = ay-cy
#AP
apx = px-ax
apy = py-ay
#outer product
c1 = abx * bpy - aby * bpx
c2 = bcx * cpy - bcy * cpx
c3 = cax * apy - cay * apx
# print c1
# print c2
# print c3
if (c1>0 and c2>0 and c3>0) or (c1<0 and c2<0 and c3<0):
print "YES"
else:
print "NO"
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,524
|
s094875621
|
p00012
|
u650459696
|
1458397103
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7496
| 419
|
import sys
def tri(x1,x2,y1,y2,z1,z2,p1,p2):
a = (x1 - y1) * (y2 - p2) - (y1 - p1) * (x2 - y2)
b = (y1 - z1) * (z2 - p2) - (z1 - p1) * (y2 - z2)
c = (z1 - x1) * (x2 - p2) - (x1 - p1) * (z2 - x2)
if(((a < 0) & (b < 0) & (c < 0)) | ((a > 0) & (b > 0) & (c > 0))):
return 'YES'
return 'NO'
ans = []
for i in sys.stdin:
ans.append(tri(*map(float,i.split())))
print('\n'.join(map(str,ans)))
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,525
|
s605766060
|
p00012
|
u148101999
|
1459238702
|
Python
|
Python
|
py
|
Accepted
| 10
|
6340
| 395
|
def S(x1,y1,x2,y2,x3,y3):
return ((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1))/2.0
import sys
for dataset in sys.stdin:
x1,y1,x2,y2,x3,y3,xp,yp=map(float,dataset.split(" "))
ABP=S(x1,y1,x2,y2,xp,yp)
BCP=S(x2,y2,x3,y3,xp,yp)
CAP=S(x3,y3,x1,y1,xp,yp)
if ABP>0 and BCP>0 and CAP>0:
print 'YES'
elif ABP<0 and BCP<0 and CAP<0:
print 'YES'
else:
print 'NO'
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,526
|
s083674776
|
p00012
|
u915343634
|
1459591740
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7440
| 421
|
def r(x1, y1, x2, y2, x3, y3):
return x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2) > 0
while True:
try:
line = input()
except:
break
x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.strip().split())
abc = r(x1, y1, x2, y2, x3, y3)
pab = r(xp, yp, x1, y1, x2, y2)
pbc = r(xp, yp, x2, y2, x3, y3)
pca = r(xp, yp, x3, y3, x1, y1)
print('YES' if abc == pab == pbc == pca else 'NO')
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,527
|
s625963679
|
p00012
|
u130979865
|
1459909324
|
Python
|
Python
|
py
|
Accepted
| 10
|
6380
| 832
|
# -*- coding: utf-8 -*-
import sys
import math
class Point_Class():
def __init__(self, x, y):
self.x = x
self.y = y
def isIn(p1, p2, p3, pp):
a = p2.y-p1.y
b = p2.x-p1.x
c = p2.x*p1.y-p1.x*p2.y
d = p3.y-p2.y
e = p3.x-p2.x
f = p3.x*p2.y-p2.x*p3.y
g = p1.y-p3.y
h = p1.x-p3.x
i = p1.x*p3.y-p3.x*p1.y
if (a*pp.x-b*pp.y+c)*(a*p3.x-b*p3.y+c) < 0:
return False
if (d*pp.x-e*pp.y+f)*(d*p1.x-e*p1.y+f) < 0:
return False
if (g*pp.x-h*pp.y+i)*(g*p2.x-h*p2.y+i) < 0:
return False
return True
for line in sys.stdin:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
p1 = Point_Class(x1, y1)
p2 = Point_Class(x2, y2)
p3 = Point_Class(x3, y3)
pp = Point_Class(xp, yp)
print "YES" if isIn(p1, p2, p3, pp) else "NO"
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,528
|
s032965930
|
p00012
|
u572790226
|
1460287674
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7544
| 544
|
import sys
def crossMulti(p1, p2):
return p1[0] * p2[1] - p1[1] * p2[0]
lines = sys.stdin.readlines()
for line in lines:
Zd = []
x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
Ps = [(x2-x1, y2-y1),(x3-x2, y3-y2),(x1-x3, y1-y3)]
Px = [(xp-x1, yp-y1),(xp-x2, yp-y2),(xp-x3, yp-y3)]
for p in range(3):
Zd.append(crossMulti(Ps[p], Px[p]))
Zd = [x > 0 for x in Zd]
if (Zd[0] and Zd[1] and Zd[2]) or not(Zd[0] or Zd[1] or Zd[2]):
print('YES')
else:
print('NO')
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,529
|
s020511566
|
p00012
|
u766477342
|
1466207191
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7724
| 933
|
import math
class Triangle:
def __init__(self, x1, y1, x2, y2, x3, y3):
self.x1 = x1
self.x2 = x2
self.x3 = x3
self.y1 = y1
self.y2 = y2
self.y3 = y3
self.a = math.sqrt((x1-x2) ** 2 + (y1 - y2) ** 2)
self.b = math.sqrt((x2-x3) ** 2 + (y2 - y3) ** 2)
self.c = math.sqrt((x1-x3) ** 2 + (y1 - y3) ** 2)
def get_acos_a(self):
val = (-self.a ** 2 + self.b ** 2 + self.c ** 2) / (2 * self.b * self.c)
return math.acos(val)
while(1):
try:
x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, input().split()))
t1 = Triangle(x1, y1, x2, y2, xp, yp)
t2 = Triangle(x2, y2, x3, y3, xp, yp)
t3 = Triangle(x3, y3, x1, y1, xp, yp)
if 6.28318530 <= t1.get_acos_a() + t2.get_acos_a() + t3.get_acos_a() <= 6.28318531:
print("YES")
else:
print("NO")
except:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,530
|
s113902479
|
p00012
|
u766477342
|
1466207581
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7812
| 991
|
import math
class Triangle:
def __init__(self, x1, y1, x2, y2, x3, y3):
self.x1 = x1
self.x2 = x2
self.x3 = x3
self.y1 = y1
self.y2 = y2
self.y3 = y3
self.a = math.sqrt((x1-x2) ** 2 + (y1 - y2) ** 2)
self.b = math.sqrt((x2-x3) ** 2 + (y2 - y3) ** 2)
self.c = math.sqrt((x1-x3) ** 2 + (y1 - y3) ** 2)
def get_acos_a(self):
val = (-self.a ** 2 + self.b ** 2 + self.c ** 2) / (2 * self.b * self.c)
return math.acos(val)
while(1):
try:
x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, input().split()))
t1 = Triangle(x1, y1, x2, y2, xp, yp)
t2 = Triangle(x2, y2, x3, y3, xp, yp)
t3 = Triangle(x3, y3, x1, y1, xp, yp)
def is_2pi(x):
return math.fabs(x - math.pi*2) < 1.0e-10
if is_2pi(t1.get_acos_a() + t2.get_acos_a() + t3.get_acos_a()):
print("YES")
else:
print("NO")
except:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,531
|
s886649777
|
p00012
|
u617990214
|
1468244893
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7456
| 507
|
out=[]
while True:
try:
k=list(map(float,input().split(" ")))
except:
break
O_x,O_y=k[0],k[1]
A_x,A_y=k[2],k[3]
B_x,B_y=k[4],k[5]
P_x,P_y=k[6],k[7]
# P in triangle OAB
# iff s+t<1 and s>0 and t>0 (OP=sOA+tOB)
OA=(A_x-O_x,A_y-O_y)
OB=(B_x-O_x,B_y-O_y)
OP=(P_x-O_x,P_y-O_y)
keisuu=1/( OA[0]*OB[1] - OA[1]*OB[0] )
s=keisuu*( OB[1]*OP[0]-OB[0]*OP[1] )
t=keisuu*( -OA[1]*OP[0]+OA[0]*OP[1] )
if s>0 and t>0 and s+t<1:
out.append("YES")
else:
out.append("NO")
for i in out:
print(i)
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,532
|
s011842495
|
p00012
|
u582608581
|
1470810409
|
Python
|
Python3
|
py
|
Accepted
| 40
|
7408
| 397
|
def Cramer(a11, a12, a13, a21, a22, a23):
den = a11 * a22 - a12 * a21
return (a13 * a22 - a12 * a23) / den, (a11 * a23 - a13 * a21) / den
while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = [eval(item) for item in input().split()]
u, v = Cramer(x3 - x1, x2 - x1, xp - x1, y3 - y1, y2 - y1, yp - y1)
print('YES' if u >= 0.0 and v >= 0.0 and u + v <= 1.0 else 'NO')
except EOFError:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,533
|
s420736150
|
p00012
|
u358919705
|
1471861408
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7524
| 504
|
import math
while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
except:
break
x = [x1, x2, x3, x1]
y = [y1, y2, y3, y1]
x = list(map(lambda i: i - xp, x))
y = list(map(lambda i: i - yp, y))
s = lambda a1, a2, b1, b2: abs(a1 * b2 - a2 * b1)
S3 = sum(s(x[i], y[i], x[i + 1], y[i + 1]) for i in range(3))
S = s(x[1] - x[0], y[1] - y[0], x[2] - x[0], y[2] - y[0])
if S3 == S:
print('YES')
else:
print('NO')
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,534
|
s786290216
|
p00012
|
u379499530
|
1472783104
|
Python
|
Python
|
py
|
Accepted
| 10
|
6380
| 748
|
class point:
def __init__(self, x, y):
self.x = x
self.y = y
def sub(self, p):
return point(self.x - p.x, self.y - p.y)
while 1:
try:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split())
A = point(x1, y1)
B = point(x2, y2)
C = point(x3, y3)
P = point(xp, yp)
AB = B.sub(A)
BP = P.sub(B)
BC = C.sub(B)
CP = P.sub(C)
CA = A.sub(C)
AP = P.sub(A)
c1 = AB.x * BP.y - AB.y * BP.x
c2 = BC.x * CP.y - BC.y * CP.x
c3 = CA.x * AP.y - CA.y * AP.x
if((c1 > 0) and (c2 > 0) and (c3 > 0) or (c1 < 0) and (c2 < 0) and (c3 < 0)): print "YES"
else: print "NO"
except:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,535
|
s841001928
|
p00012
|
u659302741
|
1477742238
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7424
| 842
|
import sys
def is_counter_clockwise(x1, y1, x2, y2, x3, y3):
px = x2 - x1
py = y2 - y1
qx = x3 - x1
qy = y3 - y1
return px * qy - py * qx > 0
def is_in_triangle(x1, y1, x2, y2, x3, y3, xp, yp):
if is_counter_clockwise(x1, y1, x2, y2, x3, y3):
return is_counter_clockwise(x1, y1, x2, y2, xp, yp) and \
is_counter_clockwise(x2, y2, x3, y3, xp, yp) and \
is_counter_clockwise(x3, y3, x1, y1, xp, yp)
else:
return is_counter_clockwise(x1, y1, x3, y3, xp, yp) and \
is_counter_clockwise(x3, y3, x2, y2, xp, yp) and \
is_counter_clockwise(x2, y2, x1, y1, xp, yp)
for line in sys.stdin:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
if is_in_triangle(x1, y1, x2, y2, x3, y3, xp, yp):
print("YES")
else:
print("NO")
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,536
|
s237605038
|
p00012
|
u922871577
|
1479281359
|
Python
|
Python
|
py
|
Accepted
| 10
|
6408
| 467
|
import sys
for line in sys.stdin:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
AB = [x2-x1, y2-y1]
BP = [xp-x2, yp-y2]
BC = [x3-x2, y3-y2]
CP = [xp-x3, yp-y3]
CA = [x1-x3, y1-y3]
AP = [xp-x1, yp-y1]
c1 = AB[0] * BP[1] - AB[1] * BP[0]
c2 = BC[0] * CP[1] - BC[1] * CP[0]
c3 = CA[0] * AP[1] - CA[1] * AP[0]
if (c1>0 and c2>0 and c3>0) or (c1<0 and c2<0 and c3<0):
print 'YES'
else:
print 'NO'
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,537
|
s910359525
|
p00012
|
u301729341
|
1481013177
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7488
| 543
|
def gai(a,b,c,d):
S = a*d - b*c
return(S)
while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp = map(float,input().split())
if gai(x1 - x2,y1 - y2,x1 - xp,y1 - yp) < 0 and gai(x2 - x3,y2 - y3,x2 - xp,y2 - yp) < 0 and gai(x3 - x1,y3 - y1,x3 - xp,y3 - yp) < 0:
print("YES")
elif gai(x1 - x2,y1 - y2,x1 - xp,y1 - yp) > 0 and gai(x2 - x3,y2 - y3,x2 - xp,y2 - yp) > 0 and gai(x3 - x1,y3 - y1,x3 - xp,y3 - yp) > 0:
print("YES")
else:
print("NO")
except EOFError:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,538
|
s003777334
|
p00012
|
u123687446
|
1481109539
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7376
| 345
|
while True:
try:
p = list(map(float,input().split()))
except EOFError:
break
a = p[2] - p[0]
b = p[4] - p[0]
c = p[6] - p[0]
d = p[3] - p[1]
e = p[5] - p[1]
f = p[7] - p[1]
s = (c*e-b*f)/(a*e-b*d)
t = (a*f-c*d)/(a*e-b*d)
print("YES" if s>0 and s<1 and t>0 and t<1 and s+t<1 else "NO")
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,539
|
s710258224
|
p00012
|
u919202930
|
1481509365
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7440
| 561
|
def getTriangleArea(x1, y1, x2, y2, x3, y3): # returns the area of triangle determined by provided 3 points
ux = x2-x1
uy = y2-y1
vx = x3-x1
vy = y3-y1
return abs(ux*vy-vx*uy)/2
inputs=[]
while True:
try:
inputs.append(list(map(float,input().split())))
except EOFError:
break
for i in inputs:
x1, y1, x2, y2, x3, y3, xp, yp = i
if getTriangleArea(x1, y1, x2, y2, x3, y3)==getTriangleArea(x1, y1, x2, y2, xp, yp)+getTriangleArea(x2, y2, x3, y3, xp, yp)+getTriangleArea(x3, y3, x1, y1, xp, yp):
print("YES")
else:
print("NO")
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,540
|
s732955672
|
p00012
|
u957840591
|
1482720981
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7744
| 2,477
|
class vector(object):
def __init__(self,a,b):
self.x=b.x-a.x
self.y=b.y-a.y
@staticmethod
def cross_product(a,b):
return a.x*b.y-a.y*b.x
class vertex(object):
def __init__(self,a):
self.x=a[0]
self.y=a[1]
class circle(object):
def __init__(self,p,r):
self.px=p.x
self.py=p.y
self.r=r
class triangle(object):
def __init__(self,a,b,c):
self.a=a
self.b=b
self.c=c
import math
self.ab=math.sqrt((self.a.x-self.b.x)**2+(self.a.y-self.b.y)**2)
self.bc=math.sqrt((self.b.x-self.c.x)**2+(self.b.y-self.c.y)**2)
self.ca=math.sqrt((self.c.x-self.a.x)**2+(self.c.y-self.a.y)**2)
c=self.ab
a=self.bc
b=self.ca
self.cosA=(b**2+c**2-a**2)/(2*b*c)
self.cosB=(a**2+c**2-b**2)/(2*a*c)
self.cosC=(b**2+a**2-c**2)/(2*b*a)
self.sinA=math.sqrt(1-self.cosA**2)
self.sinB=math.sqrt(1-self.cosB**2)
self.sinC=math.sqrt(1-self.cosC**2)
self.sin2A=2*self.sinA*self.cosA
self.sin2B=2*self.sinB*self.cosB
self.sin2C=2*self.sinC*self.cosC
def area(self):
import math
s=(self.ab+self.bc+self.ca)/2
S=math.sqrt(s*(s-self.ab)*(s-self.bc)*(s-self.ca))
return S
def circumscribed(self):
R=self.ab/(2*self.sinC)
px=(self.sin2A*self.a.x+self.sin2B*self.b.x+self.sin2C*self.c.x)/(self.sin2A+self.sin2B+self.sin2C)
py=(self.sin2A*self.a.y+self.sin2B*self.b.y+self.sin2C*self.c.y)/(self.sin2A+self.sin2B+self.sin2C)
px=round(px,3)
py=round(py,3)
R=round(R,3)
p=vertex((px,py))
return circle(p,R)
def isin(self,p):
AB=vector(self.a,self.b)
BC=vector(self.b,self.c)
CA=vector(self.c,self.a)
AP=vector(self.a,p)
BP=vector(self.b,p)
CP=vector(self.c,p)
if (vector.cross_product(AB,AP)>0 and vector.cross_product(BC,BP)>0 and vector.cross_product(CA,CP)>0)or(vector.cross_product(AB,AP)<0 and vector.cross_product(BC,BP)<0 and vector.cross_product(CA,CP)<0):
return 'YES'
else:return 'NO'
A=[]
B=[]
C=[]
p=[]
import sys
for line in sys.stdin:
a,b,c,d,e,f,g,h=list(map(float,line.split()))
A.append(vertex((a,b)))
B.append(vertex((c,d)))
C.append(vertex((e,f)))
p.append(vertex((g,h)))
for i in range(len(A)):
Triangle=triangle(A[i],B[i],C[i])
print(Triangle.isin(p[i]))
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,541
|
s220131393
|
p00012
|
u711765449
|
1483968920
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7376
| 423
|
while True:
try:
ax, ay, bx, by, cx, cy, px, py = map(float, input().split())
a = (bx - ax) * (py - ay) - (by - ay) * (px - ax)
b = (cx - bx) * (py - by) - (cy - by) * (px - bx)
c = (ax - cx) * (py - cy) - (ay - cy) * (px - cx)
if (a < 0 and b < 0 and c < 0) or (a > 0 and b > 0 and c > 0):
print("YES")
else:
print("NO")
except:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,542
|
s382661667
|
p00012
|
u078042885
|
1485812880
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7416
| 316
|
def f(a,b,c,d,e,f,g,h):return ((a-c)*(f-b)+(b-d)*(a-e))*((a-c)*(h-b)+(b-d)*(a-g))
while 1:
try:x1,y1,x2,y2,x3,y3,xp,yp=map(float,input().split())
except:break
x=(x1+x2+x3)/3
y=(y1+y2+y3)/3
print(['YES','NO'][f(x1,y1,x2,y2,xp,yp,x,y)<0 or f(x1,y1,x3,y3,xp,yp,x,y)<0 or f(x2,y2,x3,y3,xp,yp,x,y)<0])
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,543
|
s480418066
|
p00012
|
u252414452
|
1486039977
|
Python
|
Python
|
py
|
Accepted
| 10
|
6456
| 381
|
import sys
def to_f(e):
return float(e)
while True:
line = sys.stdin.readline()
if not line: break
x1, y1, x2, y2, x3, y3, xp, yp = map(to_f, line.split(" "))
a = (x2-x1)*(y3-y1)-(x3-x1)*(y2-y1)
b = (xp-x1)*(y3-y1)-(x3-x1)*(yp-y1)
c = (x2-x1)*(yp-y1)-(xp-x1)*(y2-y1)
s = b/a
t = c/a
if s>0 and t>0 and 0<s+t and s+t<1:
print("YES")
else:
print("NO")
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,544
|
s222475124
|
p00012
|
u032662562
|
1486278491
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7704
| 666
|
import math
from sys import stdin
def length(u,v):
x0=u[0]
y0=u[1]
x1=v[0]
y1=v[1]
return(math.sqrt(((x1-x0)**2+(y1-y0)**2)))
def s(a,b,c):
l=length(a,b)
m=length(b,c)
n=length(c,a)
o = (l+m+n)/2.0
p=o*(o-l)*(o-m)*(o-n)
q=math.sqrt(p)
return(q)
if __name__ == "__main__":
eps=1e-5
for line in stdin:
v=list(map(float,line.split()))
a=(v[0],v[1])
b=(v[2],v[3])
c=(v[4],v[5])
p=(v[6],v[7])
s0=s(a,b,c)
s1=s(p,a,b)
s2=s(p,b,c)
s3=s(p,c,a)
if abs(s0 - (s1+s2+s3))< eps:
print("YES")
else:
print("NO")
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,545
|
s395523189
|
p00012
|
u901080241
|
1488958305
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7396
| 554
|
import sys
def sameside(x1, y1, x2, y2, ax, ay, bx, by):
if x1 != x2:
aupper = (ay > (y1-y2)/(x1-x2) * (ax-x1) + y1)
bupper = (by > (y1-y2)/(x1-x2) * (bx-x1) + y1)
else:
aupper = ax < x1
bupper = bx < x1
return aupper == bupper
for line in sys.stdin:
x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, line.split()))
if sameside(x1, y1, x2, y2, x3, y3, xp, yp) and sameside(x2, y2, x3, y3, x1, y1, xp, yp) and sameside(x3, y3, x1, y1, x2, y2, xp, yp):
print("YES")
else:
print("NO")
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,546
|
s745883357
|
p00012
|
u797673668
|
1490622513
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7396
| 408
|
def check(x1, y1, x2, y2, xp, yp):
return ((y1 > yp) != (y2 > yp)) and (xp - x1 < (x2 - x1) * (yp - y1) / (y2 - y1))
while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
except:
break
print('YES' if (check(x1, y1, x2, y2, xp, yp) +
check(x2, y2, x3, y3, xp, yp) +
check(x3, y3, x1, y1, xp, yp)) & 1 else 'NO')
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,547
|
s903089408
|
p00012
|
u462831976
|
1492707333
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7516
| 670
|
# -*- coding: utf-8 -*-
import sys
import os
import math
def cross(a, b):
ax = a[0]
ay = a[1]
bx = b[0]
by = b[1]
return ax * by - ay * bx
for s in sys.stdin:
s = s.strip()
ax, ay, bx, by, cx, cy, px, py = map(float, s.split())
# point A, B, C, P
AP = (px - ax, py - ay)
BP = (px - bx, py - by)
CP = (px - cx, py - cy)
BA = (ax - bx, ay - by)
AC = (cx - ax, cy - ay)
CB = (bx - cx, by - cy)
v0 = cross(BP, BA)
v1 = cross(CP, CB)
v2 = cross(AP, AC)
if v0 > 0 and v1 > 0 and v2 > 0:
print('YES')
elif v0 < 0 and v1 < 0 and v2 < 0:
print('YES')
else:
print('NO')
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,548
|
s610403554
|
p00012
|
u546285759
|
1492757978
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7620
| 473
|
import math
def tri(x1, y1, x2, y2, x3, y3):
return math.fabs((x2-x1)*(y3-y1) - (y2-y1)*(x3-x1)) / 2
while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
except:
break
abc = tri(x1, y1, x2, y2, x3, y3)
abp = tri(x1, y1, x2, y2, xp, yp)
acp = tri(x1, y1, x3, y3, xp, yp)
bcp = tri(x2, y2, x3, y3, xp, yp)
x, y = int(abc*pow(10, 5)), int((abp+acp+bcp)*pow(10, 5))
print("YES" if x >= y else "NO")
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,549
|
s355068457
|
p00012
|
u618637847
|
1494897726
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7400
| 408
|
while 1:
try:
x1, y1, x2, y2, x3, y3, px, py = map(float, input().split())
a = (x2-x1) * (py-y1) - (y2-y1) * (px-x1)
b = (x3-x2) * (py-y2) - (y3-y2) * (px-x2)
c = (x1-x3) * (py-y3) - (y1-y3) * (px-x3)
if (a < 0 and b < 0 and c < 0) or (a > 0 and b > 0 and c > 0):
print("YES")
else:
print("NO")
except:
break;
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,550
|
s584660784
|
p00012
|
u905313459
|
1496317108
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7536
| 486
|
import math
def tri(x1, y1, x2, y2, x3, y3):
return math.fabs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2
while True:
try:
x1, y1, x2, y2, x3, y3, x, y = map(float, input().split())
except:
break
abc = tri(x1, y1, x2, y2, x3, y3)
abp = tri(x1, y1, x2, y2, x, y)
acp = tri(x1, y1, x3, y3, x, y)
bcp = tri(x2, y2, x3, y3, x, y)
x, y = int(abc * pow(10, 5)), int((abp + acp + bcp) * pow(10, 5))
print("YES" if x >= y else "NO")
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,551
|
s018916528
|
p00012
|
u371539389
|
1498110062
|
Python
|
Python3
|
py
|
Accepted
| 60
|
10064
| 574
|
from decimal import Decimal as D
import sys
def S(P,Q,R):
# R
#
#P
# Q
PQ=[Q[0]-P[0],Q[1]-P[1]]
PR=[R[0]-P[0],R[1]-P[1]]
s=PQ[0]*PR[1]-PQ[1]*PR[0]
return s
while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp=[D(i) for i in input().split(" ")]
A=[x1,y1]
B=[x2,y2]
C=[x3,y3]
P=[xp,yp]
if (S(A,B,P)>0 and S(B,C,P)>0 and S(C,A,P)>0) or (S(A,B,P)<0 and S(B,C,P)<0 and S(C,A,P)<0):
print("YES")
else:
print("NO")
except EOFError:
sys.exit()
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,552
|
s273927679
|
p00012
|
u354053070
|
1501927514
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7424
| 558
|
import sys
def isleft(ox, oy, ax, ay, px, py):
oax, oay = ax - ox, ay - oy
opx, opy = px - ox, py - oy
if oax * opy > oay * opx:
return 1
else:
return 0
for line in sys.stdin:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
# A, B, C, P = (x1, y1), (x2, y2), (x3, y3), (xp, yp)
# if isleft(*A, *B, *P) == isleft(*B, *C, *P) == isleft(*C, *A, *P):
if isleft(x1, y1, x2, y2, xp, yp) == isleft(x2, y2, x3, y3, xp, yp) == isleft(x3, y3, x1, y1, xp, yp):
print("YES")
else:
print("NO")
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,553
|
s353144649
|
p00012
|
u187606290
|
1502047883
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7416
| 730
|
import fileinput
class Vector2D:
def __init__(self, x, y):
self.x = x
self.y = y
def dot(self, vec2d):
return (self.x * vec2d.y) - (self.y * vec2d.x)
for line in fileinput.input():
x1, y1, x2, y2, x3, y3, xp, yp = [float(r) for r in line.split()]
v1To2 = Vector2D(x2 - x1, y2 - y1)
v2To3 = Vector2D(x3 - x2, y3 - y2)
v3To1 = Vector2D(x1 - x3, y1 - y3)
v1ToP = Vector2D(xp - x1, yp - y1)
v2ToP = Vector2D(xp - x2, yp - y2)
v3ToP = Vector2D(xp - x3, yp - y3)
if (v1To2.dot(v1ToP) < 0 and v2To3.dot(v2ToP) < 0 and v3To1.dot(v3ToP) < 0) or (v1To2.dot(v1ToP) > 0 and v2To3.dot(v2ToP) > 0 and v3To1.dot(v3ToP) > 0):
print("YES")
else:
print("NO")
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,554
|
s217698437
|
p00012
|
u957021183
|
1504763903
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7520
| 657
|
# Aizu Problem 0012: Point in Triangle
#
import sys, math, os
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
def point_in_triangle(trig, x, y):
x1, y1, x2, y2, x3, y3 = trig[:]
a = ((y2 - y3)*(x - x3) + (x3 - x2)*(y - y3)) / ((y2 - y3)*(x1 - x3) + (x3 - x2)*(y1 - y3))
b = ((y3 - y1)*(x - x3) + (x1 - x3)*(y - y3)) / ((y2 - y3)*(x1 - x3) + (x3 - x2)*(y1 - y3))
c = 1 - a - b
return 0 < a < 1 and 0 < b < 1 and 0 < c < 1
for line in sys.stdin:
inp = [float(_) for _ in line.split()]
print("YES" if point_in_triangle(inp[:6], inp[6], inp[7]) else "NO")
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,555
|
s056290696
|
p00012
|
u811733736
|
1505371925
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7744
| 6,982
|
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0012&lang=jp
"""
import sys
from sys import stdin
input = stdin.readline
class Point(object):
epsilon = 1e-10
def __init__(self, x=0.0, y=0.0):
if isinstance(x, tuple):
self.x = x[0]
self.y = x[1]
else:
self.x = x
self.y = y
# ????????????
def __add__(self, other):
return Point(self.x + other.x, self.y + other.y)
def __sub__(self, other):
return Point(self.x - other.x, self.y - other.y)
def __mul__(self, other):
return Point(other * self.x, other * self.y)
def __truediv__(self, other):
return Point(self.x / other, self.y / other)
def __lt__(self, other):
if self.x == other.x:
return self.y < other.y
else:
return self.x < other.x
def __eq__(self, other):
from math import fabs
if fabs(self.x - other.x) < Point.epsilon and fabs(self.y - other.y) < Point.epsilon:
return True
else:
return False
def norm(self):
return self.x * self.x + self.y * self.y
def __abs__(self):
return sqrt(self.norm())
def ccw(self, p0, p1):
# ??????2???(p0, p1)?????????????????????????????????????????¢????????????
a = Vector(p1 - p0)
b = Vector(self - p0)
if Vector.cross(a, b) > Point.epsilon:
return 1 # 'COUNTER_CLOCKWISE'
elif Vector.cross(a, b) < -Point.epsilon:
return -1 # 'CLOCKWISE'
elif Vector.dot(a, b) < -Point.epsilon:
return 2 # 'ONLINE_BACK'
elif a.norm() < b.norm():
return -2 # 'ONLINE_FRONT'
else:
return 0 # 'ON_SEGMENT'
def project(self, s):
# ??????(Point)????????????s??????????????????????????????????????§?¨?(?°???±)????±???????
base = Vector(s.p2 - s.p1)
a = Vector(self - s.p1)
r = Vector.dot(a, base)
r /= base.norm()
return s.p1 + base * r
def reflect(self, s):
# ??????s???????§°?????¨?????????????????¨???????§°??????????????§?¨?(????°?)????±???????
proj = self.project(s)
return self + (proj - self)*2
def distance(self, s):
# ????????¨??????s????????¢????¨??????????
if Vector.dot(s.p2-s.p1, self-s.p1) < 0.0:
return abs(self - s.p1)
if Vector.dot(s.p1-s.p2, self-s.p2) < 0.0:
return abs(self - s.p2)
return abs(Vector.cross(s.p2-s.p1, self-s.p1) / abs(s.p2-s.p1))
class Vector(Point):
def __init__(self, x=0.0, y=0.0):
if isinstance(x, tuple):
self.x = x[0]
self.y = x[1]
elif isinstance(x, Point):
self.x = x.x
self.y = x.y
else:
self.x = x
self.y = y
# ????????????
def __add__(self, other):
return Vector(self.x + other.x, self.y + other.y)
def __sub__(self, other):
return Vector(self.x - other.x, self.y - other.y)
def __mul__(self, other):
return Vector(other * self.x, other * self.y)
def __truediv__(self, other):
return Vector(self.x / other, self.y / other)
@classmethod
def dot(cls, a, b):
return a.x * b.x + a.y * b.y
@classmethod
def cross(cls, a, b):
return a.x * b.y - a.y * b.x
@classmethod
def is_orthogonal(cls, a, b):
return Vector.dot(a, b) == 0.0
@classmethod
def is_parallel(cls, a, b):
return Vector.cross(a, b) == 0.0
class Segment(object):
def __init__(self, p1=Point(), p2=Point()):
if isinstance(p1, Point):
self.p1 = p1
self.p2 = p2
elif isinstance(p1, tuple):
self.p1 = Point(p1[0], p1[1])
self.p2 = Point(p2[0], p2[1])
def intersect(self, s):
# ????????¨??????????????????????????????????????????????????????
ans1 = s.p1.ccw(self.p1, self.p2) * s.p2.ccw(self.p1, self.p2)
ans2 = self.p1.ccw(s.p1, s.p2) * self.p2.ccw(s.p1, s.p2)
return ans1 <= 0 and ans2 <= 0
def cross_point(self, s):
# ????????¨??????????????????????????????????????§?¨?????±???????
base = s.p2 - s.p1
d1 = abs(Vector.cross(base, self.p1-s.p1))
d2 = abs(Vector.cross(base, self.p2-s.p1))
t = d1 / (d1 + d2)
return self.p1 + (self.p2 - self.p1) * t
def distance(self, s):
# ????????¨?????????????????????????????¢????±???????
if self.intersect(s):
return 0.0
d1 = s.p1.distance(self)
d2 = s.p2.distance(self)
d3 = self.p1.distance(s)
d4 = self.p2.distance(s)
return min(d1, d2, d3, d4)
@classmethod
def is_orthogonal(cls, s1, s2):
a = Vector(s1.p2 - s1.p1)
b = Vector(s2.p2 - s2.p1)
return Vector.is_orthogonal(a, b)
@classmethod
def is_parallel(cls, s1, s2):
a = Vector(s1.p2 - s1.p1)
b = Vector(s2.p2 - s2.p1)
return Vector.is_parallel(a, b)
class Line(Segment):
pass
class Cirle(object):
def __init__(self, x, y=Point(), r=1.0):
if isinstance(x, Point):
self.c = x
self.r = y
elif isinstance(x, tuple):
self.c = Point(x[0], x[1])
self.r = r
def cross_points(self, s):
if isinstance(s, Segment):
pr = self.c.project(s)
e = (s.p2 - s.p1) / abs(s.p2 - s.p1)
base = sqrt(self.r * self.r - (pr - self.c).norm())
return pr + e * base, pr - e * base
elif isinstance(s, Cirle):
c2 = s
d = abs(self.c - c2.c)
a = acos((self.r * self.r + d * d - c2.r * c2.r) / (2 * self.r * d))
t = atan2(c2.c.y - self.c.y, c2.c.x - self.c.x)
temp1 = Point(cos(t+a)*self.r, sin(t+a)*self.r)
temp2 = Point(cos(t-a)*self.r, sin(t-a)*self.r)
return self.c + temp1, self.c + temp2
def contains(polygon, p):
n = len(polygon)
x = False
for i in range(n):
a = polygon[i] - p
b = polygon[(i+1)%n] - p
if abs(Vector.cross(a, b)) < Point.epsilon and Vector.dot(a, b) < Point.epsilon:
return 1
if a.y > b.y:
temp = a
a = b
b = temp
if a.y < Point.epsilon and Point.epsilon < b.y and Vector.cross(a, b) > Point.epsilon:
x = not x
return 2 if x else 0
def main(args):
for line in sys.stdin:
polygon = []
x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
polygon.append(Point(x1, y1))
polygon.append(Point(x2, y2))
polygon.append(Point(x3, y3))
result = contains(polygon, Point(xp, yp))
if result == 2:
print('YES')
else:
print('NO')
if __name__ == '__main__':
main(sys.argv[1:])
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,556
|
s433291122
|
p00012
|
u299798926
|
1505392671
|
Python
|
Python3
|
py
|
Accepted
| 20
|
7628
| 604
|
length=[float(0) for i in range(3)]
while 1:
try:
x1,y1,x2,y2,x3,y3,x4,y4=[float(i) for i in input().split( )]
x12=x1-x2
y12=y1-y2
x23=x2-x3
y23=y2-y3
x31=x3-x1
y31=y3-y1
x14=x1-x4
y14=y1-y4
x24=x2-x4
y24=y2-y4
x34=x3-x4
y34=y3-y4
gai1=x12*y14-x14*y12
gai2=x23*y24-x24*y23
gai3=x31*y34-x34*y31
if (((gai1>0)and(gai2>0)and(gai3>0))or((gai1<0)and(gai2<0)and(gai3<0))):
print("YES")
else:
print("NO")
except EOFError:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,557
|
s408606953
|
p00012
|
u197615397
|
1507558199
|
Python
|
Python3
|
py
|
Accepted
| 30
|
7620
| 627
|
import math
import sys
def get_triangle_area(x1, y1, x2, y2, x3, y3):
l1 = math.sqrt(abs(x1-x2)**2+abs(y1-y2)**2)
l2 = math.sqrt(abs(x2-x3)**2+abs(y2-y3)**2)
l3 = math.sqrt(abs(x3-x1)**2+abs(y3-y1)**2)
s = (l1+l2+l3)/2
return math.sqrt(s*(s-l1)*(s-l2)*(s-l3))
for l in sys.stdin:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, l.split())
s1 = get_triangle_area(x1, y1, x2, y2, x3, y3)
s2 = get_triangle_area(xp, yp, x1, y1, x2, y2)
s2 += get_triangle_area(xp, yp, x2, y2, x3, y3)
s2 += get_triangle_area(xp, yp, x3, y3, x1, y1)
print("YES" if round(s1, 5) == round(s2, 5) else "NO")
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,558
|
s498197477
|
p00012
|
u548155360
|
1512397083
|
Python
|
Python3
|
py
|
Accepted
| 30
|
5608
| 1,174
|
# coding=utf-8
def direction_vector(p1: list, p2: list)->list:
return [p2[0]-p1[0], p2[1]-p1[1]]
def cross_product(v1: list, v2: list)->float:
return v1[0]*v2[1] - v1[1]*v2[0]
if __name__ == '__main__':
while True:
try:
points_receive = list(map(float, input().split()))
except EOFError:
break
points_list = [[points_receive[2*i], points_receive[2 * i + 1]] for i in range(4)]
p1_to_p2 = direction_vector(points_list[0], points_list[1])
p2_to_p3 = direction_vector(points_list[1], points_list[2])
p3_to_p1 = direction_vector(points_list[2], points_list[0])
p1_to_pp = direction_vector(points_list[0], points_list[3])
p2_to_pp = direction_vector(points_list[1], points_list[3])
p3_to_pp = direction_vector(points_list[2], points_list[3])
cp1 = cross_product(p1_to_p2, p1_to_pp)
cp2 = cross_product(p2_to_p3, p2_to_pp)
cp3 = cross_product(p3_to_p1, p3_to_pp)
if cp1 > 0 and cp2 > 0 and cp3 > 0:
print('YES')
elif cp1 < 0 and cp2 < 0 and cp3 < 0:
print('YES')
else:
print('NO')
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,559
|
s167547808
|
p00012
|
u203261375
|
1513257781
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5596
| 751
|
import sys
def outer(vec_a, vec_b):
return vec_a[0] * vec_b[1] - vec_a[1] * vec_b[0]
try:
while True:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
vec_12 = [x2-x1, y2-y1]
vec_23 = [x3-x2, y3-y2]
vec_31 = [x1-x3, y1-y3]
vec_1p = [xp-x1, yp-y1]
vec_2p = [xp-x2, yp-y2]
vec_3p = [xp-x3, yp-y3]
if (outer(vec_12, vec_1p) > 0 and
outer(vec_23, vec_2p) > 0 and
outer(vec_31, vec_3p) > 0):
print('YES')
elif (outer(vec_12, vec_1p) < 0 and
outer(vec_23, vec_2p) < 0 and
outer(vec_31, vec_3p) < 0):
print('YES')
else:
print('NO')
except:
sys.exit()
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,560
|
s497159158
|
p00012
|
u273843182
|
1514991287
|
Python
|
Python3
|
py
|
Accepted
| 30
|
5588
| 460
|
def tri(x1, y1, x2, y2, x3, y3):
return abs((x2-x1)*(y3-y1) - (y2-y1)*(x3-x1)) / 2
while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
except:
break
abc = tri(x1, y1, x2, y2, x3, y3)
abp = tri(x1, y1, x2, y2, xp, yp)
acp = tri(x1, y1, x3, y3, xp, yp)
bcp = tri(x2, y2, x3, y3, xp, yp)
x, y = int(abc*pow(10, 5)), int((abp+acp+bcp)*pow(10, 5))
print("YES" if x >= y else "NO")
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,561
|
s544729804
|
p00012
|
u024715419
|
1515131179
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5648
| 440
|
import math
while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
s1 = (x2-x1)*(yp-y1) - (y2-y1)*(xp-x1)
s2 = (x3-x2)*(yp-y2) - (y3-y2)*(xp-x2)
s3 = (x1-x3)*(yp-y3) - (y1-y3)*(xp-x3)
if math.copysign(1, s1) == math.copysign(1, s2) and math.copysign(1, s1) == math.copysign(1, s3):
print("YES")
else:
print("NO")
except:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,562
|
s931783267
|
p00012
|
u764789069
|
1515224479
|
Python
|
Python
|
py
|
Accepted
| 10
|
4716
| 821
|
def f(a,b,c,d):
return a*d-b*c
while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp=map(float,raw_input().split())
AB=[x2-x1,y2-y1]
AP=[xp-x1,yp-y1]
BC=[x3-x2,y3-y2]
BP=[xp-x2,yp-y2]
CA=[x1-x3,y1-y3]
CP=[xp-x3,yp-y3]
#print AB
#print BC
#print CA
#print AP
#print BP
#print CP
#print f(AB[0],AB[1],AP[0],AP[1])
#print f(BC[0],BC[1],BP[0],BP[1])
#print f(CA[0],CA[1],CP[0],CP[1])
if (f(AB[0],AB[1],AP[0],AP[1]) < 0 and f(BC[0],BC[1],BP[0],BP[1]) < 0 and f(CA[0],CA[1],CP[0],CP[1]) < 0) or\
(f(AB[0],AB[1],AP[0],AP[1]) > 0 and f(BC[0],BC[1],BP[0],BP[1]) > 0 and f(CA[0],CA[1],CP[0],CP[1]) > 0):
print "YES"
else:
print "NO"
except:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,563
|
s086670847
|
p00012
|
u846136461
|
1516237105
|
Python
|
Python
|
py
|
Accepted
| 10
|
4724
| 1,702
|
# coding: utf-8
while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split())
# print(x1)
# print(x2)
# print(x3)
# print(y1)
# print(y2)
# print(y3)
xg = 1./3 * (x1 + x2 + x3)
yg = 1./3 * (y1 + y2 + y3)
# print("xg = {:}, yg = {:}".format(xg, yg))
def line(xi, yi, xj, yj, x, y):
return (yi-yj)*x/(xi-xj) + (xi*yj-xj*yi)/(xi-xj)
if x1 != x2:
def line12(x, y):
if y < line(x1, y1, x2, y2, x, y):
# print("2")
return 2
elif y > line(x1, y1, x2, y2, x, y):
# print("3")
return 3
else:
# print("0")
return 0
else:
def line12(x, y):
if x1 < x:
# print("2")
return 2
elif x1 > x:
# print("3")
return 3
else:
# print("0")
return 0
if x2 != x3:
def line23(x, y):
if y < line(x2, y2, x3, y3, x, y):
# print("5")
return 5
elif y > line(x2, y2, x3, y3, x, y):
# print("7")
return 7
else:
# print("0")
return 0
else:
def line23(x, y):
if x2 < x:
# print("5")
return 5
elif x2 > x:
# print("7")
return 7
else:
# print("0")
return 0
if x1 != x3:
def line13(x, y):
if y < line(x1, y1, x3, y3, x, y):
# print("11")
return 11
elif y > line(x1, y1, x3, y3, x, y):
# print("13")
return 13
else:
# print("0")
return 0
else:
def line13(x, y):
if x1 < x:
# print("11")
return 11
elif x1 > x:
# print("13")
return 13
else:
# print("0")
return 0
if line12(xp, yp)*line23(xp, yp)*line13(xp, yp) == line12(xg, yg)*line23(xg, yg)*line13(xg, yg):
print("YES")
else:
print("NO")
except EOFError:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,564
|
s803969326
|
p00012
|
u546285759
|
1516367793
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5592
| 440
|
while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
except:
break
AB = [x2-x1, y2-y1]
BC = [x3-x2, y3-y2]
CA = [x1-x3, y1-y3]
BP = [xp-x2, yp-y2]
CP = [xp-x3, yp-y3]
AP = [xp-x1, yp-y1]
v1 = AB[0]*BP[1]-AB[1]*BP[0]
v2 = BC[0]*CP[1]-BC[1]*CP[0]
v3 = CA[0]*AP[1]-CA[1]*AP[0]
print(["NO", "YES"][(v1<0 and v2<0 and v3<0) or (v1>0 and v2>0 and v3>0)])
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,565
|
s908730113
|
p00012
|
u150984829
|
1516788351
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5588
| 202
|
import sys
for e in sys.stdin:
p,q,r,s,t,u,x,y=map(float,e.split())
f=lambda h,i,j,k:(h-p)*(i-q)-(j-q)*(k-p)
a,b=f(x,u,y,t)/f(r,u,s,t),f(x,s,y,r)/f(t,s,u,r)
print(['NO','YES'][0<a<1-b and 0<b<1-a])
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,566
|
s011966953
|
p00012
|
u150984829
|
1516789291
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5584
| 210
|
import sys
def f(h,i,j,k):
z=(j-h)*(y-k)-(k-i)*(x-j);return([-1,1][z>0],0)[z==0]
for e in sys.stdin:
p,q,r,s,t,u,x,y=map(float,e.split())
a,b,c=f(p,q,r,s),f(r,s,t,u),f(t,u,p,q)
print(['NO','YES'][a==b==c])
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,567
|
s127391037
|
p00012
|
u150984829
|
1516789545
|
Python
|
Python3
|
py
|
Accepted
| 30
|
5588
| 219
|
import sys
def f(h,i,j,k):
z=(j-h)*(y-k)-(k-i)*(x-j);return([-1,1][z>0],0)[z==0]
for e in sys.stdin:
p,q,r,s,t,u,x,y=map(float,e.split())
g=[p,q,r,s,t,u]
print(['NO','YES'][f(*g[:4])==f(*g[2:6])==f(*g[4:],*g[:2])])
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,568
|
s708872570
|
p00012
|
u150984829
|
1516789548
|
Python
|
Python3
|
py
|
Accepted
| 30
|
5592
| 219
|
import sys
def f(h,i,j,k):
z=(j-h)*(y-k)-(k-i)*(x-j);return([-1,1][z>0],0)[z==0]
for e in sys.stdin:
p,q,r,s,t,u,x,y=map(float,e.split())
g=[p,q,r,s,t,u]
print(['NO','YES'][f(*g[:4])==f(*g[2:6])==f(*g[4:],*g[:2])])
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,569
|
s126693480
|
p00012
|
u150984829
|
1516789599
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5588
| 197
|
import sys
def f(h,i,j,k):
z=(j-h)*(y-k)-(k-i)*(x-j);return([-1,1][z>0],0)[z==0]
for e in sys.stdin:
p,q,r,s,t,u,x,y=map(float,e.split())
print(['NO','YES'][f(p,q,r,s)==f(r,s,t,u)==f(t,u,p,q)])
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,570
|
s698503008
|
p00012
|
u150984829
|
1516789697
|
Python
|
Python3
|
py
|
Accepted
| 30
|
5584
| 195
|
import sys
def f(h,i,j,k):z=(j-h)*(y-k)-(k-i)*(x-j);return([-1,1][z>0],0)[z==0]
for e in sys.stdin:
p,q,r,s,t,u,x,y=map(float,e.split())
print(['NO','YES'][f(p,q,r,s)==f(r,s,t,u)==f(t,u,p,q)])
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,571
|
s019741399
|
p00012
|
u150984829
|
1516789699
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5584
| 195
|
import sys
def f(h,i,j,k):z=(j-h)*(y-k)-(k-i)*(x-j);return([-1,1][z>0],0)[z==0]
for e in sys.stdin:
p,q,r,s,t,u,x,y=map(float,e.split())
print(['NO','YES'][f(p,q,r,s)==f(r,s,t,u)==f(t,u,p,q)])
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,572
|
s813099930
|
p00012
|
u150984829
|
1516789812
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5584
| 195
|
import sys
def f(a,b,c,d):z=(c-a)*(y-d)-(d-b)*(x-c);return([-1,1][z>0],0)[z==0]
for e in sys.stdin:
p,q,r,s,t,u,x,y=map(float,e.split())
print(['NO','YES'][f(p,q,r,s)==f(r,s,t,u)==f(t,u,p,q)])
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,573
|
s946444748
|
p00012
|
u069727578
|
1520821361
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5592
| 510
|
def cross(x, y):
return (x.conjugate() * y).imag
def inside_triangle(p, x, y, z):
a = cross(y-x, p-y)
b = cross(z-y, p-z)
c = cross(x-z, p-x)
if a*b > 0 and b*c > 0:
return True
return False
import sys
for line in sys.stdin:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
x = complex(x1, y1)
y = complex(x2, y2)
z = complex(x3, y3)
p = complex(xp, yp)
if inside_triangle(p, x, y, z):
print('YES')
else:
print('NO')
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,574
|
s126241024
|
p00012
|
u166871988
|
1523714513
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5596
| 349
|
g=lambda a,b,c:(a[0]-b[0])*(b[1]-c[1])-(b[0]-c[0])*(a[1]-b[1])
while True:
try:t=input()
except:break
l=[float(i) for i in t.split()]
b=[g(l[0:2],l[2:4],l[6:8]),g(l[2:4],l[4:6],l[6:8]),g(l[4:6],l[0:2],l[6:8])]
if len([i for i in b if i>0])==3 or len([i for i in b if i<0])==3:
print("YES")
else:
print("NO")
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,575
|
s519282064
|
p00012
|
u150984829
|
1525319831
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5588
| 192
|
import sys
def f(a,b,c,d):z=(c-a)*(y-d)-(d-b)*(x-c);return[-1*(z==0),1][z>0]
for e in sys.stdin:
p,q,r,s,t,u,x,y=map(float,e.split())
print(['NO','YES'][f(p,q,r,s)==f(r,s,t,u)==f(t,u,p,q)])
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,576
|
s123124583
|
p00012
|
u724548524
|
1525745184
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5588
| 379
|
import sys
def calc(x, y, xp, yp):
a = [(y[i] - y[i -1]) * (xp - x[i]) - (x[i] - x[i - 1]) * (yp - y[i]) for i in range(3)]
print("YES" if (a[0] > 0 and a[1] > 0 and a[2] > 0) or (a[0] < 0 and a[1] < 0 and a[2] < 0) else "NO")
for s in sys.stdin:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, s.split())
x = [x1, x2, x3]
y = [y1, y2, y3]
calc(x, y, xp, yp)
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,577
|
s851826989
|
p00012
|
u536280367
|
1526129528
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5592
| 767
|
import sys
def cross_product(a, b):
ax, ay = a
bx, by = b
return ax * by - ay * bx
def sub(a, b):
a1, a2 = a
b1, b2 = b
return b1 - a1, b2 - a2
def judge(p1, p2, p3, pp):
cnt = 0
for a, b in ((p1, p2), (p2, p3), (p3, p1)):
vec1 = sub(a, b)
vec2 = sub(a, pp)
if cross_product(vec2, vec1) > 0:
cnt += 1
if cnt == 0 or cnt == 3:
print("YES")
else:
print("NO")
if __name__ == '__main__':
for line in sys.stdin:
inputs = [float(s) for s in line.split()]
p1 = (inputs.pop(0), inputs.pop(0))
p2 = (inputs.pop(0), inputs.pop(0))
p3 = (inputs.pop(0), inputs.pop(0))
pp = (inputs.pop(0), inputs.pop(0))
judge(p1, p2, p3, pp)
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,578
|
s521204924
|
p00012
|
u043254318
|
1526483042
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5648
| 802
|
import math
class Point():
def __init__(self, x, y):
self.x = x
self.y = y
def CP(p1, p2, p3):
ax = p2.x-p1.x
ay = p2.y-p1.y
bx = p3.x-p1.x
by = p3.y-p1.y
return ax*by - ay*bx
def Judge(a,b,c):
if a > 0 and b > 0 and c > 0:
print("YES")
elif a < 0 and b < 0 and c < 0:
print("YES")
else:
print("NO")
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
N = list(get_input())
for l in range(len(N)):
x1,y1,x2,y2,x3,y3,xp,yp = [float(i) for i in N[l].split()]
P1 = Point(x1,y1)
P2 = Point(x2,y2)
P3 = Point(x3,y3)
PP = Point(xp,yp)
cp1 = CP(PP, P1, P2)
cp2 = CP(PP, P2, P3)
cp3 = CP(PP, P3, P1)
Judge(cp1,cp2,cp3)
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,579
|
s962841902
|
p00012
|
u458530128
|
1528466832
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5584
| 458
|
def f(x):
x1, y1, x2, y2, x3, y3, xp, yp = x
ax = x3 - x1
ay = y3 - y1
bx = x2 - x1
by = y2 - y1
xp -= x1
yp -= y1
k = (by * xp - bx * yp) / (ax * by - ay * bx)
l = (ay * xp - ax * yp) / (ay * bx - ax * by)
if (k > 0 and l > 0 and k + l < 1):
print('YES')
else:
print('NO')
while True:
try:
point = list(map(float, input().split()))
f(point)
except EOFError:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,580
|
s673714708
|
p00012
|
u847467233
|
1529210439
|
Python
|
Python3
|
py
|
Accepted
| 30
|
5592
| 901
|
# AOJ 0012 A Point in a Triangle
# Python3 2018.6.17 bal4u
EPS = 0.0001
# a, b, はラインの同一側にあるか
def is_atSameSide(a, b, line):
sa = (line[1].real-line[0].real)*(a.imag-line[0].imag) \
+ (line[1].imag-line[0].imag)*(line[0].real-a.real);
sb = (line[1].real-line[0].real)*(b.imag-line[0].imag) \
+ (line[1].imag-line[0].imag)*(line[0].real-b.real);
if -EPS <= sa and sa <= EPS: return False # a in line
if -EPS <= sb and sb <= EPS: return False # b in line
if sa*sb >= 0: return True # a,b at same side
return False # -1;
while True:
try: p = list(map(float, input().split()))
except: break
p1 = complex(p[0], p[1])
p2 = complex(p[2], p[3])
p3 = complex(p[4], p[5])
pp = complex(p[6], p[7])
if is_atSameSide(p3, pp, [p1,p2]) and \
is_atSameSide(p1, pp, [p2,p3]) and \
is_atSameSide(p2, pp, [p3,p1]): print('YES')
else: print('NO')
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,581
|
s394391868
|
p00012
|
u089116225
|
1529512320
|
Python
|
Python3
|
py
|
Accepted
| 20
|
5592
| 522
|
def vec(s,t):
return [t[0]-s[0], t[1]-s[1]]
def area(a,b):
return a[0]*b[1] - a[1]*b[0]
while True:
try:
l = [float(x) for x in input().split()]
a = [l[0],l[1]]
b = [l[2],l[3]]
c = [l[4],l[5]]
p = [l[6],l[7]]
x = area(vec(p,a),vec(p,b))
y = area(vec(p,b),vec(p,c))
z = area(vec(p,c),vec(p,a))
if (x<0 and y<0 and z<0) or (x>0 and y>0 and z>0):
print('YES')
else:
print('NO')
except:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,582
|
s074741759
|
p00012
|
u650035614
|
1530633557
|
Python
|
Python3
|
py
|
Accepted
| 30
|
5812
| 2,615
|
import math
PI = math.pi
EPS = 10**-10
def edge(a, b):
return ((a[0]-b[0])**2+(a[1]-b[1])**2)**.5
def area(a, b, c):
s = (a+b+c)/2
return (s*(s-a)*(s-b)*(s-c))**.5
def LawOfCosines(a, b, c): #余弦定理
return math.acos( (b*b+c*c-a*a) / (2.0*b*c) );
def is_same(x, y):
return abs(x-y) < EPS
class Triangle:
def __init__(self, p):
a, b, c = p
self.a = a
self.b = b
self.c = c
self.edgeA = edge(b, c)
self.edgeB = edge(c, a)
self.edgeC = edge(a, b)
self.area = area(self.edgeA, self.edgeB, self.edgeC)
self.angleA = LawOfCosines(self.edgeA, self.edgeB, self.edgeC)
self.angleB = LawOfCosines(self.edgeB, self.edgeC, self.edgeA)
self.angleC = LawOfCosines(self.edgeC, self.edgeA, self.edgeB)
def circumscribeadCircleRadius(self): #外接円の半径を返す
return self.edgeA / math.sin(self.angleA) / 2.0
def circumscribedCircleCenter(self): #外接円の中心の座標を返す
a = math.sin(2.0*self.angleA);
b = math.sin(2.0*self.angleB);
c = math.sin(2.0*self.angleC);
X = (self.a[0] * a + self.b[0] * b + self.c[0] * c) / (a+b+c);
Y = (self.a[1] * a + self.b[1] * b + self.c[1] * c) / (a+b+c);
return X, Y
def inscribedCircleRadius(self): #内接円の半径
return 2 * self.area / (self.edgeA + self.edgeB + self.edgeC)
def inscribedCircleCenter(self): #内接円の中心の座標
points = [self.a, self.b, self.c]
edges = [self.edgeA, self.edgeB, self.edgeC]
s = sum(edges)
return [sum([points[j][i]*edges[j] for j in range(3)])/s for i in range(2)]
def isInner(self, p): #点が三角形の内側か判定
cross = lambda a, b: a[0]*b[1]-a[1]*b[0]
c1 = 0
c2 = 0
points = [self.a, self.b, self.c]
for i in range(3):
a = [points[i][0]-points[(i+1)%3][0], points[i][1]-points[(i+1)%3][1]]
b = [points[i][0]-p[0], points[i][1]-p[1]]
c = cross(a, b)
if c > 0:
c1 += 1
elif c < 0:
c2 += 1
if c1 == 3 or c2 == 3:
return True
else:
return c1+c2 != 3 and (c1 == 0 or c2 == 0)
if __name__ == "__main__":
while True:
try:
c = list(map(float, input().split()))
points = [(c[i], c[i+1]) for i in range(0, 6, 2)]
point = [c[6], c[7]]
t = Triangle(points)
print(["NO","YES"][t.isInner(point)])
except:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,583
|
s969663379
|
p00012
|
u759949288
|
1351586129
|
Python
|
Python
|
py
|
Accepted
| 10
|
11000
| 757
|
import sys
def cross(a, b):
return (a.conjugate() * b).imag
def dot(a, b):
return (a.conjugate() * b).real
def ccw(a, b, c):
x = b - a
y = c - a;
if cross(x, y) > 0: return 1
if cross(x, y) < 0: return -1
if dot(x, y) < 0: return 2
if abs(x) < abs(y): return -2
return 0
def solve(l, p):
x = ccw(l[0][0], l[0][1], p)
if x == 0: x = 1
else: x = int(x / abs(x))
for i in l[1:]:
y = ccw(i[0], i[1], p)
if y == 0: y = 1
else: y = int(y / abs(y))
if x != y:
print "NO"
return
print "YES"
for line in sys.stdin:
try:
ax, ay, bx, by, cx, cy, px, py = map(float, line.split())
except ValueError:
sys.exit(0)
a = complex(ax, ay)
b = complex(bx, by)
c = complex(cx, cy)
p = complex(px, py)
solve([(a, b), (b, c), (c, a)], p)
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,584
|
s790347556
|
p00012
|
u759949288
|
1351588164
|
Python
|
Python
|
py
|
Accepted
| 20
|
5300
| 588
|
import sys
def cross(a, b):
return (a.conjugate() * b).imag
def dot(a, b):
return (a.conjugate() * b).real
def ccw(a, b, c):
x = b - a
y = c - a;
cr = cross(x, y)
if cr != 0: return cr
if dot(x, y) < 0: return 2
if abs(x) < abs(y): return -2
return 0
def solve(l, p):
x = cmp(ccw(l[0][0], l[0][1], p), 0)
if any([x != cmp(ccw(i[0], i[1], p), 0) for i in l[1:]]):
print "NO"
else: print "YES"
for line in sys.stdin:
t = map(float, line.split())
if len(t) == 0: continue
a, b, c, p = map(lambda x, y: complex(x, y), t[0::2], t[1::2])
solve([(a, b), (b, c), (c, a)], p)
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,585
|
s038693780
|
p00012
|
u759949288
|
1351592042
|
Python
|
Python
|
py
|
Accepted
| 10
|
5300
| 569
|
import sys
def cross(a, b):
return (a.conjugate() * b).imag
def dot(a, b):
return (a.conjugate() * b).real
def ccw(a, b, c):
x = b - a
y = c - a;
cr = cross(x, y)
if cr != 0: return cr
if dot(x, y) < 0: return 2
if abs(x) < abs(y): return -2
return 0
def solve(l, p):
x = cmp(ccw(l[0][0], l[0][1], p), 0)
if all(cmp(ccw(i[0], i[1], p), 0) == x for i in l[1:]):
print "YES"
else:
print "NO"
for line in sys.stdin:
t = map(float, line.split())
if len(t) == 0: continue
a, b, c, p = map(complex, t[0::2], t[1::2])
solve([(a, b), (b, c), (c, a)], p)
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,586
|
s315807957
|
p00012
|
u759949288
|
1351593213
|
Python
|
Python
|
py
|
Accepted
| 10
|
5300
| 542
|
import sys
def cross(a, b):
return (a.conjugate() * b).imag
def dot(a, b):
return (a.conjugate() * b).real
def ccw(a, b, c):
x = b - a
y = c - a;
cr = cross(x, y)
if cr != 0: return cr
if dot(x, y) < 0: return 2
if abs(x) < abs(y): return -2
return 0
for line in sys.stdin:
t = map(float, line.split())
if len(t) == 0: continue
a, b, c, p = map(complex, t[0::2], t[1::2])
l = [(a, b), (b, c), (c, a)]
x = cmp(ccw(l[0][0], l[0][1], p), 0)
if all(cmp(ccw(i[0], i[1], p), 0) == x for i in l[1:]):
print "YES"
else:
print "NO"
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,587
|
s397190043
|
p00012
|
u647766105
|
1351612231
|
Python
|
Python
|
py
|
Accepted
| 10
|
4300
| 611
|
import sys
for line in sys.stdin.readlines():
try:
list=map(float,line.split())
x=list[0:6:2]
y=list[1:6:2]
xp=list[6]
yp=list[7]
xv=[x[a%3]-x[(a+1)%3] for a in xrange(4)]
yv=[y[a%3]-y[(a+1)%3] for a in xrange(4)]
xpv=[xp-x[a] for a in xrange(3)]
ypv=[yp-y[a] for a in xrange(3)]
cross=[xv[i]*ypv[i]-yv[i]*xpv[i] for i in xrange(3)]
if (cross[2]>0 and cross[1]>0 and cross[0]>0) or (cross[2]<0 and cross[1]<0 and cross[0]<0):
print "YES"
else:
print "NO"
except:
pass
#temp
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,588
|
s829678721
|
p00012
|
u779627195
|
1352549787
|
Python
|
Python
|
py
|
Accepted
| 20
|
5440
| 950
|
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)
EPS = 10**(-7)
def isIntersectedLS(a1, a2, b1, b2):
return ((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1)) < EPS and
(cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1)) < EPS)
while 1:
try:
x,y = [[0. for i in xrange(3)] for j in xrange(2)]
a = []
z = [0. for i in xrange(2)]
line = raw_input().split()
if line == []: break
x[0],y[0],x[1],y[1],x[2],y[2],z[0],z[1] = map(float, line)
for i in xrange(3):
a.append((x[i]+(y[i])*1j))
c = (sum(x)/3)+(sum(y)/3)*1j
p = z[0]+z[1]*1j
for i in xrange(3):
#print a, c, p
if isIntersectedLS(a[i-1], a[i], c, p) is True:
print "NO"
break
else:
print "YES"
except EOFError:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,589
|
s147811686
|
p00012
|
u280179677
|
1355388665
|
Python
|
Python
|
py
|
Accepted
| 10
|
4284
| 963
|
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
class DirectedSegment:
def __init__(self, s, e):
self.start = s
self.end = e
LEFT = -1
ONLINE = 0
RIGHT = 1
def datasets():
import sys
while True:
s = sys.stdin.readline()
if len(s) < 2:
break
x1, y1, x2, y2, x3, y3, xp, yp = [float(d) for d in s.split()]
p1 = Point(x1, y1)
p2 = Point(x2, y2)
p3 = Point(x3, y3)
x = Point(xp,yp)
yield p1, p2, p3, x
def side(ds, p):
return cmp(p.x * (ds.start.y - ds.end.y) + ds.start.x * (ds.end.y - p.y) + ds.end.x * (p.y - ds.start.y), 0)
for p1, p2, p3, x in datasets():
r = [
side(DirectedSegment(p1, p2), x),
side(DirectedSegment(p2, p3), x),
side(DirectedSegment(p3, p1), x)
]
if all(0 < n for n in r) or all(0 > n for n in r):
print "YES"
else:
print "NO"
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,590
|
s039284885
|
p00012
|
u419407022
|
1356035187
|
Python
|
Python
|
py
|
Accepted
| 20
|
4308
| 849
|
class Point(object):
x = 0.0
y = 0.0
def __init__(self, x, y):
self.x = x
self.y = y
def __sub__(left, right):
return Point(left.x - right.x, left.y - right.y)
#cross
def __mul__(left, right):
return left.x * right.y - left.y * right.x
while True:
try:
(x1, y1, x2, y2, x3, y3, xp, yp) = map(float, raw_input().split())
p1 = Point(x1, y1)
p2 = Point(x2, y2)
p3 = Point(x3, y3)
pp = Point(xp, yp)
p12 = p1 - p2
p23 = p2 - p3
p31 = p3 - p1
pp1 = pp - p1
pp2 = pp - p2
pp3 = pp - p3
c1 = (p12 * pp1 < 0.0)
c2 = (p23 * pp2 < 0.0)
c3 = (p31 * pp3 < 0.0)
if(c1 ^ c2 or c2 ^ c3):
print 'NO'
else:
print 'YES'
except EOFError:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,591
|
s279598691
|
p00012
|
u126791750
|
1357122247
|
Python
|
Python
|
py
|
Accepted
| 10
|
4272
| 537
|
if __name__ == '__main__':
while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split())
r = 0
vec = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1)
if vec > 0:
r += 1
elif vec < 0:
r -= 1
vec = (x3 - x2) * (yp - y2) - (y3 - y2) * (xp - x2)
if vec > 0:
r += 1
elif vec < 0:
r -= 1
vec = (x1 - x3) * (yp - y3) - (y1 - y3) * (xp - x3)
if vec > 0:
r += 1
elif vec < 0:
r -= 1
if r == 3 or r == -3:
print("YES")
else:
print("NO")
except EOFError:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,592
|
s964238381
|
p00012
|
u126791750
|
1357122429
|
Python
|
Python
|
py
|
Accepted
| 20
|
4272
| 488
|
def checker(x1,y1,x2,y2,xp,yp):
r = 0
vec = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1)
if vec > 0:
r = 1
elif vec < 0:
r = -1
return r
if __name__ == '__main__':
while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split())
r = 0
r += int(checker(x1,y1,x2,y2,xp,yp))
r += int(checker(x2, y2, x3, y3, xp, yp))
r += int(checker(x3, y3, x1, y1, xp, yp))
if r == 3 or r == -3:
print("YES")
else:
print("NO")
except EOFError:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,593
|
s736380858
|
p00012
|
u782850731
|
1362064510
|
Python
|
Python
|
py
|
Accepted
| 20
|
4804
| 1,067
|
from __future__ import (division, absolute_import, print_function,
unicode_literals)
from sys import stdin
from operator import attrgetter
from collections import namedtuple
Point = namedtuple('Point', 'x y')
def linear(p1, p2):
gradient = (p1.y - p2.y) / (p1.x - p2.x)
y_intercept = p1.y - gradient * p1.x
return lambda x: gradient * x + y_intercept
def takeout(seq):
gen = (Point(next(seq), next(seq)) for _ in xrange(3))
for p in sorted(gen, key=attrgetter('x')):
yield p
yield Point(next(seq), next(seq))
for line in stdin:
A, B, C, P = takeout(float(s) for s in line.split())
assert A.x <= B.x <= C.x
if P.x <= A.x or C.x <= P.x:
print('NO')
continue
if A.x == B.x or B.x <= P.x <= C.x:
L = (linear(B, C), linear(A, C))
elif B.x == C.x or A.x <= P.x <= B.x:
L = (linear(A, B), linear(A, C))
else:
print('NO')
continue
y1, y2 = sorted(f(P.x) for f in L)
if y1 < P.y < y2:
print('YES')
else:
print('NO')
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,594
|
s414463478
|
p00012
|
u894941280
|
1362610221
|
Python
|
Python
|
py
|
Accepted
| 20
|
4452
| 577
|
from math import sqrt
dis = lambda x1,y1,x2,y2: sqrt((x1-x2)**2+(y1-y2)**2)
def heron(a,b,c):
s = (a+b+c)*1.0/2
return sqrt(s*(s-a)*(s-b)*(s-c))
while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split())
a,b,c = dis(x1,y1,x2,y2),dis(x1,y1,x3,y3),dis(x3,y3,x2,y2)
d,e,f = dis(x1,y1,xp,yp),dis(xp,yp,x2,y2),dis(xp,yp,x3,y3)
AnsS = heron(a,b,c)
FakS = heron(a,e,d)+heron(e,c,f)+heron(d,b,f)
q1,q2 = str(AnsS),str(FakS)
Ans = "YES" if q1 == q2 else "NO"
print Ans
except EOFError: break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,595
|
s633668595
|
p00012
|
u542421762
|
1368174357
|
Python
|
Python
|
py
|
Accepted
| 10
|
4276
| 763
|
import sys
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def direction_of_rotation(p1, p2, p3):
d = p1.x * (p2.y - p3.y) + p2.x * (p3.y - p1.y) + p3.x * (p1.y - p2.y)
if d < 0:
direction = 'right'
else:
direction = 'left'
return direction
#input_file = open(sys.argv[1], "r")
#for line in input_file:
for line in sys.stdin:
a = map((lambda x: float(x)), line.split(' '))
p1 = Point(a[0], a[1])
p2 = Point(a[2], a[3])
p3 = Point(a[4], a[5])
p = Point(a[6], a[7])
d1 = direction_of_rotation(p, p1, p2)
d2 = direction_of_rotation(p, p2, p3)
d3 = direction_of_rotation(p, p3, p1)
if d1 == d2 and d1 == d3:
print "YES"
else:
print "NO"
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,596
|
s868866965
|
p00012
|
u724947062
|
1369401633
|
Python
|
Python
|
py
|
Accepted
| 20
|
4324
| 1,335
|
import sys
class Point(object):
def __init__(self, x, y):
self.x = x
self.y = y
def isLeft(self, vector):
tmpVector = DirectedVector(vector.start, self)
sin = tmpVector * vector
if sin > 0:
return True
else:
return False
class DirectedVector(object):
def __init__(self, start, end):
self.start = start
self.end = end
@property
def x(self):
return self.end.x - self.start.x
@property
def y(self):
return self.end.y - self.start.y
def __mul__(self, other):
return self.x * other.y - self.y * other.x
def getDataSets():
for line in sys.stdin.readlines():
line = line.strip()
x1, y1, x2, y2, x3, y3, xp, yp = [float(x) for x in line.split()]
p1 = Point(x1, y1)
p2 = Point(x2, y2)
p3 = Point(x3, y3)
px = Point(xp, yp)
yield p1, p2, p3, px
def main():
for p1, p2, p3, px in getDataSets():
evaluate = [
px.isLeft(DirectedVector(p1, p2)),
px.isLeft(DirectedVector(p2, p3)),
px.isLeft(DirectedVector(p3, p1)),
]
if(all(evaluate) or not any(evaluate)):
print 'YES'
else:
print 'NO'
if __name__ == "__main__":
main()
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,597
|
s483489160
|
p00012
|
u912237403
|
1377410752
|
Python
|
Python
|
py
|
Accepted
| 20
|
4260
| 410
|
def side(p1, p2, p3):
return (p3[1]-p1[1])*(p2[0]-p1[0])-(p2[1]-p1[1])*(p3[0]-p1[0])>0
while True:
try:
x = map(float, raw_input().split())
p1 = x[0:2]
p2 = x[2:4]
p3 = x[4:6]
p0 = x[6:]
if (side(p1, p2, p0)==side(p2, p3, p0) and side(p2, p3, p0)==side(p3, p1, p0)):
print "YES"
else:
print "NO"
except:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,598
|
s104570478
|
p00012
|
u813384600
|
1379496210
|
Python
|
Python
|
py
|
Accepted
| 20
|
4272
| 623
|
while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split())
r = 0
vec = (x2-x1) * (yp-y1) - (y2-y1) * (xp-x1)
if vec > 0:
r += 1
elif vec < 0:
r -= 1
vec = (x3-x2) * (yp-y2) - (y3-y2) * (xp-x2)
if vec > 0:
r += 1
elif vec < 0:
r -= 1
vec = (x1-x3) * (yp-y3) - (y1-y3) * (xp-x3)
if vec > 0:
r += 1
elif vec < 0:
r -= 1
if r == 3 or r == -3:
print("YES")
else:
print("NO")
except EOFError:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,599
|
s298954151
|
p00012
|
u230836528
|
1392286094
|
Python
|
Python
|
py
|
Accepted
| 10
|
4332
| 1,080
|
# -*- coding: utf-8 -*-
import sys
def prod2d(vec1, vec2):
return vec1[0]*vec2[1] - vec1[1]*vec2[0]
lineNumber = 0
#for line in [ "0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5", "0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0"]:
for line in sys.stdin.readlines():
lineNumber += 1
# get data
List = map(float, line.strip().split())
# set data
nodes = [ [List[0], List[1]], [List[2], List[3]], [List[4], List[5]] ]
point = [List[6], List[7]]
ABvec = [ nodes[1][0] - nodes[0][0], nodes[1][1] - nodes[0][1] ]
BCvec = [ nodes[2][0] - nodes[1][0], nodes[2][1] - nodes[1][1] ]
CAvec = [ nodes[0][0] - nodes[2][0], nodes[0][1] - nodes[2][1] ]
APvec = [ point[0] - nodes[0][0], point[1] - nodes[0][1] ]
BPvec = [ point[0] - nodes[1][0], point[1] - nodes[1][1] ]
CPvec = [ point[0] - nodes[2][0], point[1] - nodes[2][1] ]
a = prod2d(CAvec, APvec)
b = prod2d(ABvec, BPvec)
c = prod2d(BCvec, CPvec)
if a > 0 and b > 0 and c > 0: print "YES"
elif a < 0 and b < 0 and c < 0: print "YES"
else : print "NO"
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,600
|
s083344752
|
p00012
|
u633068244
|
1393359838
|
Python
|
Python
|
py
|
Accepted
| 10
|
4468
| 802
|
import math
while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp = map(float, raw_input().split())
a = math.sqrt((x1-x2)**2+(y1-y2)**2)
b = math.sqrt((x1-x3)**2+(y1-y3)**2)
c = math.sqrt((x2-x3)**2+(y2-y3)**2)
xa = math.sqrt((x3-xp)**2+(y3-yp)**2)
xb = math.sqrt((x2-xp)**2+(y2-yp)**2)
xc = math.sqrt((x1-xp)**2+(y1-yp)**2)
s = (a+b+c)/2
sa = (a+xb+xc)/2
sb = (b+xa+xc)/2
sc = (c+xa+xb)/2
ss = math.sqrt(s*(s-a)*(s-b)*(s-c))
ssa = math.sqrt(sa*(sa-a)*(sa-xb)*(sa-xc))
ssb = math.sqrt(sb*(sb-xa)*(sb-b)*(sb-xc))
ssc = math.sqrt(sc*(sc-xa)*(sc-xb)*(sc-c))
if ssa+ssb+ssc - ss > 0.0000001:
print "NO"
else:
print "YES"
except:
break
|
p00012
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>A Point in a Triangle</H1>
<p>
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
</p>
<p>
Write a program which prints "<span>YES</span>" if a point $P$ $(x_p, y_p)$ is in the triangle and "<span>NO</span>" if not.
</p>
<!--
<p>
You can suppose that P is never on the points nor sides of the triangle.
</p>
-->
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$<br/>
</p>
<p>
All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.
</p>
<h2>Constraints</h2>
<p>
You can assume that:
</p>
<ul>
<li>$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$</li>
<li>1.0 $\leq$ Length of each side of a tringle</li>
<li>0.001 $\leq$ Distance between $P$ and each side of a triangle</li>
</ul>
<H2>Output</H2>
<p>
For each dataset, print "<span>YES</span>" or "<span>NO</span>" in a line.
</p>
<H2>Sample Input</H2>
<pre>
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
YES
NO
</pre>
|
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
|
YES
NO
| 5,601
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.