福建省第八届 Triangles
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
Sample Output


- #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的更多相关文章
- FZU 2273 Triangles 第八届福建省赛 (三角形面积交 有重边算相交)
Problem Description This is a simple problem. Given two triangles A and B, you should determine they ...
- FZU 2272 Frog 第八届福建省赛 (鸡兔同笼水题)
Problem Description Therearex frogs and y chicken in a garden. Kim found there are n heads and m leg ...
- FOJ Problem 2273 Triangles
Problem 2273 Triangles Accept: 201 Submit: 661Time Limit: 1000 mSec Memory Limit : 262144 KB P ...
- FZUOJ-2273 Triangles
Problem 2273 Triangles Accept: 109 Submit: 360 Time Limit: 1000 mSec Memory Limit : 262144 KB ...
- Count the number of possible triangles
From: http://www.geeksforgeeks.org/find-number-of-triangles-possible/ Given an unsorted array of pos ...
- 电子科技大学第八届ACM趣味程序设计竞赛第四场(正式赛)题解
A. Picking&Dancing 有一列n个石子,两人交替取石子,每次只能取连续的两个,取走后,剩下的石子仍然排成1列.问最后剩下的石子数量是奇数还是偶数. 读懂题意就没什么好说的. #i ...
- [ACM_搜索] Triangles(POJ1471,简单搜索,注意细节)
Description It is always very nice to have little brothers or sisters. You can tease them, lock them ...
- acdream.Triangles(数学推导)
Triangles Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit Stat ...
- UVA 12651 Triangles
You will be given N points on a circle. You must write a program to determine how many distinctequil ...
随机推荐
- 关于Github Pages
迁移Github Pages 我稍微有一点强迫症,实在是忍受不了整洁的界面有一些推广的广告.正所谓博客平台不重要,重要的是要有干货,CSDN首页满屏的广告也就忍受了,但是自己的文章的页面有广告看着实在 ...
- elasticsearch搜索类型简单介绍
简单搜索 GET请求很easy--你能轻松获取你想要的文档.让我们来进一步尝试一些东西.比方简单的搜索! 我们尝试一个最简单的搜索所有员工的请求: GET /megacorp/employee/_se ...
- Android控件-单选按钮RadioButton
RadioGroup单选按钮用法,还是先看效果图 先中后,点RadioGroup测试按钮,可在标题栏显示选择结果,点清除可以清除选择.下面上代码,main.xml: <RadioGroup an ...
- js实现导出数据到excel
来自:http://www.imooc.com/article/13374 //html代码<!DOCTYPE HTML> <html> <head> <ti ...
- BFS(广度优先搜索)
Catch That Cow Farmer John has been informed of the location of a fugitive cow and wants to catch he ...
- Chromium String usage
For Developers > Chromium String usage Types of StringsIn the Chromium code base, we use std:: ...
- 新手教程:电信+广电(或其他运营商)双WAN设置
由于国内不同运营商之间互联互通存在问题,假如用联通的线路去访问电信的站点那么会比较卡,反之亦然:所以如果两个WAN的线路不是同一个运营商,一般都是建议用户双WAN模式选为“智能路由”.经过本人测试发现 ...
- 微信小程序官方文档中的加密算法
用Nodejs来算一下:
- js获取当前时间年份,处理年月日
js中获得当前时间年份.月份.日期 //获取完整的日期 var date=new Date; var y = date.getFullYear()var m = date.getMonth ...
- 开发板ping得通本地,但是不能上网
在3531D的开发板上面接入LAN7500的USB转以太网口,加载完驱动后. 然后开启eth1 查看一下ifconfig,发现没有ip,配置一下ip 直接ping本地发现可以ping得通,代表链路是连 ...