結果
問題 | No.3008 ワンオペ警備員 |
ユーザー |
👑 |
提出日時 | 2025-01-08 12:22:16 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 169 ms / 2,000 ms |
コード長 | 1,086 bytes |
コンパイル時間 | 1,006 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 78,552 KB |
最終ジャッジ日時 | 2025-01-08 12:22:23 |
合計ジャッジ時間 | 4,004 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 37 |
ソースコード
def Area(u,v,w):return(v[0]-u[0])*(w[1]-u[1])-(v[1]-u[1])*(w[0]-u[0]) def sign(n):return[-1,1][n>0]if n else 0 def L1(v):return abs(v[0])+abs(v[1]) def L1_Distance(u,v):return L1([u[0]-v[0],u[1]-v[1]]) def L1_LongestEdge(u,v,w):return L1_Distance(u,v)>=max(L1_Distance(u,w),L1_Distance(w,v)) def IntersectionType(u,v,z,w):s=[sign(Area(u,v,z)),sign(Area(u,v,w)),sign(Area(z,w,u)),sign(Area(z,w,v))];return 1 if s[0]*s[1]<0 and s[2]*s[3]<0 else 0 if(s[0]==0 and L1_LongestEdge(u,v,z))or(s[1]==0 and L1_LongestEdge(u,v,w))or(s[2]==0 and L1_LongestEdge(z,w,u))or(s[3]==0 and L1_LongestEdge(z,w,v))else -1 R=range J=lambda:list(map(int,input().split())) N,*_=J() XY=[J()for i in R(N)] answer=-1 def xy(i):return XY[i if i<N else i-N] def intersection_type(i,j):return IntersectionType(xy(i),xy(i+1),xy(j),xy(j+1)) def area_sign(i,j,k):return sign(Area(xy(i),xy(j),xy(k))) for i in R(N): s=area_sign(i,i+1,i+2) if s==0:exit(print(0)) for j in R(2,N): if j<N-1 and intersection_type(i,i+j)!=-1:exit(print(0)) t=area_sign(i,i+j-1,i+j) if s*t<0:s=0;break if s!=0:answer=1 print(answer)