Problem Description

This is a simple problem. Given two triangles A and B, you should determine they are intersect, contain or disjoint. (Public edge or point are treated as intersect.)

Input

First line contains an integer T (1 ≤ T ≤ 10), represents there are T test cases.

For each test case: X1 Y1 X2 Y2 X3 Y3 X4 Y4 X5 Y5 X6 Y6. All the coordinate are integer. (X1,Y1) , (X2,Y2), (X3,Y3) forms triangles A ; (X4,Y4) , (X5,Y5), (X6,Y6) forms triangles B.

-10000<=All the coordinate <=10000

Output

For each test case, output “intersect”, “contain” or “disjoint”.

Sample Input

2 0 0 0 1 1 0 10 10 9 9 9 10 0 0 1 1 1 0 0 0 1 1 0 1

Sample Output

disjoint
intersect
判断两个三角形是 相交,包含,还是相离的关系
包含关系:
如图:若ΔDEF被包含;则可通过点来判断
D点被包含SΔACD+SΔCDB+SΔADB=SΔABC 同理判断E、F点,若三点全满足则包含
相离关系:
如图:若D点在外:则有SΔDAC+SΔDBC+SΔAB>SΔABC
若三点都满足上式,则相离,剩下的就只有相交关系了。
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int t,ans;
struct point
{
double x;
double y;
};
struct trangle
{
point p[];
}angle[];
double area(point a,point b,point c)
{
return fabs((b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y));//三角形面积
}
bool check(trangle a,trangle b)
{
double area_trangle=area(a.p[],a.p[],a.p[]);//判断是否包含和不相交
int pos=;
for(int i=;i<;i++)
{
if((area(b.p[i],a.p[],a.p[])+area(b.p[i],a.p[],a.p[])+area(b.p[i],a.p[],a.p[]))>area_trangle) continue;
else ans++,pos++;
}
return pos==;
}
void solve()
{
ans=;
if(check(angle[],angle[]) || check(angle[],angle[]))
{
puts("contain");
return ;
}
else if(!ans)
{
puts("disjoint");
return ;
}
else
{
puts("intersect");
return ;
}
}
int main()
{
scanf("%d",&t);
while(t--)
{
for(int i=;i<;i++)
{
for(int j=;j<;j++)
{
scanf("%lf%lf",&angle[i].p[j].x,&angle[i].p[j].y);
}
}
solve();
}
return ;
}

福建省第八届 Triangles的更多相关文章

  1. FZU 2273 Triangles 第八届福建省赛 (三角形面积交 有重边算相交)

    Problem Description This is a simple problem. Given two triangles A and B, you should determine they ...

  2. FZU 2272 Frog 第八届福建省赛 (鸡兔同笼水题)

    Problem Description Therearex frogs and y chicken in a garden. Kim found there are n heads and m leg ...

  3. FOJ Problem 2273 Triangles

    Problem 2273 Triangles Accept: 201    Submit: 661Time Limit: 1000 mSec    Memory Limit : 262144 KB P ...

  4. FZUOJ-2273 Triangles

     Problem 2273 Triangles Accept: 109    Submit: 360 Time Limit: 1000 mSec    Memory Limit : 262144 KB ...

  5. Count the number of possible triangles

    From: http://www.geeksforgeeks.org/find-number-of-triangles-possible/ Given an unsorted array of pos ...

  6. 电子科技大学第八届ACM趣味程序设计竞赛第四场(正式赛)题解

    A. Picking&Dancing 有一列n个石子,两人交替取石子,每次只能取连续的两个,取走后,剩下的石子仍然排成1列.问最后剩下的石子数量是奇数还是偶数. 读懂题意就没什么好说的. #i ...

  7. [ACM_搜索] Triangles(POJ1471,简单搜索,注意细节)

    Description It is always very nice to have little brothers or sisters. You can tease them, lock them ...

  8. acdream.Triangles(数学推导)

    Triangles Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Submit Stat ...

  9. UVA 12651 Triangles

    You will be given N points on a circle. You must write a program to determine how many distinctequil ...

随机推荐

  1. 【Cocos2d-x 3.0】游戏开发之win32配置环境搭建project

    作者:Senlern 转载请注明,原文链接:http://blog.csdn.net/zhang429350061/article/details/37958275 非常久没有写教程了.如今认为还是要 ...

  2. Java并发编程 - Executor,Executors,ExecutorService, CompletionServie,Future,Callable

    一.Exectuor框架简介 Java从1.5版本开始,为简化多线程并发编程,引入全新的并发编程包:java.util.concurrent及其并发编程框架(Executor框架). Executor ...

  3. 关于es6中对象的扩展

    1.Object.is() es5比较两个值是否相等,只有两个运算符,相等(==) 和 严格相等(===),他们都有缺点,前者会自动转换数据类型,后者的NaN不等于自身,以及+0 等于 -0.es6提 ...

  4. 暑假集训-WHUST 2015 Summer Contest #0.1

    ID Origin Title   4 / 12 Problem A Gym 100589A Queries on the Tree 14 / 41 Problem B Gym 100589B Cou ...

  5. HDU 4349 Xiao Ming's Hope 组合数学

    题意:给你n,问在C(n,1),C(n,2)...C(n,n)中有多少个奇数. 比赛的时候打表看出规律,这里给一个数学上的说明. Lucas定理:A,B非负整数,p是质数,A,B化为p进制分别为a[n ...

  6. 关于HTML5和CSS3的几个“新增”

    html5和css3分别是目前最新的web前端编程的标准,加入了新的标准和要求. 1.HTML5新增input输入类型,即type后面的值 文本域 <input type="text& ...

  7. DevExpress Report打印边距越界问题

    DevExpress  Report Print的时候,出现这样的问题:one or more margins are set outside the printable area of the pa ...

  8. 学习TF:《TensorFlow技术解析与实战》PDF+代码

    TensorFlow 是谷歌公司开发的深度学习框架,也是目前深度学习的主流框架之一.<TensorFlow技术解析与实战>从深度学习的基础讲起,深入TensorFlow框架原理.模型构建. ...

  9. 无闻go编程基础笔记

    Go语言做Web编程非常方便,并且在开发效率和程序运行效率方面都非常优秀.相比于Java,其最大的优势就是简便易用,而相比于PHP,它最大的优势就是性能好. (go做web)推荐Gorilla的库,里 ...

  10. UVALive 7146 Defeat The Enemy

    Defeat The Enemy Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu Long long ...