submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s803969326
p00012
Accepted
while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) except: break AB = [x2-x1, y2-y1] BC = [x3-x2, y3-y2] CA = [x1-x3, y1-y3] BP = [xp-x2, yp-y2] CP = [xp-x3, yp-y3] AP = [xp-x1, yp-y1] v1 = AB[0]*BP[1]-AB[1]*BP[0] v2 = BC[0]*CP[1]-BC[1]*CP[0] v3 = CA[0]*AP[1]-CA[1]*AP[0] print(["NO", "YES"][(v1<0 and v2<0 and v3<0) or (v1>0 and v2>0 and v3>0)])
0.0 0.0 2.0 0.0 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>
s908730113
p00012
Accepted
import sys for e in sys.stdin: p,q,r,s,t,u,x,y=map(float,e.split()) f=lambda h,i,j,k:(h-p)*(i-q)-(j-q)*(k-p) a,b=f(x,u,y,t)/f(r,u,s,t),f(x,s,y,r)/f(t,s,u,r) print(['NO','YES'][0<a<1-b and 0<b<1-a])
0.0 0.0 2.0 0.0 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>
s011966953
p00012
Accepted
import sys def f(h,i,j,k): z=(j-h)*(y-k)-(k-i)*(x-j);return([-1,1][z>0],0)[z==0] for e in sys.stdin: p,q,r,s,t,u,x,y=map(float,e.split()) a,b,c=f(p,q,r,s),f(r,s,t,u),f(t,u,p,q) print(['NO','YES'][a==b==c])
0.0 0.0 2.0 0.0 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>
s127391037
p00012
Accepted
import sys def f(h,i,j,k): z=(j-h)*(y-k)-(k-i)*(x-j);return([-1,1][z>0],0)[z==0] for e in sys.stdin: p,q,r,s,t,u,x,y=map(float,e.split()) g=[p,q,r,s,t,u] print(['NO','YES'][f(*g[:4])==f(*g[2:6])==f(*g[4:],*g[:2])])
0.0 0.0 2.0 0.0 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>
s126693480
p00012
Accepted
import sys def f(h,i,j,k): z=(j-h)*(y-k)-(k-i)*(x-j);return([-1,1][z>0],0)[z==0] for e in sys.stdin: p,q,r,s,t,u,x,y=map(float,e.split()) print(['NO','YES'][f(p,q,r,s)==f(r,s,t,u)==f(t,u,p,q)])
0.0 0.0 2.0 0.0 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>
s698503008
p00012
Accepted
import sys def f(h,i,j,k):z=(j-h)*(y-k)-(k-i)*(x-j);return([-1,1][z>0],0)[z==0] for e in sys.stdin: p,q,r,s,t,u,x,y=map(float,e.split()) print(['NO','YES'][f(p,q,r,s)==f(r,s,t,u)==f(t,u,p,q)])
0.0 0.0 2.0 0.0 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>
s813099930
p00012
Accepted
import sys def f(a,b,c,d):z=(c-a)*(y-d)-(d-b)*(x-c);return([-1,1][z>0],0)[z==0] for e in sys.stdin: p,q,r,s,t,u,x,y=map(float,e.split()) print(['NO','YES'][f(p,q,r,s)==f(r,s,t,u)==f(t,u,p,q)])
0.0 0.0 2.0 0.0 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>
s946444748
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>
s126241024
p00012
Accepted
g=lambda a,b,c:(a[0]-b[0])*(b[1]-c[1])-(b[0]-c[0])*(a[1]-b[1]) while True: try:t=input() except:break l=[float(i) for i in t.split()] b=[g(l[0:2],l[2:4],l[6:8]),g(l[2:4],l[4:6],l[6:8]),g(l[4:6],l[0:2],l[6:8])] if len([i for i in b if i>0])==3 or len([i for i in b if i<0])==3: print("YES") else: print("NO")
0.0 0.0 2.0 0.0 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>
s519282064
p00012
Accepted
import sys def f(a,b,c,d):z=(c-a)*(y-d)-(d-b)*(x-c);return[-1*(z==0),1][z>0] for e in sys.stdin: p,q,r,s,t,u,x,y=map(float,e.split()) print(['NO','YES'][f(p,q,r,s)==f(r,s,t,u)==f(t,u,p,q)])
0.0 0.0 2.0 0.0 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>
s123124583
p00012
Accepted
import sys def calc(x, y, xp, yp): a = [(y[i] - y[i -1]) * (xp - x[i]) - (x[i] - x[i - 1]) * (yp - y[i]) for i in range(3)] print("YES" if (a[0] > 0 and a[1] > 0 and a[2] > 0) or (a[0] < 0 and a[1] < 0 and a[2] < 0) else "NO") for s in sys.stdin: x1, y1, x2, y2, x3, y3, xp, yp = map(float, s.split()) x = [x1, x2, x3] y = [y1, y2, y3] calc(x, y, xp, yp)
0.0 0.0 2.0 0.0 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>
s851826989
p00012
Accepted
import sys def cross_product(a, b): ax, ay = a bx, by = b return ax * by - ay * bx def sub(a, b): a1, a2 = a b1, b2 = b return b1 - a1, b2 - a2 def judge(p1, p2, p3, pp): cnt = 0 for a, b in ((p1, p2), (p2, p3), (p3, p1)): vec1 = sub(a, b) vec2 = sub(a, pp) if cross_product(vec2, vec1) > 0: cnt += 1 if cnt == 0 or cnt == 3: print("YES") else: print("NO") if __name__ == '__main__': for line in sys.stdin: inputs = [float(s) for s in line.split()] p1 = (inputs.pop(0), inputs.pop(0)) p2 = (inputs.pop(0), inputs.pop(0)) p3 = (inputs.pop(0), inputs.pop(0)) pp = (inputs.pop(0), inputs.pop(0)) judge(p1, p2, p3, pp)
0.0 0.0 2.0 0.0 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>
s521204924
p00012
Accepted
import math class Point(): def __init__(self, x, y): self.x = x self.y = y def CP(p1, p2, p3): ax = p2.x-p1.x ay = p2.y-p1.y bx = p3.x-p1.x by = p3.y-p1.y return ax*by - ay*bx def Judge(a,b,c): if a > 0 and b > 0 and c > 0: print("YES") elif a < 0 and b < 0 and c < 0: print("YES") else: print("NO") def get_input(): while True: try: yield ''.join(input()) except EOFError: break N = list(get_input()) for l in range(len(N)): x1,y1,x2,y2,x3,y3,xp,yp = [float(i) for i in N[l].split()] P1 = Point(x1,y1) P2 = Point(x2,y2) P3 = Point(x3,y3) PP = Point(xp,yp) cp1 = CP(PP, P1, P2) cp2 = CP(PP, P2, P3) cp3 = CP(PP, P3, P1) Judge(cp1,cp2,cp3)
0.0 0.0 2.0 0.0 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>
s962841902
p00012
Accepted
def f(x): x1, y1, x2, y2, x3, y3, xp, yp = x ax = x3 - x1 ay = y3 - y1 bx = x2 - x1 by = y2 - y1 xp -= x1 yp -= y1 k = (by * xp - bx * yp) / (ax * by - ay * bx) l = (ay * xp - ax * yp) / (ay * bx - ax * by) if (k > 0 and l > 0 and k + l < 1): print('YES') else: print('NO') while True: try: point = list(map(float, input().split())) f(point) except EOFError: break
0.0 0.0 2.0 0.0 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>
s673714708
p00012
Accepted
# AOJ 0012 A Point in a Triangle # Python3 2018.6.17 bal4u EPS = 0.0001 # a, b, はラインの同一側にあるか def is_atSameSide(a, b, line): sa = (line[1].real-line[0].real)*(a.imag-line[0].imag) \ + (line[1].imag-line[0].imag)*(line[0].real-a.real); sb = (line[1].real-line[0].real)*(b.imag-line[0].imag) \ + (line[1].imag-line[0].imag)*(line[0].real-b.real); if -EPS <= sa and sa <= EPS: return False # a in line if -EPS <= sb and sb <= EPS: return False # b in line if sa*sb >= 0: return True # a,b at same side return False # -1; while True: try: p = list(map(float, input().split())) except: break p1 = complex(p[0], p[1]) p2 = complex(p[2], p[3]) p3 = complex(p[4], p[5]) pp = complex(p[6], p[7]) if is_atSameSide(p3, pp, [p1,p2]) and \ is_atSameSide(p1, pp, [p2,p3]) and \ is_atSameSide(p2, pp, [p3,p1]): print('YES') else: print('NO')
0.0 0.0 2.0 0.0 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>
s394391868
p00012
Accepted
def vec(s,t): return [t[0]-s[0], t[1]-s[1]] def area(a,b): return a[0]*b[1] - a[1]*b[0] while True: try: l = [float(x) for x in input().split()] a = [l[0],l[1]] b = [l[2],l[3]] c = [l[4],l[5]] p = [l[6],l[7]] x = area(vec(p,a),vec(p,b)) y = area(vec(p,b),vec(p,c)) z = area(vec(p,c),vec(p,a)) if (x<0 and y<0 and z<0) or (x>0 and y>0 and z>0): print('YES') else: print('NO') except: break
0.0 0.0 2.0 0.0 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>
s074741759
p00012
Accepted
import math PI = math.pi EPS = 10**-10 def edge(a, b): return ((a[0]-b[0])**2+(a[1]-b[1])**2)**.5 def area(a, b, c): s = (a+b+c)/2 return (s*(s-a)*(s-b)*(s-c))**.5 def LawOfCosines(a, b, c): #余弦定理 return math.acos( (b*b+c*c-a*a) / (2.0*b*c) ); def is_same(x, y): return abs(x-y) < EPS class Triangle: def __init__(self, p): a, b, c = p self.a = a self.b = b self.c = c self.edgeA = edge(b, c) self.edgeB = edge(c, a) self.edgeC = edge(a, b) self.area = area(self.edgeA, self.edgeB, self.edgeC) self.angleA = LawOfCosines(self.edgeA, self.edgeB, self.edgeC) self.angleB = LawOfCosines(self.edgeB, self.edgeC, self.edgeA) self.angleC = LawOfCosines(self.edgeC, self.edgeA, self.edgeB) def circumscribeadCircleRadius(self): #外接円の半径を返す return self.edgeA / math.sin(self.angleA) / 2.0 def circumscribedCircleCenter(self): #外接円の中心の座標を返す a = math.sin(2.0*self.angleA); b = math.sin(2.0*self.angleB); c = math.sin(2.0*self.angleC); X = (self.a[0] * a + self.b[0] * b + self.c[0] * c) / (a+b+c); Y = (self.a[1] * a + self.b[1] * b + self.c[1] * c) / (a+b+c); return X, Y def inscribedCircleRadius(self): #内接円の半径 return 2 * self.area / (self.edgeA + self.edgeB + self.edgeC) def inscribedCircleCenter(self): #内接円の中心の座標 points = [self.a, self.b, self.c] edges = [self.edgeA, self.edgeB, self.edgeC] s = sum(edges) return [sum([points[j][i]*edges[j] for j in range(3)])/s for i in range(2)] def isInner(self, p): #点が三角形の内側か判定 cross = lambda a, b: a[0]*b[1]-a[1]*b[0] c1 = 0 c2 = 0 points = [self.a, self.b, self.c] for i in range(3): a = [points[i][0]-points[(i+1)%3][0], points[i][1]-points[(i+1)%3][1]] b = [points[i][0]-p[0], points[i][1]-p[1]] c = cross(a, b) if c > 0: c1 += 1 elif c < 0: c2 += 1 if c1 == 3 or c2 == 3: return True else: return c1+c2 != 3 and (c1 == 0 or c2 == 0) if __name__ == "__main__": while True: try: c = list(map(float, input().split())) points = [(c[i], c[i+1]) for i in range(0, 6, 2)] point = [c[6], c[7]] t = Triangle(points) print(["NO","YES"][t.isInner(point)]) except: break
0.0 0.0 2.0 0.0 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>
s969663379
p00012
Accepted
import sys def cross(a, b): return (a.conjugate() * b).imag def dot(a, b): return (a.conjugate() * b).real def ccw(a, b, c): x = b - a y = c - a; if cross(x, y) > 0: return 1 if cross(x, y) < 0: return -1 if dot(x, y) < 0: return 2 if abs(x) < abs(y): return -2 return 0 def solve(l, p): x = ccw(l[0][0], l[0][1], p) if x == 0: x = 1 else: x = int(x / abs(x)) for i in l[1:]: y = ccw(i[0], i[1], p) if y == 0: y = 1 else: y = int(y / abs(y)) if x != y: print "NO" return print "YES" for line in sys.stdin: try: ax, ay, bx, by, cx, cy, px, py = map(float, line.split()) except ValueError: sys.exit(0) a = complex(ax, ay) b = complex(bx, by) c = complex(cx, cy) p = complex(px, py) solve([(a, b), (b, c), (c, a)], p)
0.0 0.0 2.0 0.0 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>
s790347556
p00012
Accepted
import sys def cross(a, b): return (a.conjugate() * b).imag def dot(a, b): return (a.conjugate() * b).real def ccw(a, b, c): x = b - a y = c - a; cr = cross(x, y) if cr != 0: return cr if dot(x, y) < 0: return 2 if abs(x) < abs(y): return -2 return 0 def solve(l, p): x = cmp(ccw(l[0][0], l[0][1], p), 0) if any([x != cmp(ccw(i[0], i[1], p), 0) for i in l[1:]]): print "NO" else: print "YES" for line in sys.stdin: t = map(float, line.split()) if len(t) == 0: continue a, b, c, p = map(lambda x, y: complex(x, y), t[0::2], t[1::2]) solve([(a, b), (b, c), (c, a)], p)
0.0 0.0 2.0 0.0 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>
s038693780
p00012
Accepted
import sys def cross(a, b): return (a.conjugate() * b).imag def dot(a, b): return (a.conjugate() * b).real def ccw(a, b, c): x = b - a y = c - a; cr = cross(x, y) if cr != 0: return cr if dot(x, y) < 0: return 2 if abs(x) < abs(y): return -2 return 0 def solve(l, p): x = cmp(ccw(l[0][0], l[0][1], p), 0) if all(cmp(ccw(i[0], i[1], p), 0) == x for i in l[1:]): print "YES" else: print "NO" for line in sys.stdin: t = map(float, line.split()) if len(t) == 0: continue a, b, c, p = map(complex, t[0::2], t[1::2]) solve([(a, b), (b, c), (c, a)], p)
0.0 0.0 2.0 0.0 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>
s315807957
p00012
Accepted
import sys def cross(a, b): return (a.conjugate() * b).imag def dot(a, b): return (a.conjugate() * b).real def ccw(a, b, c): x = b - a y = c - a; cr = cross(x, y) if cr != 0: return cr if dot(x, y) < 0: return 2 if abs(x) < abs(y): return -2 return 0 for line in sys.stdin: t = map(float, line.split()) if len(t) == 0: continue a, b, c, p = map(complex, t[0::2], t[1::2]) l = [(a, b), (b, c), (c, a)] x = cmp(ccw(l[0][0], l[0][1], p), 0) if all(cmp(ccw(i[0], i[1], p), 0) == x for i in l[1:]): print "YES" else: print "NO"
0.0 0.0 2.0 0.0 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>
s397190043
p00012
Accepted
import sys for line in sys.stdin.readlines(): try: list=map(float,line.split()) x=list[0:6:2] y=list[1:6:2] xp=list[6] yp=list[7] xv=[x[a%3]-x[(a+1)%3] for a in xrange(4)] yv=[y[a%3]-y[(a+1)%3] for a in xrange(4)] xpv=[xp-x[a] for a in xrange(3)] ypv=[yp-y[a] for a in xrange(3)] cross=[xv[i]*ypv[i]-yv[i]*xpv[i] for i in xrange(3)] if (cross[2]>0 and cross[1]>0 and cross[0]>0) or (cross[2]<0 and cross[1]<0 and cross[0]<0): print "YES" else: print "NO" except: pass #temp
0.0 0.0 2.0 0.0 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>
s829678721
p00012
Accepted
def dot(a, b): return (a.real*b.real - a.imag*b.imag) def cross(a, b): return (a.real*b.imag - a.imag*b.real) EPS = 10**(-7) def isIntersectedLS(a1, a2, b1, b2): return ((cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1)) < EPS and (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1)) < EPS) while 1: try: x,y = [[0. for i in xrange(3)] for j in xrange(2)] a = [] z = [0. for i in xrange(2)] line = raw_input().split() if line == []: break x[0],y[0],x[1],y[1],x[2],y[2],z[0],z[1] = map(float, line) for i in xrange(3): a.append((x[i]+(y[i])*1j)) c = (sum(x)/3)+(sum(y)/3)*1j p = z[0]+z[1]*1j for i in xrange(3): #print a, c, p if isIntersectedLS(a[i-1], a[i], c, p) is True: print "NO" break else: print "YES" except EOFError: break
0.0 0.0 2.0 0.0 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>
s147811686
p00012
Accepted
class Point: def __init__(self, x, y): self.x = x self.y = y class DirectedSegment: def __init__(self, s, e): self.start = s self.end = e LEFT = -1 ONLINE = 0 RIGHT = 1 def datasets(): import sys while True: s = sys.stdin.readline() if len(s) < 2: break x1, y1, x2, y2, x3, y3, xp, yp = [float(d) for d in s.split()] p1 = Point(x1, y1) p2 = Point(x2, y2) p3 = Point(x3, y3) x = Point(xp,yp) yield p1, p2, p3, x def side(ds, p): return cmp(p.x * (ds.start.y - ds.end.y) + ds.start.x * (ds.end.y - p.y) + ds.end.x * (p.y - ds.start.y), 0) for p1, p2, p3, x in datasets(): r = [ side(DirectedSegment(p1, p2), x), side(DirectedSegment(p2, p3), x), side(DirectedSegment(p3, p1), x) ] if all(0 < n for n in r) or all(0 > n for n in r): print "YES" else: print "NO"
0.0 0.0 2.0 0.0 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>
s039284885
p00012
Accepted
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>
s279598691
p00012
Accepted
if __name__ == '__main__': while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split()) r = 0 vec = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1) if vec > 0: r += 1 elif vec < 0: r -= 1 vec = (x3 - x2) * (yp - y2) - (y3 - y2) * (xp - x2) if vec > 0: r += 1 elif vec < 0: r -= 1 vec = (x1 - x3) * (yp - y3) - (y1 - y3) * (xp - x3) if vec > 0: r += 1 elif vec < 0: r -= 1 if r == 3 or r == -3: print("YES") else: print("NO") except EOFError: break
0.0 0.0 2.0 0.0 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>
s964238381
p00012
Accepted
def checker(x1,y1,x2,y2,xp,yp): r = 0 vec = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1) if vec > 0: r = 1 elif vec < 0: r = -1 return r if __name__ == '__main__': while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split()) r = 0 r += int(checker(x1,y1,x2,y2,xp,yp)) r += int(checker(x2, y2, x3, y3, xp, yp)) r += int(checker(x3, y3, x1, y1, xp, yp)) if r == 3 or r == -3: print("YES") else: print("NO") except EOFError: break
0.0 0.0 2.0 0.0 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>
s736380858
p00012
Accepted
from __future__ import (division, absolute_import, print_function, unicode_literals) from sys import stdin from operator import attrgetter from collections import namedtuple Point = namedtuple('Point', 'x y') def linear(p1, p2): gradient = (p1.y - p2.y) / (p1.x - p2.x) y_intercept = p1.y - gradient * p1.x return lambda x: gradient * x + y_intercept def takeout(seq): gen = (Point(next(seq), next(seq)) for _ in xrange(3)) for p in sorted(gen, key=attrgetter('x')): yield p yield Point(next(seq), next(seq)) for line in stdin: A, B, C, P = takeout(float(s) for s in line.split()) assert A.x <= B.x <= C.x if P.x <= A.x or C.x <= P.x: print('NO') continue if A.x == B.x or B.x <= P.x <= C.x: L = (linear(B, C), linear(A, C)) elif B.x == C.x or A.x <= P.x <= B.x: L = (linear(A, B), linear(A, C)) else: print('NO') continue y1, y2 = sorted(f(P.x) for f in L) if y1 < P.y < y2: print('YES') else: print('NO')
0.0 0.0 2.0 0.0 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>
s414463478
p00012
Accepted
from math import sqrt dis = lambda x1,y1,x2,y2: sqrt((x1-x2)**2+(y1-y2)**2) def heron(a,b,c): s = (a+b+c)*1.0/2 return sqrt(s*(s-a)*(s-b)*(s-c)) while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split()) a,b,c = dis(x1,y1,x2,y2),dis(x1,y1,x3,y3),dis(x3,y3,x2,y2) d,e,f = dis(x1,y1,xp,yp),dis(xp,yp,x2,y2),dis(xp,yp,x3,y3) AnsS = heron(a,b,c) FakS = heron(a,e,d)+heron(e,c,f)+heron(d,b,f) q1,q2 = str(AnsS),str(FakS) Ans = "YES" if q1 == q2 else "NO" print Ans except EOFError: break
0.0 0.0 2.0 0.0 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>
s633668595
p00012
Accepted
import sys class Point: def __init__(self, x, y): self.x = x self.y = y def direction_of_rotation(p1, p2, p3): d = p1.x * (p2.y - p3.y) + p2.x * (p3.y - p1.y) + p3.x * (p1.y - p2.y) if d < 0: direction = 'right' else: direction = 'left' return direction #input_file = open(sys.argv[1], "r") #for line in input_file: for line in sys.stdin: a = map((lambda x: float(x)), line.split(' ')) p1 = Point(a[0], a[1]) p2 = Point(a[2], a[3]) p3 = Point(a[4], a[5]) p = Point(a[6], a[7]) d1 = direction_of_rotation(p, p1, p2) d2 = direction_of_rotation(p, p2, p3) d3 = direction_of_rotation(p, p3, p1) if d1 == d2 and d1 == d3: print "YES" else: print "NO"
0.0 0.0 2.0 0.0 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>
s868866965
p00012
Accepted
import sys class Point(object): def __init__(self, x, y): self.x = x self.y = y def isLeft(self, vector): tmpVector = DirectedVector(vector.start, self) sin = tmpVector * vector if sin > 0: return True else: return False class DirectedVector(object): def __init__(self, start, end): self.start = start self.end = end @property def x(self): return self.end.x - self.start.x @property def y(self): return self.end.y - self.start.y def __mul__(self, other): return self.x * other.y - self.y * other.x def getDataSets(): for line in sys.stdin.readlines(): line = line.strip() x1, y1, x2, y2, x3, y3, xp, yp = [float(x) for x in line.split()] p1 = Point(x1, y1) p2 = Point(x2, y2) p3 = Point(x3, y3) px = Point(xp, yp) yield p1, p2, p3, px def main(): for p1, p2, p3, px in getDataSets(): evaluate = [ px.isLeft(DirectedVector(p1, p2)), px.isLeft(DirectedVector(p2, p3)), px.isLeft(DirectedVector(p3, p1)), ] if(all(evaluate) or not any(evaluate)): print 'YES' else: print 'NO' if __name__ == "__main__": main()
0.0 0.0 2.0 0.0 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>
s483489160
p00012
Accepted
def side(p1, p2, p3): return (p3[1]-p1[1])*(p2[0]-p1[0])-(p2[1]-p1[1])*(p3[0]-p1[0])>0 while True: try: x = map(float, raw_input().split()) p1 = x[0:2] p2 = x[2:4] p3 = x[4:6] p0 = x[6:] if (side(p1, p2, p0)==side(p2, p3, p0) and side(p2, p3, p0)==side(p3, p1, p0)): print "YES" else: print "NO" except: break
0.0 0.0 2.0 0.0 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>
s104570478
p00012
Accepted
while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split()) r = 0 vec = (x2-x1) * (yp-y1) - (y2-y1) * (xp-x1) if vec > 0: r += 1 elif vec < 0: r -= 1 vec = (x3-x2) * (yp-y2) - (y3-y2) * (xp-x2) if vec > 0: r += 1 elif vec < 0: r -= 1 vec = (x1-x3) * (yp-y3) - (y1-y3) * (xp-x3) if vec > 0: r += 1 elif vec < 0: r -= 1 if r == 3 or r == -3: print("YES") else: print("NO") except EOFError: break
0.0 0.0 2.0 0.0 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>
s298954151
p00012
Accepted
# -*- coding: utf-8 -*- import sys def prod2d(vec1, vec2): return vec1[0]*vec2[1] - vec1[1]*vec2[0] lineNumber = 0 #for line in [ "0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5", "0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0"]: for line in sys.stdin.readlines(): lineNumber += 1 # get data List = map(float, line.strip().split()) # set data nodes = [ [List[0], List[1]], [List[2], List[3]], [List[4], List[5]] ] point = [List[6], List[7]] ABvec = [ nodes[1][0] - nodes[0][0], nodes[1][1] - nodes[0][1] ] BCvec = [ nodes[2][0] - nodes[1][0], nodes[2][1] - nodes[1][1] ] CAvec = [ nodes[0][0] - nodes[2][0], nodes[0][1] - nodes[2][1] ] APvec = [ point[0] - nodes[0][0], point[1] - nodes[0][1] ] BPvec = [ point[0] - nodes[1][0], point[1] - nodes[1][1] ] CPvec = [ point[0] - nodes[2][0], point[1] - nodes[2][1] ] a = prod2d(CAvec, APvec) b = prod2d(ABvec, BPvec) c = prod2d(BCvec, CPvec) if a > 0 and b > 0 and c > 0: print "YES" elif a < 0 and b < 0 and c < 0: print "YES" else : print "NO"
0.0 0.0 2.0 0.0 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>
s083344752
p00012
Accepted
import math while True: try: x1,y1,x2,y2,x3,y3,xp,yp = map(float, raw_input().split()) a = math.sqrt((x1-x2)**2+(y1-y2)**2) b = math.sqrt((x1-x3)**2+(y1-y3)**2) c = math.sqrt((x2-x3)**2+(y2-y3)**2) xa = math.sqrt((x3-xp)**2+(y3-yp)**2) xb = math.sqrt((x2-xp)**2+(y2-yp)**2) xc = math.sqrt((x1-xp)**2+(y1-yp)**2) s = (a+b+c)/2 sa = (a+xb+xc)/2 sb = (b+xa+xc)/2 sc = (c+xa+xb)/2 ss = math.sqrt(s*(s-a)*(s-b)*(s-c)) ssa = math.sqrt(sa*(sa-a)*(sa-xb)*(sa-xc)) ssb = math.sqrt(sb*(sb-xa)*(sb-b)*(sb-xc)) ssc = math.sqrt(sc*(sc-xa)*(sc-xb)*(sc-c)) if ssa+ssb+ssc - ss > 0.0000001: print "NO" else: print "YES" except: break
0.0 0.0 2.0 0.0 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>
s211682068
p00012
Accepted
import math 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 = math.sqrt((x1-x2)**2+(y1-y2)**2) b = math.sqrt((x1-x3)**2+(y1-y3)**2) c = math.sqrt((x2-x3)**2+(y2-y3)**2) xa = math.sqrt((x3-xp)**2+(y3-yp)**2) xb = math.sqrt((x2-xp)**2+(y2-yp)**2) xc = math.sqrt((x1-xp)**2+(y1-yp)**2) if S(a,xb,xc)+S(b,xc,xa)+S(c,xa,xb)-S(a,b,c) > 0.0000001: 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>
s615569987
p00012
Accepted
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(x1,y1,x3,y3) c = L(x2,y2,x3,y3) pa = L(x3,y3,xp,yp) pb = L(x2,y2,xp,yp) pc = L(x1,y1,xp,yp) if S(a,pb,pc)+S(b,pc,pa)+S(c,pa,pb)-S(a,b,c) > 0.0000001: 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>
s024195591
p00012
Accepted
import sys def c(x1, y1, x2, y2, x, y): return (y2 - y1)*(x - x1) - (x2 - x1)*(y - y1) for str in sys.stdin: x1,y1,x2,y2,x3,y3,xp,yp = map(float, str.split(' ')) gx, gy = (x1 + x2 + x3)/3, (y1 + y2 + y3)/3 r1 = c(x1, y1, x2, y2, gx, gy)*c(x1, y1, x2, y2, xp, yp) > 0 r2 = c(x2, y2, x3, y3, gx, gy)*c(x2, y2, x3, y3, xp, yp) > 0 r3 = c(x3, y3, x1, y1, gx, gy)*c(x3, y3, x1, y1, xp, yp) > 0 print 'YES' if r1 and r2 and r3 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>
s245184305
p00012
Accepted
while 1: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split()) except EOFError: break Points = [(x1, y1), (x2, y2), (x3, y3)] for i in xrange(3): A = Points[i] B = Points[(i + 1) % 3] C = Points[(i + 2) % 3] if A[0] - B[0] == 0: mark1 = C[0] - A[0] mark2 = xp - A[0] else: a = (A[1] - B[1]) / (A[0] - B[0]) b = A[1] - a * A[0] mark1 = C[1] - (a * C[0] + b) mark2 = yp - (a * xp + b) if not ((mark1 >= 0 and mark2 >= 0) or (mark1 <= 0 and mark2 <= 0)): print "NO" break 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>
s098119548
p00012
Accepted
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(x1,y1,x3,y3) c = L(x2,y2,x3,y3) pa = L(x3,y3,xp,yp) pb = L(x2,y2,xp,yp) pc = L(x1,y1,xp,yp) if S(a,pb,pc)+S(b,pc,pa)+S(c,pa,pb)-S(a,b,c) > 0.0000001: 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>
s857559103
p00012
Accepted
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(x1, y1, x3, y3) c = L(x2, y2, x3, y3) p1 = L(x1, y1, xp, yp) p2 = L(x2, y2, xp, yp) p3 = L(x3, y3, xp, yp) if S(a, p2, p1)+S(b, p1, p3)+S(c, p3, p2)-S(a, b, c) > 0.0000001: 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>
s421233703
p00012
Accepted
# 2点(a, b) (c, d)を通る直線の傾きと切片を返す def func(a, b, c, d): k = (d - b) / (c - a) h = d - k * c return k, h # 2点と通る直線のf(x)を返す def fx(a, b, c, d, x): k, h = func(a, b, c, d) return k * x + h def main(): import sys for dataset in sys.stdin: ans = 'NO' try : a, b, c, d, e, f, px, py = map(float, dataset.split()) except: break T = [(a, b), (c, d), (e, f)] T.sort(key=lambda x: (x[0], x[1])) a, b, c, d, e, f = T[0][0], T[0][1], T[1][0], T[1][1], T[2][0], T[2][1] # 共通なxを持つ2点が存在するか判定し、する場合 if a == c: if a < px and fx(a, b, e, f, px) < py and fx(c, d, e, f, px) > py: ans = 'YES' elif c == e: if px < e and fx(a, b, c, d, px) < py and fx(a, b, e, f, px) > py: ans = 'YES' else: # 3点において共通のxを持たない場合 if fx(a, b, e, f, c) < d: # 中間点が残り2点を通る直線より上にあるケース if fx(a, b, c, d, px) > py and fx(c, d, e, f, px) > py and fx(a, b, e, f, px) < py: ans = 'YES' else: if fx(a, b, c, d, px) < py and fx(c, d, e, f, px) < py and fx(a, b, e, f, px) > py: ans = 'YES' print(ans) 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>
s820613274
p00012
Accepted
def cross_product(a,b):#a,bは複素数、だけどベクトル扱いしよう return (a.conjugate()*b).imag def abs_area_vector(ax,ay,bx,by):#3点(0,0)(ax,ay)(bx,by)で構成される三角形の面積の絶対値 return abs(0.5 * (cross_product(complex(ax,ay),complex(bx,by)))) def abs_area_3point(ax,ay,bx,by,cx,cy):#3点(ax,ay)(bx,by)(cx,cy)で構成される三角形の面積の絶対値 return abs_area_vector(bx-ax,by-ay,cx-ax,cy-ay) try: while True: x1,y1,x2,y2,x3,y3,xp,yp = map(float,input().split()) abc = abs_area_3point(x1,y1,x2,y2,x3,y3) pab = abs_area_3point(x1,y1,x2,y2,xp,yp) pbc = abs_area_3point(x2,y2,x3,y3,xp,yp) pca = abs_area_3point(x1,y1,x3,y3,xp,yp) #ここらへんで結構ミスあったから今度からはもっと簡潔に書けるように何か関数でも用意すべき print("NO" if pab * pbc * pca == 0 or abc != pab + pbc + pca else "YES") except (EOFError,ValueError): 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>
s102745587
p00012
Accepted
try: while True: P= list(map(float,input().split())) a, b, c, q = [complex(P[i*2],P[i*2+1]) for i in range(4)] x,y,z= a-q,b-q,c-q xx= (x.conjugate()*y).imag yy= (y.conjugate()*z).imag zz= (z.conjugate()*x).imag if (xx>0 and yy>0 and zz>0) or (xx<0 and yy<0 and zz<0): print("YES") else: print("NO") except EOFError: 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>
s485088124
p00012
Accepted
def cross_product(a,b): return (a.conjugate()*b).imag try: while True: P = list(map(float,input().split())) a, b, c, p = [complex(P[i*2],P[i*2+1]) for i in range(4)] S = cross_product(p-a,p-b) T = cross_product(p-b,p-c) U = cross_product(p-c,p-a) if S*T > 0 and T*U >0: print('YES') else: print('NO') except EOFError: 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>
s597178580
p00012
Accepted
try: while True: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) a = complex(x1, y1) b = complex(x2, y2) c = complex(x3, y3) p = complex(xp, yp) s1 = ((a - p).conjugate() * (b - p)).imag s2 = ((b - p).conjugate() * (c - p)).imag s3 = ((c - p).conjugate() * (a - p)).imag if (s1 > 0) ^ (s2 > 0) == False and (s2 > 0) ^ (s3 > 0) == False: print('YES') else: print("NO") except EOFError: 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>
s971676774
p00012
Accepted
import math import cmath def dot(a:complex,b:complex): return (a.conjugate()*b).real def cross(a:complex,b:complex): return (a.conjugate()*b).imag next=[1,2,0] try: while True: l=list(map(float,input().split())) p=[complex(l[2*j],l[2*j+1]) for j in range(4)] flg_ans=True sgn=1 if cross(p[0]-p[3],p[1]-p[3])>0 else -1 for i in range(3): flg_ans=flg_ans and (sgn*cross(p[i]-p[3],p[next[i]]-p[3]))>0 print('YES' if flg_ans else 'NO') except EOFError: 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>
s816777353
p00012
Accepted
def stl1(x): if a == e: y = b else: y = (f-b)*(x-a)/(e-a) +b return(y) def stl2(x): if c == e: y = f else: y = (d-f)*(x-e)/(c-e) +f return(y) def stl3(x): if c == a: y = b else: y = (d-b)*(x-a)/(c-a) +b return(y) while True: try: lst = list(map(float, input().split())) point1 = [lst[0], lst[1]] point2 = [lst[2], lst[3]] point3 = [lst[4], lst[5]] xp, yp = lst[6], lst[7] pointlst = [point1, point2, point3] pointlst.sort() a, b, e, f, c, d = pointlst[0][0], pointlst[0][1], pointlst[1][0], pointlst[1][1], pointlst[2][0], pointlst[2][1] if a <= xp and xp <= e: bdr1 = stl1(xp) bdr3 = stl3(xp) if min(bdr1, bdr3) <= yp and yp <= max(bdr1, bdr3): print("YES") else: print("NO") elif e < xp and xp <= c: bdr2 = stl2(xp) bdr3 = stl3(xp) if min(bdr2, bdr3) <= yp and yp <= max(bdr2, bdr3): print("YES") else: print("NO") 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>
s273398514
p00012
Accepted
def cross3(a, b, c): return (b[0] - a[0])*(c[1] - a[1]) - (b[1] - a[1])*(c[0] - a[0]) for line in open(0).readlines(): x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split()) p1 = (x1, y1); p2 = (x2, y2); p3 = (x3, y3); pp = (xp, yp) if cross3(p1, p2, p3) < 0: p1, p2 = p2, p1 if cross3(p1, p2, pp) > 0 and cross3(p1, pp, p3) > 0 and cross3(p2, p3, pp) > 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>
s598054003
p00012
Accepted
while True: try: x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, input().split())) sign = lambda x1, y1, x2, y2, x3, y3: (x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3) b1 = sign(xp, yp, x1, y1, x2, y2) < 0.0 b2 = sign(xp, yp, x2, y2, x3, y3) < 0.0 b3 = sign(xp, yp, x3, y3, x1, y1) < 0.0 if b1 == b2 and b2 == b3: 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>
s440497827
p00012
Accepted
import sys for s in sys.stdin: x1,y1,x2,y2,x3,y3,xp,yp = [ float(x) for x in s.split() ] v12 = (x2-x1, y2-y1) v23 = (x3-x2, y3-y2) v31 = (x1-x3, y1-y3) v1p = (xp-x1, yp-y1) v2p = (xp-x2, yp-y2) v3p = (xp-x3, yp-y3) cp1 = v12[0]*v1p[1] - v1p[0]*v12[1] cp2 = v23[0]*v2p[1] - v2p[0]*v23[1] cp3 = v31[0]*v3p[1] - v3p[0]*v31[1] 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>
s987811697
p00012
Accepted
while True : try : x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) # 三角形の回転方向で判定する # 三角形PAB, PBC, PCAの回転が全て同じならば、 # 点Pは三角形ABC内に存在する # 三角形ABCの回転の方向は、 # x1(y2 - y3) + x2(y3 - y1) + x3(y1 - y2) # の符号で判断できる # 正なら左周り、負なら右回り a = xp * (y1 - y2) + x1 * (y2 - yp) + x2 * (yp - y1) b = xp * (y2 - y3) + x2 * (y3 - yp) + x3 * (yp - y2) c = xp * (y3 - y1) + x3 * (y1 - yp) + x1 * (yp - y3) 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>
s099049921
p00012
Accepted
def r(a, b, c, d, e, f): return a * (d-f) + c * (f-b) + e * (b-d) > 0 while True: try: line = list(map(float, input().split())) except: break x1, y1, x2, y2, x3, y3, xp, yp = line 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>
s961107707
p00012
Accepted
import sys def f(a,b,c,d):z=(c-a)*(y-d)-(d-b)*(x-c);return[-1*(z==0),1][z>0] for e in sys.stdin: p,q,r,s,t,u,x,y=map(float,e.split()) print(['NO','YES'][f(p,q,r,s)==f(r,s,t,u)==f(t,u,p,q)])
0.0 0.0 2.0 0.0 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>
s717960979
p00012
Accepted
def r(a, b, c, d, e, f): return a * (d-f) + c * (f-b) + e * (b-d) > 0 while True: try: line = list(map(float, input().split())) except: break x1, y1, x2, y2, x3, y3, xp, yp = line 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>
s254191030
p00012
Accepted
import sys def gaiseki(x0, y0, x1, y1): return x0*y1 - y0*x1 def muki(x0, y0, x1, y1, x2, y2): return gaiseki(x1-x0, y1-y0, x2-x1, y2-y1) > 0 for line in sys.stdin: x0, y0, x1, y1, x2, y2, xp, yp = map(float, line.split()) m0 = muki(xp, yp, x0, y0, x1, y1) m1 = muki(xp, yp, x1, y1, x2, y2) m2 = muki(xp, yp, x2, y2, x0, y0) if m0 == m1 and m1 == m2: 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>
s060322257
p00012
Accepted
def isPos(p,x,y): return ((x-p).conjugate()*(y-p)).imag>0 try: while True: X=list(map(float,input().split())) a,b,c,p=map(lambda x:complex(*x),[X[:2],X[2:4],X[4:6],X[6:]]) print(['NO','YES'][isPos(p,a,b)==isPos(p,b,c)==isPos(p,c,a)]) except EOFError: 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>
s611918698
p00012
Accepted
while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split()) except EOFError: break vec_b = [x2-x1, y2-y1] vec_c = [x3-x1, y3-y1] vec_p = [xp-x1, yp-y1] a = (vec_p[0]*vec_c[1] - vec_p[1]*vec_c[0]) / (vec_b[0]*vec_c[1] - vec_b[1]*vec_c[0]) b = (vec_p[0]*vec_b[1] - vec_p[1]*vec_b[0]) / (vec_b[1]*vec_c[0] - vec_b[0]*vec_c[1]) if ((a > 0) and (b > 0) and (a+b < 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>
s684054677
p00012
Accepted
while 1: try: x1,y1,x2,y2,x3,y3,xp,yp=map(float,input().split()) a=((x1-x2)**2+(y1-y2)**2)**0.5 b=((x2-x3)**2+(y2-y3)**2)**0.5 c=((x3-x1)**2+(y3-y1)**2)**0.5 s=(a+b+c)/2 S=(s*(s-a)*(s-b)*(s-c))**0.5 d=((x1-xp)**2+(y1-yp)**2)**0.5 e=((x2-xp)**2+(y2-yp)**2)**0.5 f=((x3-xp)**2+(y3-yp)**2)**0.5 sa=(a+d+e)/2 sb=(b+e+f)/2 sc=(c+f+d)/2 Sa=(sa*(sa-a)*(sa-d)*(sa-e))**0.5 Sb=(sb*(sb-b)*(sb-e)*(sb-f))**0.5 Sc=(sc*(sc-c)*(sc-f)*(sc-d))**0.5 Sp=Sa+Sb+Sc if abs(S-Sp)<=0.001**2: 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>
s305490001
p00012
Accepted
if __name__ == '__main__': while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().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") 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>
s479409352
p00012
Accepted
def cross(a,b): return (a.conjugate()*b).imag def is_in_triangle(X1,Y1,X2,Y2,X3,Y3,Xp,Yp): z1 = complex(X1-Xp,Y1-Yp) z2 = complex(X2-Xp,Y2-Yp) z3 = complex(X3-Xp,Y3-Yp) if cross(z1,z2) * cross(z2,z3) > 0: if cross(z2,z3) * cross(z3,z1) > 0: return True else: return False lst = [] try: while True: P = tuple(map(float,input().strip().split())) lst.append(P) except EOFError: pass N = len(lst) for i in range(N): if is_in_triangle(*lst[i]): 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>
s896347313
p00012
Accepted
E = 10**-10 def cp(a, b): c = [a[1]*b[2] - a[2]*b[1], a[2]*b[0] - a[0]*b[2], a[0]*b[1] - a[1]*b[0]] return c while True: try: x1,y1,x2,y2,x3,y3,xp,yp = [float(i) for i in input().split()] ax = x3-x1 ay = y3-y1 bx = x1-x2 by = y1-y2 cx = x2-x3 cy = y2-y3 pax = xp-x1 pay = yp-y1 pbx = xp-x2 pby = yp-y2 pcx = xp-x3 pcy = yp-y3 ca = [bx,by,0] ab = [cx,cy,0] bc = [ax,ay,0] pa = [pax,pay,0] pb = [pbx,pby,0] pc = [pcx,pcy,0] cp1 = cp(ca,pa)[2] cp2 = cp(ab,pb)[2] cp3 = cp(bc,pc)[2] if abs(cp1 - abs(cp1)) < E: sig1 = 1 elif abs(cp1 + abs(cp1)) < E: sig1 = -1 if abs(cp2 - abs(cp2)) < E: sig2 = 1 elif abs(cp2 + abs(cp2)) < E: sig2 = -1 if abs(cp3 - abs(cp3)) < E: sig3 = 1 elif abs(cp3 + abs(cp3)) < E: sig3 = -1 if abs(sig1 + sig2 + sig3) == 3: 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>
s621105753
p00012
Accepted
def r(a, b, c, d, e, f): return a * (d-f) + c * (f-b) + e * (b-d) > 0 while True: try: line = list(map(float, input().split())) except: break x1, y1, x2, y2, x3, y3, xp, yp = line 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>
s376571060
p00012
Accepted
while(True): try: x1,y1,x2,y2,x3,y3,xp,yp = map(float, input().split()) c1 = (x2-x1)*(yp-y1)-(y2-y1)*(xp-x1) c2 = (x3-x2)*(yp-y2)-(y3-y2)*(xp-x2) c3 = (x1-x3)*(yp-y3)-(y1-y3)*(xp-x3) if (c1<0 and c2<0 and c3<0) or (c1>0 and c2>0 and c3>0): print("YES") continue 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>
s076897020
p00012
Accepted
from collections import namedtuple Point = namedtuple('Point', ('x', 'y')) def sign (p1, p2, p3): return (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y); while True: try: x = list(map(float, input().split())) p1 = Point(x[0], x[1]) p2 = Point(x[2], x[3]) p3 = Point(x[4], x[5]) pp = Point(x[6], x[7]) b1 = sign(pp, p1, p2) < 0.0 b2 = sign(pp, p2, p3) < 0.0 b3 = sign(pp, p3, p1) < 0.0 if (b1 == b2) and(b2 == b3): 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>
s802122911
p00012
Accepted
def rot(xa,ya,xb,yb,xc,yc): r=(xb-xa)*(yc-ya)-(xc-xa)*(yb-ya) if r>0:return 1 if r==0:return 0 if r<0:return -1 while 1: try: x1,y1,x2,y2,x3,y3,xp,yp=map(float,input().split(" ")) if rot(x1,y1,x2,y2,xp,yp)==rot(x2,y2,x3,y3,xp,yp)==rot(x3,y3,x1,y1,xp,yp): 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>
s079917837
p00012
Accepted
def point(a,b): return a[0]*b[0]+a[1]*b[1] def euclid(a): return (a[0]**2+a[1]**2)**(1/2) def cos(a,b): return point(a,b)/(euclid(a)*euclid(b)) while 1: try: ax,ay,bx,by,cx,cy,px,py = map(float, input().split(" ")) ab = [bx-ax, by-ay] ac = [cx-ax, cy-ay] ba = [ax-bx, ay-by] bc = [cx-bx, cy-by] ap = [px-ax, py-ay] bp = [px-bx, py-by] if min(cos(ab,ap),cos(ac,ap)) > cos(ab,ac) and min(cos(ba,bp),cos(bc,bp)) > cos(ba,bc): 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>
s495417517
p00012
Accepted
# A Point in a Triangle import math def simul_eq(a,b,c,d,e,f): # A = [[a,b],[d,e]] C = [c,f] detA = a*e - b*d # if detA == 0: raise # det(A) == 0. At = [[e,-b],[-d,a]] x = sum(map((lambda x,y: x*y), At[0], C)) / detA y = sum(map((lambda x,y: x*y), At[1], C)) / detA return (x,y) ss = input().split() while 1: x1,y1,x2,y2,x3,y3,xp,yp = map(float,ss) s,t = simul_eq(x2-x1, x3-x1, xp-x1, y2-y1, y3-y1, yp-y1) if 0 < s < 1 and 0 < t < 1 and 0 < s + t < 1: print('YES') else: print('NO') try: ss = input().split() 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>
s583236833
p00012
Runtime Error
# -*- coding: utf-8 -*- import math import cmath 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 while True: line = input() if line == "": break 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>
s707529613
p00012
Runtime Error
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, raw_input().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>
s729218401
p00012
Runtime Error
# coding: utf-8 # Here your code ! # coding: utf-8 import numpy as np l = map(float, raw_input().split()) x1 = l[2]-l[0] x2 = l[3]-l[1] y1 = l[4]-l[0] y2 = l[5]-l[1] p1 = l[6]-l[0] p2 = l[7]-l[1] matrix_A = np.array([[x1,y1],[x2,y2]]) vector_p = np.array([p1,p2]) x = np.linalg.solve(matrix_A, vector_p) if 0<abs(x[0])+abs(x[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>
s890586663
p00012
Runtime Error
i = 1 while True: l = map(float, raw_input().split()) x1 = l[2]-l[0] x2 = l[3]-l[1] y1 = l[4]-l[0] y2 = l[5]-l[1] p1 = l[6]-l[0] p2 = l[7]-l[1] matrix_A = np.array([[x1,y1],[x2,y2]]) vector_p = np.array([p1,p2]) x = np.linalg.solve(matrix_A, vector_p) if 0<abs(x[0])+abs(x[1])<1: print "Yes" else: print "No" if i > 100: break i += 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>
s304881650
p00012
Runtime Error
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) sum = 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 sum == 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>
s271136969
p00012
Runtime Error
import sys datasets = sys.stdin def between(xa, xb, xp): return xa < xp < xb or xb < xp < xa for dataset in datasets: x1, y1, x2, y2, x3, y3, xp, yp = map(float, dataset.split()) if between(x1, x2, xp) and beteen(y1, y2, yp) and between(x2, x3, xp) and between(y2, y3, yp) and between(x3, x1, xp) and between(y3, y1, 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>
s423219026
p00012
Runtime Error
import sys for line in sys.stdin: x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().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] BP = [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>
s050683345
p00012
Runtime Error
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] BP = [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>
s205776151
p00012
Runtime Error
#include<bits/stdc++.h> #include<vector> #include<list> #include<stack> #include<queue> #include<algorithm> using namespace std; int main(){ double x1,y1,x2,y2,x3,y3,xp,yp; while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){ if (((x2-x1)*(y2-y3))-((y1-y3)*(x2-x3))>0 && ((x3-x2)*(y3-yp))-((y1-yp)*(x3-xp))>0) { //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)){ printf("YES\n"); //}else 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)){ // printf("YES\n"); }else{ printf("NO\n"); } } return 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>
s915712620
p00012
Runtime Error
import sys lines = str(sys.stdin.read()).strip().split("\n") for line in lines: data = line.split(" ") x1 = float(data[0]) y1 = float(data[1]) x2 = float(data[2]) y2 = float(data[3]) x3 = float(data[4]) y3 = float(data[5]) xp = float(data[6]) yp = float(data[7]) if xp > min(x1, x2, x3) and xp < max(x1, x2, x3) and yp > min(y1, y2, y3) and yp < max(y1, y2, y3): 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>
s567742821
p00012
Runtime Error
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): 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>
s566813078
p00012
Runtime Error
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 = list(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): 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>
s638306525
p00012
Runtime Error
while True: x1,y1,x2,y2,x3,y3,xp,yp=map(float,input().split()) if xp<0 or yp<0: 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>
s090266901
p00012
Runtime Error
# coding: utf-8 def linecheck(x1, y1, x2, y2, xp, yp): if yp - y1 > (xp - x1) * (y2 - y1) / (x2 - x1): return 1 elif yp - y1 < (xp - x1) * (y2 - y1) / (x2 - x1): return -1 while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split()) if x1 == x2: if (x1 < xp and xp < x3) or (x1 > xp and xp > x3): judge = -1 else: judge = 1 judge *= linecheck(x1, y1, x3, y3, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp) elif x2 == x3: if (x1 < xp and xp < x3) or (x1 > xp and xp > x3): judge = -1 else: judge = 1 judge *= linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x1, y1, x3, y3, xp, yp) elif x3 == x1: if (x1 < xp and xp < x2) or (x1 > xp and xp > x2): judge = -1 else: judge = 1 judge *= linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp) else: judge = linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x1, y1, x3, y3, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp) if judge > 0: print("YES") elif judge < 0: 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>
s217238355
p00012
Runtime Error
# coding: utf-8 def linecheck(x1, y1, x2, y2, xp, yp): if yp - y1 > (xp - x1) * (y2 - y1) / (x2 - x1): return 1 elif yp - y1 < (xp - x1) * (y2 - y1) / (x2 - x1): return -1 while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split()) if x1 == x2: if (x1 < xp and xp < x3) or (x1 > xp and xp > x3): judge = -1 else: judge = 1 judge *= linecheck(x1, y1, x3, y3, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp) elif x2 == x3: if (x1 < xp and xp < x3) or (x1 > xp and xp > x3): judge = -1 else: judge = 1 judge *= linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x1, y1, x3, y3, xp, yp) elif x3 == x1: if (x1 < xp and xp < x2) or (x1 > xp and xp > x2): judge = -1 else: judge = 1 judge *= linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp) else: judge = linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x1, y1, x3, y3, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp) if judge > 0: print("YES") elif judge < 0: 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>
s014929142
p00012
Runtime Error
def linecheck(x1, y1, x2, y2, xp, yp): if yp - y1 > (xp - x1) * (y2 - y1) / (x2 - x1): return 1 elif yp - y1 < (xp - x1) * (y2 - y1) / (x2 - x1): return -1 while True: try: x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split()) if x1 == x2: if (x1 < xp and xp < x3) or (x1 > xp and xp > x3): judge = -1 else: judge = 1 judge *= linecheck(x1, y1, x3, y3, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp) elif x2 == x3: if (x1 < xp and xp < x3) or (x1 > xp and xp > x3): judge = -1 else: judge = 1 judge *= linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x1, y1, x3, y3, xp, yp) elif x3 == x1: if (x1 < xp and xp < x2) or (x1 > xp and xp > x2): judge = -1 else: judge = 1 judge *= linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp) else: judge = linecheck(x1, y1, x2, y2, xp, yp) * linecheck(x1, y1, x3, y3, xp, yp) * linecheck(x2, y2, x3, y3, xp, yp) if judge > 0: print("YES") elif judge < 0: 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>
s317999904
p00012
Runtime Error
import numpy while True: try: x1,y1,x2,y2,x3,y3,xp,yp=map(float,raw_input().split()) AB=numpy.array([x2-x1,y2-y1]) AP=numpy.array([xp-x1,yp-y1]) BC=numpy.array([x3-x2,y3-y2]) BP=numpy.array([xp-x2,yp-y2]) CA=numpy.array([x1-x3,y1-y3]) CP=numpy.array([xp-x3,yp-y3]) if (numpy.cross(AB,AP) < 0 and numpy.cross(BC,BP) < 0 and numpy.cross(CA,CP) < 0) or\ (numpy.cross(AB,AP) > 0 and numpy.cross(BC,BP) > 0 and numpy.cross(CA,CP) > 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>
s279950012
p00012
Runtime Error
import numpy 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 numpy.sign(s1) == numpy.sign(s2) and numpy.sign(s1) == numpy.sign(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>
s428566192
p00012
Runtime Error
import numpy while True: try: x1,y1,x2,y2,x3,y3,xp,yp=map(float,raw_input().split()) AB=numpy.array([x2-x1,y2-y1]) AP=numpy.array([xp-x1,yp-y1]) BC=numpy.array([x3-x2,y3-y2]) BP=numpy.array([xp-x2,yp-y2]) CA=numpy.array([x1-x3,y1-y3]) CP=numpy.array([xp-x3,yp-y3]) #print numpy.cross(AB,AP) if (numpy.cross(AB,AP) < 0 and numpy.cross(BC,BP) < 0 and numpy.cross(CA,CP) < 0) or\ (numpy.cross(AB,AP) > 0 and numpy.cross(BC,BP) > 0 and numpy.cross(CA,CP) > 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>
s478156995
p00012
Runtime Error
import numpy while True: try: x1,y1,x2,y2,x3,y3,xp,yp=map(float,raw_input().split()) AB=numpy.array([x2-x1,y2-y1]) AP=numpy.array([xp-x1,yp-y1]) BC=numpy.array([x3-x2,y3-y2]) BP=numpy.array([xp-x2,yp-y2]) CA=numpy.array([x1-x3,y1-y3]) CP=numpy.array([xp-x3,yp-y3]) #print numpy.cross(AB,AP) if (numpy.cross(AB,AP) < 0 and numpy.cross(BC,BP) < 0 and numpy.cross(CA,CP) < 0) or\ (numpy.cross(AB,AP) > 0 and numpy.cross(BC,BP) > 0 and numpy.cross(CA,CP) > 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>
s073071617
p00012
Runtime Error
import sys for e in sys.stdin: p,q,r,s,t,u,x,y=map(float,e.split()) a=((x-p)*(u-q)-(y-q)*(t-p))/((r-p)*(u-q)-(s-q)*(t-p)) b=(x-p-a*(r-p))/(t-p) print(['No','Yes'][0<a<1-b and 0<b<1-a])
0.0 0.0 2.0 0.0 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>
s901967145
p00012
Runtime Error
import sys for e in sys.stdin: p,q,r,s,t,u,x,y=map(float,e.split()) a=((x-p)*(u-q)-(y-q)*(t-p))/((r-p)*(u-q)-(s-q)*(t-p)) b=(x-p-a*(r-p))/(t-p) print(['NO','YES'][0<a<1-b and 0<b<1-a])
0.0 0.0 2.0 0.0 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>
s540392412
p00012
Runtime Error
while 1: x1,y1,x2,y2,x3,y3,xp,yp=[float(p) for p in input().split()] d_max=max((x2-x1)**2+(y2-y1)**2,(x3-x2)**2+(y3-y2)**2,(x3-x1)**2+(y3-y1)**2) d1,d2,d3=(x2-x1)**2+(y2-y1)**2,(x3-x2)**2+(y3-y2)**2,(x3-x1)**2+(y3-y1)**2; if max(d_max,d1,d2,d3) > d_max: 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>
s649009155
p00012
Runtime Error
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>
s503808220
p00012
Runtime Error
while(true): 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>
s920274659
p00012
Runtime Error
while(True): 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>
s072074434
p00012
Runtime Error
while(True): 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>
s761608732
p00012
Runtime Error
while(True): 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>
s484249181
p00012
Runtime Error
import math lm=lambda x,y,xa,ya,xb,yb:abs((yb-ya)/(xb-xa)*xa+xa - y + (yb-ya)/(xb-xa)*x) / math.hypot((yb-ya)/(xb-xa),-1) if (xb-xa)!=0 else abs(x-xb) while True: r=input() if r=="":break x1,y1,x2,y2,x3,y3,xp,yp=[float(i) for i in r.split()] if lm(x1,y1,x2,y2,x3,y3)<lm(xp,yp,x2,y2,x3,y3) or lm(x2,y2,x1,y1,x3,y3)<lm(xp,yp,x1,y1,x3,y3) or lm(x3,y3,x1,y1,x2,y2)<lm(xp,yp,x1,y1,x2,y2): 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>
s051582293
p00012
Runtime Error
import math def lm(x,y,xa,ya,xb,yb): if (xb-xa)==0:return abs(x-xb) d=(yb-ya)/(xb-xa) return abs(d*xa+xa - y + d*x) / math.hypot(d,-1) while True: r=input() if r=="":break x1,y1,x2,y2,x3,y3,xp,yp=[float(i) for i in r.split()] a=bool(lm(x1,y1,x2,y2,x3,y3)<lm(xp,yp,x2,y2,x3,y3)) b=bool(lm(x2,y2,x1,y1,x3,y3)<lm(xp,yp,x1,y1,x3,y3)) c=bool(lm(x3,y3,x1,y1,x2,y2)<lm(xp,yp,x1,y1,x2,y2)) if a or b or c: 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>
s969556574
p00012
Runtime Error
g=lambda a,b:abs(a[0]*b[1]-a[1]*b[0]) while True: l=[float(i) for i in input().split()] if not l: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) 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>
s834071131
p00012
Runtime Error
g=lambda a,b:abs(a[0]*b[1]-a[1]*b[0]) while True: t=input() if t=="":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>