submission_id string | problem_id string | status string | code string | input string | output string | problem_description string |
|---|---|---|---|---|---|---|
s520103846 | p00012 | Wrong Answer |
x1,y1,x2,y2,x3,y3,xp,yp=[float(p) for p in input().split()]
x_vector_1to2=x2-x1;
y_vector_1to2=y2-y1;
x_vector_1to3=x3-x1;
y_vector_1to3=y3-y1;
x_vector_p=xp-x1;
y_vector_p=yp-y1;
def renritu(p,q,r,s,t,u): # renritu(p,q,r,s,t,u) px + qy = r sx+ty=u
a=p; b=q; c=r; d=s; e=t; f=u;
a1=a*d; b1=b*d; c1=c*d; d1=d*a; e1=e*a; f1=f*a;
res_y=b1-e1;
if res_y != 0 :
res_y =(c1-f1)/res_y;
res_x =(c-b*res_y)/a;
return(res_x,res_y)
else:
res_x=c/a;
res=renritu(x_vector_1to2,x_vector_1to3,x_vector_p,y_vector_1to2,y_vector_1to3,y_vector_p)
if res[0] >=0 and res[1] >=0 and res[0]+res[1]<=1:
print("YES")
else:
print("NO")
| 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
|
<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>
|
s260687683 | p00012 | Wrong Answer |
x1,y1,x2,y2,x3,y3,xp,yp=[float(p) for p in input().split()]
x_vector_1to2=x2-x1;
y_vector_1to2=y2-y1;
x_vector_1to3=x3-x1;
y_vector_1to3=y3-y1;
x_vector_p=xp-x1;
y_vector_p=yp-y1;
def renritu(p,q,r,s,t,u): # renritu(p,q,r,s,t,u) px + qy = r sx+ty=u
a=p; b=q; c=r; d=s; e=t; f=u;
a1=a*d; b1=b*d; c1=c*d; d1=d*a; e1=e*a; f1=f*a;
res_y=b1-e1;
if res_y != 0 :
res_y =(c1-f1)/res_y;
res_x =(c-b*res_y)/a;
return(res_x,res_y)
else:
res_x=c/a;
res=renritu(x_vector_1to2,x_vector_1to3,x_vector_p,y_vector_1to2,y_vector_1to3,y_vector_p)
if res[0] >=0 and res[1] >=0 and res[0]+res[1]<=1:
print("YES ")
else:
print("NO ")
| 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
|
<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>
|
s011498505 | p00012 | Wrong Answer |
x1,y1,x2,y2,x3,y3,xp,yp=[float(p) for p in input().split()]
x_vector_1to2=x2-x1;
y_vector_1to2=y2-y1;
x_vector_1to3=x3-x1;
y_vector_1to3=y3-y1;
x_vector_p=xp-x1;
y_vector_p=yp-y1;
def renritu(p,q,r,s,t,u): # renritu(p,q,r,s,t,u) px + qy = r sx+ty=u
a=p; b=q; c=r; d=s; e=t; f=u;
a1=a*d; b1=b*d; c1=c*d; d1=d*a; e1=e*a; f1=f*a;
res_y=b1-e1;
if res_y != 0 :
res_y =(c1-f1)/res_y;
res_x =(c-b*res_y)/a;
return(res_x,res_y)
else:
res_x=c/a;
return(res_x,0)
res=renritu(x_vector_1to2,x_vector_1to3,x_vector_p,y_vector_1to2,y_vector_1to3,y_vector_p)
if res[0] >=0 and res[1] >=0 and res[0]+res[1]<=1:
print("YES")
else:
print("NO")
| 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
|
<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>
|
s184659137 | p00012 | Wrong Answer |
x1,y1,x2,y2,x3,y3,xp,yp=[float(p) for p in input().split()]
x_vector_1to2=x2-x1;
y_vector_1to2=y2-y1;
x_vector_1to3=x3-x1;
y_vector_1to3=y3-y1;
x_vector_p=xp-x1;
y_vector_p=yp-y1;
def renritu(p,q,r,s,t,u): # renritu(p,q,r,s,t,u) px + qy = r sx+ty=u
a=p; b=q; c=r; d=s; e=t; f=u;
a1=a*d; b1=b*d; c1=c*d; d1=d*a; e1=e*a; f1=f*a;
res_y=b1-e1;
if res_y != 0 :
res_y =(c1-f1)/res_y;
res_x =(c-b*res_y)/a;
return(res_x,res_y)
else:
res_x=c/a;
return(res_x,0)
res=renritu(x_vector_1to2,x_vector_1to3,x_vector_p,y_vector_1to2,y_vector_1to3,y_vector_p)
if res[0] >0 and res[1] >0 and res[0]+res[1]<1:
print("YES")
else:
print("NO")
| 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
|
<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>
|
s217292256 | p00012 | Wrong Answer |
x1,y1,x2,y2,x3,y3,xp,yp=[float(p) for p in input().split()]
x_vector_1to2=x2-x1;
y_vector_1to2=y2-y1;
x_vector_1to3=x3-x1;
y_vector_1to3=y3-y1;
x_vector_p=xp-x1;
y_vector_p=yp-y1;
def renritu(p,q,r,s,t,u): # renritu(p,q,r,s,t,u) px + qy = r sx+ty=u
a=p; b=q; c=r; d=s; e=t; f=u;
a1=a*d; b1=b*d; c1=c*d; d1=d*a; e1=e*a; f1=f*a;
res_y=b1-e1;
if res_y != 0 :
res_y =(c1-f1)/res_y;
res_x =(c-b*res_y)/a;
return(res_x,res_y)
else:
return(-1,-1)
res=renritu(x_vector_1to2,x_vector_1to3,x_vector_p,y_vector_1to2,y_vector_1to3,y_vector_p)
if res[0] >0 and res[1] >0 and (res[0]+res[1])<1:
print("YES")
else:
print("NO")
| 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
|
<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>
|
s291832173 | p00012 | Wrong Answer | g=lambda a,b:a[0]*b[1]-a[1]*b[0]
while True:
try:l=[float(i) for i in input().split()]
except:break
ba=[l[0]-l[2],l[1]-l[3]]
ab=[-i for i in ba]
cb=[l[2]-l[4],l[3]-l[5]]
bc=[-i for i in cb]
ca=[l[0]-l[4],l[1]-l[5]]
ac=[-i for i in ca]
ap=[l[6]-l[0],l[7]-l[1]]
bp=[l[6]-l[2],l[7]-l[3]]
cp=[l[6]-l[4],l[7]-l[5]]
if g(ab,ac)<g(ab,ap) or g(ba,bc)<g(ba,bp):
print("NO")
else:
print("YES")
| 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
|
<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>
|
s214835153 | p00012 | Wrong Answer | g=lambda a,b:abs(a[0]*b[1]-a[1]*b[0])
while True:
try:t=input()
except:break
l=[float(i) for i in t.split()]
ba=[l[0]-l[2],l[1]-l[3]]
ab=[-i for i in ba]
cb=[l[2]-l[4],l[3]-l[5]]
bc=[-i for i in cb]
ca=[l[0]-l[4],l[1]-l[5]]
ac=[-i for i in ca]
ap=[l[6]-l[0],l[7]-l[1]]
bp=[l[6]-l[2],l[7]-l[3]]
cp=[l[6]-l[4],l[7]-l[5]]
if g(ab,ac)<g(ab,ap) or g(ba,bc)<g(ba,bp) or g(ca,cb)<g(ca,cp):
print("NO")
else:
print("YES")
| 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
|
<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>
|
s793257578 | p00012 | Wrong Answer | g=lambda a,b:a[0]*b[1]-a[1]*b[0]
while True:
try:t=input()
except:break
l=[float(i) for i in t.split()]
ba=[l[0]-l[2],l[1]-l[3]]
ab=[-i for i in ba]
cb=[l[2]-l[4],l[3]-l[5]]
bc=[-i for i in cb]
ca=[l[0]-l[4],l[1]-l[5]]
ac=[-i for i in ca]
ap=[l[6]-l[0],l[7]-l[1]]
bp=[l[6]-l[2],l[7]-l[3]]
cp=[l[6]-l[4],l[7]-l[5]]
p=[g(ab,ac) , g(ab,ap) , g(ba,bc) , g(ba,bp) , g(ca,cb) , g(ca,cp)]
if p[0]*p[1]<0 or p[2]*p[3]<0 or p[4]<p[5]<0 or abs(p[0])<abs(p[1]) or abs(p[2])<abs(p[3]) or abs(p[4])<abs(p[5]):
print("NO")
else:
print("YES")
| 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
|
<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>
|
s714939027 | p00012 | Wrong Answer | 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):
for a, b in ((p1, p2), (p2, p3), (p3, p1)):
vec1 = sub(a, b)
vec2 = sub(a, pp)
if cross_product(vec2, vec1) >= 0:
print("NO")
return
print("YES")
if __name__ == '__main__':
inputs = [float(s) for s in input().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)
| 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
|
<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>
|
s733499586 | p00012 | Wrong Answer | 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__':
inputs = [float(s) for s in input().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)
| 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
|
<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>
|
s493102366 | p00012 | Wrong Answer | def f(x):
x1, y1, x2, y2, x3, y3, xp, yp = x
if not x2 == x1:
a1 = ((y2 - y1) / (x2 - x1)) * (xp -x1) + y1
else:
a1 = x1
if not x3 == x1:
a2 = ((y3 - y1) / (x3 - x1)) * (xp - x1) + y1
else:
a2 = x1
if not x3 == x2:
a3 = ((y3 - y2) / (x3 - x2)) * (xp - x2) + y2
else:
a3 = x2
if (yp > a1 and yp < a2 and yp < a3) or (yp < a1 and yp > a2 and yp < a3) or (yp < a1 and yp < a2 and yp > a3):
print('YES')
else:
print('NO')
while True:
try:
point = list(map(float, input().split()))
f(point)
except EOFError:
break
| 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
|
<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>
|
s889295069 | p00012 | Wrong Answer | def f(x):
x1, y1, x2, y2, x3, y3, xp, yp = x
ax = x3 - x1
ay = y3 - y1
bx = x2 - x1
by = y2 - 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
| 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
|
<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>
|
s493415765 | p00012 | Wrong Answer | import sys
def cross(a, b):
return (a.conjugate() * b).real
def dot(a, b):
return (a.conjugate() * b).imag
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 = int(x / abs(x))
for i in l[1:]:
y = ccw(i[0], i[1], p)
if y != 0:
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) | 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
|
<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>
|
s953787819 | p00012 | Wrong Answer | import sys
def cross(a, b):
return (a.conjugate() * b).real
def dot(a, b):
return (a.conjugate() * b).imag
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) | 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
|
<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>
|
s986791015 | p00012 | Wrong Answer | 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):
if any(ccw(i[0], i[1], p) == ccw(l[0][0], l[0][1], p) 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) | 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
|
<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>
|
s191809717 | p00012 | Wrong Answer | 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), x) 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(complex, t[0::2], t[1::2])
solve([(a, b), (b, c), (c, a)], p) | 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
|
<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>
|
s338757866 | p00012 | Wrong Answer | 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)]
sorted(cross)
if (cross[2]>0 and cross[0]>0) or (cross[2]<0 and cross[0]<0):
print "YES"
else:
print "NO"
except:
pass
#temp | 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
|
<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>
|
s619122874 | p00012 | Wrong Answer | import sys
def cross(a,b,p):
return ((b[0]-a[0])*(p[1]-a[1])) - ((p[0]-a[0])*(b[1]-a[1]))
for i in sys.stdin:
l = [float(x.rstrip()) for x in i.split()]
if len(l) is 8:
a,b,c,p = [l[:2],l[2:4],l[4:6],l[6:]]
if cross(a,b,p)<=0 and cross(b,c,p)<=0 and cross(c,a,p)<=0 :
print "YES"
elif cross(a,b,p)>=0 and cross(b,c,p)>=0 and cross(c,a,p)>=0 :
print "YES"
else:
print "N0" | 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
|
<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>
|
s488788383 | p00012 | Wrong Answer | while True:
try:
x1,y1,x2,y2,x3,y3,px,py = map(float,raw_input().split(' '))
v1 = [x1-px,y1-py]
v2 = [x2-px,y2-py]
v3 = [x3-px,y3-py]
v12 =[v1[0]+v2[0],v1[1]+v2[1]]
if v12[0]*v3[0]+v12[1]*v3[1] < 0:
print 'YES'
else:
print 'NO'
except ValueError:
break | 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
|
<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>
|
s907447275 | p00012 | Wrong Answer | 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.x + left.y * right.y
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)
c2 = (p23 * pp2 < 0)
c3 = (p31 * pp3 < 0)
if(c1 ^ c2 or c2 ^ c3):
print 'NO'
else:
print 'YES'
except EOFError:
break | 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
|
<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>
|
s080392069 | p00012 | Wrong Answer | 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.x + left.y * right.y
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 | 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
|
<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>
|
s322741965 | p00012 | Wrong Answer | 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 | 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
|
<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>
|
s265355198 | p00012 | Wrong Answer | from __future__ import (division, absolute_import, print_function,
unicode_literals)
from sys import stdin
for line in stdin:
sets = [float(s) for s in line.split()]
xa, xb = sorted(sets[:5:2])[::2]
ya, yb = sorted(sets[1:6:2])[::2]
if xa < sets[6] < xb and ya < sets[7] < yb:
print('YES')
else:
print('NO') | 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
|
<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>
|
s108597309 | p00012 | Wrong Answer | 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())
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') | 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
|
<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>
|
s454880378 | p00012 | Wrong Answer | ans=[]
def inside(t1x,t1y,t2x,t2y,t3x,t3y,px,py):
if ((t1x-t2x) * (t3y-t1y) + (t1y-t2y)* (t1x-t3x))*((t1x-t2x) * (py-t1y) + (t1y-t2y) * (t1x-px)) > 0:
return False
else:
return True
while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp=map(float,raw_input().split())
except EOFError:
break
if not (
inside(x1,y1,x2,y2,x3,y3,xp,yp) and
inside(x1,y1,x2,y2,x3,y3,xp,yp) and
inside(x1,y1,x2,y2,x3,y3,xp,yp)
):
ans.append("YES")
else:
ans.append("NO")
for i in ans:
print i | 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
|
<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>
|
s815399246 | p00012 | Wrong Answer | import sys
def inp(a,b): return a[0]*b[0]+a[1]*b[1]
def area(a,b): return inp(a,a)*inp(b,b) - inp(a,b)
for line in sys.stdin:
[x1,y1,x2,y2,x3,y3,xp,yp] = [float(x) for x in line.split()]
ap = [x1-xp,y1-yp]
bp = [x2-xp,y2-yp]
cp = [x3-xp,y3-yp]
s = [x1-x2,y1-y2]
t = [x1-x3,y1-y3]
res = (area(s,t) >= (area(ap,bp) + area(ap,cp) + area(bp,cp)))
print area(s,t)
print area(ap,bp) + area(ap,cp) + area(bp,cp)
print "YES" if res else "NO" | 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
|
<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>
|
s580114225 | p00012 | Wrong Answer | import sys
def inp(a,b): return a[0]*b[0]+a[1]*b[1]
def area(a,b): return inp(a,a)*inp(b,b) - inp(a,b)
for line in sys.stdin:
[x1,y1,x2,y2,x3,y3,xp,yp] = [float(x) for x in line.split()]
ap = [x1-xp,y1-yp]
bp = [x2-xp,y2-yp]
cp = [x3-xp,y3-yp]
s = [x1-x2,y1-y2]
t = [x1-x3,y1-y3]
res = (area(s,t) >= (area(ap,bp) + area(ap,cp) + area(bp,cp)))
print "YES" if res else "NO" | 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
|
<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>
|
s107993430 | p00012 | Wrong Answer | while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split(' '))
a = [x1-xp,y1-yp]
b = [x2-xp,y2-yp]
c = [x3-xp,y3-yp]
j1 = a[0]*b[0]+a[1]*b[1]
j2 = b[0]*c[0]+b[1]*c[1]
j3 = a[0]*c[0]+a[1]*c[1]
j = [j1,j2,j3]
count = 0
for jug in j:
if jug < 0:
count += 1
if count >= 2:
print 'YES'
else:
print 'NO'
except EOFError:
break | 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
|
<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>
|
s338254150 | p00012 | Wrong Answer | # -*- coding: utf-8 -*-
import sys
def dist2(p1, p2):
return (p1[0] - p2[0])**2 + (p1[1] - p2[1])**2
def MinDistIdx(nodes, point):
Min = dist2(nodes[0], point)
idx = 0
if dist2(nodes[1], point) < Min:
Min = dist2(nodes[1], point)
idx = 1
if dist2(nodes[2], point) < Min:
Min = dist2(nodes[2], point)
idx = 2
return idx
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]]
idx = MinDistIdx(nodes, point)
distsum = [0, 0]
for i in xrange(3):
if i == idx: continue
distsum[0] += dist2(nodes[i], point)
distsum[1] += dist2(nodes[i], nodes[idx])
if distsum[0] < distsum[1]: print "YES"
else : print "NO"
| 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
|
<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>
|
s663260774 | p00012 | Wrong Answer | # -*- coding: utf-8 -*-
import sys
def dist2(p1, p2):
return ((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)**0.5
def MinDistIdx(nodes, point):
Min = dist2(nodes[0], point)
idx = 0
if dist2(nodes[1], point) < Min:
Min = dist2(nodes[1], point)
idx = 1
if dist2(nodes[2], point) < Min:
Min = dist2(nodes[2], point)
idx = 2
return idx
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]]
idx = MinDistIdx(nodes, point)
distsum = [0, 0]
for i in xrange(3):
if i == idx: continue
distsum[0] += dist2(nodes[i], point)
distsum[1] += dist2(nodes[i], nodes[idx])
if distsum[0] < distsum[1]: print "YES"
else : print "NO"
| 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
|
<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>
|
s702869745 | p00012 | Wrong Answer | while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp = map(float, raw_input().split())
a = (x1-x2)**2+(y1-y2)**2
b = (x1-x3)**2+(y1-y3)**2
c = (x2-x3)**2+(y2-y3)**2
xa = (x3-xp)**2+(y3-yp)**2
xb = (x2-xp)**2+(y2-yp)**2
xc = (x1-xp)**2+(y1-yp)**2
cosa = 2*math.sqrt(b)*math.sqrt(c)/(b+c)
cosb = 2*math.sqrt(a)*math.sqrt(c)/(a+c)
cosc = 2*math.sqrt(a)*math.sqrt(b)/(a+b)
cos1 = 2*math.sqrt(xa)*math.sqrt(b)/(xa+b)
cos2 = 2*math.sqrt(xb)*math.sqrt(c)/(xb+c)
cos3 = 2*math.sqrt(xc)*math.sqrt(a)/(xc+a)
if cos1<cosa or cos2<cosb or cos3<cosc:
print "YES"
else:
print "NO"
except:
break | 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
|
<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>
|
s035628886 | p00012 | Wrong Answer | while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp = map(float, raw_input().split())
a = (x1-x2)**2+(y1-y2)**2
b = (x1-x3)**2+(y1-y3)**2
c = (x2-x3)**2+(y2-y3)**2
xa = (x3-xp)**2+(y3-yp)**2
xb = (x2-xp)**2+(y2-yp)**2
xc = (x1-xp)**2+(y1-yp)**2
cosa = 2*math.sqrt(b)*math.sqrt(c)/(b+c)
cosb = 2*math.sqrt(a)*math.sqrt(c)/(a+c)
cosc = 2*math.sqrt(a)*math.sqrt(b)/(a+b)
cos1 = 2*math.sqrt(xa)*math.sqrt(b)/(xa+b)
cos2 = 2*math.sqrt(xb)*math.sqrt(c)/(xb+c)
cos3 = 2*math.sqrt(xc)*math.sqrt(a)/(xc+a)
cos4 = 2*math.sqrt(xa)*math.sqrt(c)/(xa+c)
cos5 = 2*math.sqrt(xb)*math.sqrt(a)/(xb+a)
cos6 = 2*math.sqrt(xc)*math.sqrt(b)/(xc+b)
if cos1<cosa or cos2<cosb or cos3<cosc:
print "YES"
elif cos4<cosa or cos5<cosb or cos6<cosc:
print "YES"
else:
print "NO"
except:
break | 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
|
<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>
|
s708719314 | p00012 | Wrong Answer | while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp = map(float, raw_input().split())
a = (x1-x2)**2+(y1-y2)**2
b = (x1-x3)**2+(y1-y3)**2
c = (x2-x3)**2+(y2-y3)**2
xa = (x3-xp)**2+(y3-yp)**2
xb = (x2-xp)**2+(y2-yp)**2
xc = (x1-xp)**2+(y1-yp)**2
cosa = (a-b+c)/(2*math.sqrt(b)*math.sqrt(c))
cosb = (b-a+c)/(2*math.sqrt(a)*math.sqrt(c))
cosc = (c-a+b)/(2*math.sqrt(a)*math.sqrt(b))
cos1 = (xc-xa+b)/(2*math.sqrt(xa)*math.sqrt(b))
cos2 = (xa-xb+c)/(2*math.sqrt(xb)*math.sqrt(c))
cos3 = (xb-xc+a)/(2*math.sqrt(xc)*math.sqrt(a))
if cos1<cosa or cos2<cosb or cos3<cosc:
print "YES"
else:
print "NO"
except:
break | 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
|
<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>
|
s264049539 | p00012 | Wrong Answer | while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp = map(float, raw_input().split())
a = (x1-x2)**2+(y1-y2)**2
b = (x1-x3)**2+(y1-y3)**2
c = (x2-x3)**2+(y2-y3)**2
xa = (x3-xp)**2+(y3-yp)**2
xb = (x2-xp)**2+(y2-yp)**2
xc = (x1-xp)**2+(y1-yp)**2
cosa = -(a-b+c)/(2*math.sqrt(b)*math.sqrt(c))
cosb = -(b-a+c)/(2*math.sqrt(a)*math.sqrt(c))
cosc = -(c-a+b)/(2*math.sqrt(a)*math.sqrt(b))
cos1 = -(xc-xa+b)/(2*math.sqrt(xa)*math.sqrt(b))
cos2 = -(xa-xb+c)/(2*math.sqrt(xb)*math.sqrt(c))
cos3 = -(xb-xc+a)/(2*math.sqrt(xc)*math.sqrt(a))
if cos1<cosa or cos2<cosb or cos3<cosc:
print "YES"
else:
print "NO"
except:
break | 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
|
<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>
|
s031560572 | p00012 | Wrong Answer | while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp = map(float, raw_input().split())
a = (x1-x2)**2+(y1-y2)**2
b = (x1-x3)**2+(y1-y3)**2
c = (x2-x3)**2+(y2-y3)**2
xa = (x3-xp)**2+(y3-yp)**2
xb = (x2-xp)**2+(y2-yp)**2
xc = (x1-xp)**2+(y1-yp)**2
cosa = -(a-b+c)/(2*math.sqrt(b)*math.sqrt(c))
cosb = -(b-a+c)/(2*math.sqrt(a)*math.sqrt(c))
cosc = -(c-a+b)/(2*math.sqrt(a)*math.sqrt(b))
cos1 = -(xc-xa+b)/(2*math.sqrt(xa)*math.sqrt(b))
cos2 = -(xa-xb+c)/(2*math.sqrt(xb)*math.sqrt(c))
cos3 = -(xb-xc+a)/(2*math.sqrt(xc)*math.sqrt(a))
if cos1<=cosa or cos2<=cosb or cos3<=cosc:
print "YES"
else:
print "NO"
except:
break | 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
|
<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>
|
s358604956 | p00012 | Wrong Answer | while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split())
l = [sorted([x1, x2, x3]), sorted([y1, y2, y3])]
if (xp > l[0][0]) and (xp < l[0][2]) and (yp > l[1][0]) and (yp <l[1][2]):
print "YES"
else:
print "NO"
except EOFError:
break | 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
|
<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>
|
s590239219 | p00012 | Wrong Answer | import math, sys
def length(x1, y1, x2, y2):
return math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
def area(x1, y1, x2, y2, x3, y3):
a = length(x1, y1, x2, y2)
b = length(x2, y2, x3, y3)
c = length(x3, y3, x1, y1)
s = (a + b + c)/2.0
return math.sqrt(s*(s - a)*(s - b)*(s - c))
for s in sys.stdin:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, s.split(' '))
s_all = area(x1, y1, x2, y2, x3, y3)
s1 = area(x1, y1, x2, y2, xp, yp)
s2 = area(x2, y2, x3, y3, xp, yp)
s3 = area(x3, y3, x1, y1, xp, yp)
if math.fabs(s_all - (s1 + s2 + s3)) <= 0.000000001:
print 'YES'
else:
print 'NO' | 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
|
<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>
|
s652839377 | p00012 | Wrong Answer | import math
def length(x1, y1, x2, y2):
return math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
def area(x1, y1, x2, y2, x3, y3):
a = length(x1, y1, x2, y2)
b = length(x2, y2, x3, y3)
c = length(x3, y3, x1, y1)
s = (a + b + c)/2.0
return math.sqrt(s*(s - a)*(s - b)*(s - c))
while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split(' '))
s_all = area(x1, y1, x2, y2, x3, y3)
s1 = area(x1, y1, x2, y2, xp, yp)
s2 = area(x2, y2, x3, y3, xp, yp)
s3 = area(x3, y3, x1, y1, xp, yp)
if math.fabs(s_all - (s1 + s2 + s3)) <= 0.000000001:
print 'YES'
else:
print 'NO'
except:
break | 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
|
<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>
|
s709558514 | p00012 | Wrong Answer | import math
def L(x1,y1,x2,y2):
return math.sqrt((x1-x2)**2+(y1-y2)**2)
def S(a,b,c):
s=(a+b+c)/2
return math.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 = L(x1, y1, x2, y2)
b = L(x2, y2, x3, y3)
c = L(x3, y3, x1, y1)
p1 = L(x1, y1, xp, yp)
p2 = L(x2, y2, xp, yp)
p3 = L(x3, y3, xp, yp)
if S(a,b,p1)+S(b,c,p2)+S(c,a,p3) - S(a,b,c) > 0.00001:
print "NO"
else:
print "YES"
except:
break | 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
|
<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>
|
s778192271 | p00012 | Time Limit Exceeded | while True:
try:
x1,y1,x2,y2,x3,y3,xp,yp=map(float,input().split())
if xp<0 or yp<0:
print('No')
else:
print('Yes')
except: pass | 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
|
<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>
|
s316939428 | p00012 | Accepted | 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()
| 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
|
<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>
|
s780464984 | p00012 | Accepted | # -*- 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") | 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
|
<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>
|
s998084633 | p00012 | Accepted | 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 | 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
|
<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>
|
s482319853 | p00012 | Accepted | 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))] | 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
|
<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>
|
s588862989 | p00012 | Accepted | 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))] | 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
|
<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>
|
s828433173 | p00012 | Accepted | #!/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"
| 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
|
<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>
|
s426844946 | p00012 | Accepted | 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 | 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
|
<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>
|
s768883549 | p00012 | Accepted | 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 | 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
|
<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>
|
s076235194 | p00012 | Accepted | 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') | 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
|
<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>
|
s853935513 | p00012 | Accepted | 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' | 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
|
<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>
|
s118730724 | p00012 | Accepted | 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' | 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
|
<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>
|
s481792042 | p00012 | Accepted | # 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 | 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
|
<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>
|
s920877240 | p00012 | Accepted | 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" | 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
|
<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>
|
s529335989 | p00012 | Accepted | 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" | 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
|
<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>
|
s945368892 | p00012 | Accepted | 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)] | 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
|
<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>
|
s702162953 | p00012 | Accepted | #!/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") | 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
|
<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>
|
s182523455 | p00012 | Accepted | 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 | 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
|
<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>
|
s272022408 | p00012 | Accepted | # -*- 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() | 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
|
<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>
|
s381603833 | p00012 | Accepted | 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 | 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
|
<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>
|
s749966678 | p00012 | Accepted | 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 | 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
|
<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>
|
s601258296 | p00012 | Accepted | 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') | 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
|
<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>
|
s764194900 | p00012 | Accepted | #! -*- 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" | 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
|
<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>
|
s094875621 | p00012 | Accepted | 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))) | 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
|
<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>
|
s083674776 | p00012 | Accepted | 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') | 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
|
<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>
|
s625963679 | p00012 | Accepted | # -*- 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" | 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
|
<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>
|
s032965930 | p00012 | Accepted | 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')
| 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
|
<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>
|
s020511566 | p00012 | Accepted | 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 | 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
|
<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>
|
s113902479 | p00012 | Accepted | 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 | 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
|
<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>
|
s886649777 | p00012 | Accepted | 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) | 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
|
<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>
|
s011842495 | p00012 | Accepted | 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 | 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
|
<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>
|
s420736150 | p00012 | Accepted | 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') | 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
|
<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>
|
s786290216 | p00012 | Accepted | 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 | 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
|
<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>
|
s841001928 | p00012 | Accepted | 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") | 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
|
<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>
|
s237605038 | p00012 | Accepted | 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' | 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
|
<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>
|
s910359525 | p00012 | Accepted | 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 | 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
|
<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>
|
s003777334 | p00012 | Accepted | 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") | 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
|
<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>
|
s710258224 | p00012 | Accepted | 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") | 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
|
<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>
|
s732955672 | p00012 | Accepted | 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])) | 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
|
<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>
|
s382661667 | p00012 | Accepted | 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]) | 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
|
<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>
|
s480418066 | p00012 | Accepted | 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") | 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
|
<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>
|
s222475124 | p00012 | Accepted | 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") | 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
|
<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>
|
s395523189 | p00012 | Accepted | 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") | 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
|
<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>
|
s745883357 | p00012 | Accepted | 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') | 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
|
<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>
|
s903089408 | p00012 | Accepted | # -*- 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') | 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
|
<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>
|
s610403554 | p00012 | Accepted | 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") | 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
|
<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>
|
s355068457 | p00012 | Accepted |
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;
| 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
|
<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>
|
s584660784 | p00012 | Accepted | 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") | 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
|
<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>
|
s018916528 | p00012 | Accepted | 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()
| 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
|
<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>
|
s273927679 | p00012 | Accepted | 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") | 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
|
<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>
|
s353144649 | p00012 | Accepted | 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") | 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
|
<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>
|
s217698437 | p00012 | Accepted | # 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") | 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
|
<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>
|
s056290696 | p00012 | Accepted | # -*- 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:]) | 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
|
<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>
|
s433291122 | p00012 | Accepted | 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 | 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
|
<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>
|
s408606953 | p00012 | Accepted | 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") | 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
|
<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>
|
s498197477 | p00012 | Accepted | # 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') | 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
|
<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>
|
s167547808 | p00012 | Accepted | 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() | 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
|
<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>
|
s497159158 | p00012 | Accepted | 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")
| 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
|
<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>
|
s544729804 | p00012 | Accepted | 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
| 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
|
<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>
|
s931783267 | p00012 | Accepted | 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
| 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
|
<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>
|
s086670847 | p00012 | Accepted | # 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
| 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
|
<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>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.