fork(2) download
  1.  
  2. #include <iostream>
  3. #include <cstdio>
  4. #include <cmath>
  5. #include <algorithm>
  6. #include <cstdio>
  7. #include <utility>
  8. using namespace std;
  9. typedef long long LL;
  10. const int MXN=1e5;
  11. LL n,x,y,x1,y11;
  12. typedef long long LL;
  13. struct punkt{
  14. LL x,y;
  15. };
  16. struct odcinek{
  17. LL x,y,x1,y1;
  18. };
  19. odcinek tab[MXN];
  20. LL det(punkt a,punkt b,punkt c){
  21. LL wyn=a.x*b.y+b.x*c.y+c.x*a.y-b.x*a.y-c.x*b.y-a.x*c.y;
  22. if(wyn>0)return 1;
  23. if(wyn==0)return 0;
  24. return -1;
  25. }
  26. LL sgn(LL a){
  27. if(a>0)return 1;
  28. if(a==0)return 0;
  29. return -1;
  30. }
  31. bool rw(punkt a,punkt b){
  32. if(a.x==b.x&&a.y==b.y)return 1;
  33. return 0;
  34. }
  35. bool nod(odcinek a,punkt b){
  36. punkt a1,a2;
  37. a1.x=a.x;a1.y=a.y;a2.x=a.x1;a2.y=a.y1;
  38. if(det(a1,a2,b)==0&&min(a1.x,a2.x)<=b.x&&max(a2.x,a1.x)>=b.x&&min(a1.y,a2.y)<=b.y&&max(a2.y,a1.y)>=b.y)return 1;
  39. return 0;
  40. }
  41. bool nd(odcinek a,odcinek b){
  42. punkt a1,a2,b1,b2;
  43. a1.x=a.x;a1.y=a.y;a2.x=a.x1;a2.y=a.y1;b1.x=b.x;b1.y=b.y;b2.x=b.x1;b2.y=b.y1;
  44. if(rw(a1,b1)==0&&rw(a1,b2)==0&&rw(b1,a1)==0&&rw(b1,a2)==0&&
  45. rw(a2,b1)==0&&rw(a2,b2)==0&&rw(b2,a1)==0&&rw(b2,a2)==0)return 1;
  46. return 0;
  47. }
  48. LL czy(odcinek a,odcinek b){
  49. punkt a1,a2,b1,b2;
  50. a1.x=a.x;a1.y=a.y;a2.x=a.x1;a2.y=a.y1;b1.x=b.x;b1.y=b.y;b2.x=b.x1;b2.y=b.y1;
  51. if(sgn(det(a1,a2,b1))*sgn(det(a1,a2,b2))<=0&&sgn(det(b1,b2,a1))*sgn(det(b1,b2,a2))<=0){
  52. if(det(a1,a2,b1)==0&&det(a1,a2,b2)==0&&rw(a1,a2)==0&&rw(b1,b2)==0){
  53. if(nod(a,b1)==1&&nod(a,b2)==1)return 2;
  54. if(nod(b,a1)==1&&nod(b,a2)==1)return 2;
  55. if(rw(a1,b1)==1&&nod(a,b1)==1&&nod(a,b2)==1)return 2;
  56. if(rw(a1,b1)==1&&nod(b,a1)==1&&nod(b,a2)==1)return 2;
  57. if(rw(a1,b2)==1&&nod(a,b1)==1&&nod(a,b2)==1)return 2;
  58. if(rw(a1,b2)==1&&nod(b,a1)==1&&nod(b,a2)==1)return 2;
  59. if(rw(a2,b1)==1&&nod(a,b1)==1&&nod(a,b2)==1)return 2;
  60. if(rw(a2,b1)==1&&nod(b,a1)==1&&nod(b,a2)==1)return 2;
  61. if(rw(a2,b2)==1&&nod(a,b1)==1&&nod(a,b2)==1)return 2;
  62. if(rw(a2,b2)==1&&nod(b,a1)==1&&nod(b,a2)==1)return 2;
  63. if(nd(a,b)==1&&nod(a,b1)==1&&nod(b,a1)==1)return 2;
  64. if(nd(a,b)==1&&nod(a,b1)==1&&nod(b,a2)==1)return 2;
  65. if(nd(a,b)==1&&nod(a,b2)==1&&nod(b,a1)==1)return 2;
  66. if(nd(a,b)==1&&nod(a,b2)==1&&nod(b,a2)==1)return 2;
  67. return 1;
  68. }
  69. if(rw(a1,a2)==1&&nod(b,a1)==0)return 0;
  70. if(rw(b1,b2)==1&&nod(a,b1)==0)return 0;
  71. return 1;
  72. }
  73. return 0;
  74. }
  75. int main(){
  76. scanf("%lld",&n);
  77. for(int i=0;i<2*n;i++){
  78. scanf("%lld%lld%lld%lld",&x,&y,&x1,&y11);
  79. tab[i].x=x;
  80. tab[i].y=y;
  81. tab[i].x1=x1;
  82. tab[i].y1=y11;
  83. if(i%2==1){
  84. if(czy(tab[i],tab[i-1])==0)printf("NO\n");
  85. if(czy(tab[i],tab[i-1])==1)printf("POINT\n");
  86. if(czy(tab[i],tab[i-1])==2)printf("SEGMENT\n");
  87. }
  88. }
  89. return 0;
  90. }
  91.  
Success #stdin #stdout 0s 18360KB
stdin
3
0 0 0 10
0 0 0 0
0 0 0 1
1 0 1 1
0 0 2 0
1 0 10 0
stdout
POINT
NO
SEGMENT