Circuit Board


Time Limit: 2 Seconds      Memory Limit: 65536 KB


On the circuit board, there are lots of circuit paths. We know the basic constrain is that no two path cross each other, for otherwise the board will be burned.



Now given a circuit diagram, your task is to lookup if there are some crossed paths. If not find, print "ok!", otherwise "burned!" in one line.



A circuit path is defined as a line segment on a plane with two endpoints p1(x1,y1) and p2(x2,y2).



You may assume that no two paths will cross each other at any of their endpoints.

Input



The input consists of several test cases. For each case, the first line contains an integer n(<=2000), the number of paths, then followed by n lines each with four float numbers x1, y1, x2, y2.

Output



If there are two paths crossing each other, output "burned!" in one line; otherwise output "ok!" in one line.



Sample Input

1

0 0 1 1

2

0 0 1 1

0 1 1 0

Sample Output

ok!

burned!

——————————————————————————————————————

题目的意思是给出n条线段,问是否有线段相交

两两之间暴力判,判可以用模板



#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <functional>
#include <bitset>
#include <string> using namespace std; #define LL long long
#define INF 0x3f3f3f3f struct Point
{
double x;
double y;
};
typedef struct Point point;
struct line
{
point p1,p2;
}; double multi(point p0,point p1,point p2)
{
return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
}
bool is(point s1,point e1,point s2,point e2)
{
return (max(s1.x,e1.x)>=min(s2.x,e2.x))&&
(max(s2.x,e2.x)>=min(s1.x,e1.x))&&
(max(s1.y,e1.y)>=min(s2.y,e2.y))&&
(max(s2.y,e2.y)>=min(s1.y,e1.y))&&
(multi(s1,s2,e1)*multi(s1,e1,e2)>0)&&
(multi(s2,s1,e2)*multi(s2,e2,e1)>0);
} int main()
{
int n;
line L[2005];
while(~scanf("%d",&n))
{
for(int i=0; i<n; i++)
{
scanf("%lf%lf%lf%lf",&L[i].p1.x,&L[i].p1.y,&L[i].p2.x,&L[i].p2.y);
}
int flag=0;
for(int i=0; i<n; i++)
{
for(int j=0; j<n; j++)
{
if(i==j)
continue;
if(is(L[i].p1,L[i].p2,L[j].p1,L[j].p2))
{
flag=1;
break;
}
}
if(flag)
break;
}
if(flag)
printf("burned!\n");
else
printf("ok!\n");
}
return 0;
}


Author: ZHOU, Feng

Source: ZOJ Monthly, September 2003

ZOJ1648 Circuit Board 2017-04-18 20:31 34人阅读 评论(0) 收藏的更多相关文章

  1. hadoop调优之一:概述 分类: A1_HADOOP B3_LINUX 2015-03-13 20:51 395人阅读 评论(0) 收藏

    hadoop集群性能低下的常见原因 (一)硬件环境 1.CPU/内存不足,或未充分利用 2.网络原因 3.磁盘原因 (二)map任务原因 1.输入文件中小文件过多,导致多次启动和停止JVM进程.可以设 ...

  2. Self Numbers 分类: POJ 2015-06-12 20:07 14人阅读 评论(0) 收藏

    Self Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 22101   Accepted: 12429 De ...

  3. 高质量C++C编程指南笔记 标签: c++笔记 2015-11-22 20:59 179人阅读 评论(0) 收藏

    1.  在多重循环中,如果有可能,应当将最长的循环放在最内层,最短的循环放在最外层,以减少 CPU 跨切循环层的次数. 2.  如果循环体内存在逻辑判断,并且循环次数很大,宜将逻辑判断移到循环体的外面 ...

  4. Codeforces812B Sagheer, the Hausmeister 2017-06-02 20:47 85人阅读 评论(0) 收藏

    B. Sagheer, the Hausmeister time limit per test 1 second memory limit per test 256 megabytes input s ...

  5. UI基础:UIView(window,frame,UIColor,CGPoint,alpha,CGRect等) 分类: iOS学习-UI 2015-06-30 20:01 119人阅读 评论(0) 收藏

    UIView 视图类,视图都是UIView或者UIView子类 UIWindow 窗口类,用于展示视图,视图一定要添加window才能显示 注意:一般来说,一个应用只有一个window 创建一个UIW ...

  6. OC基础:OC 基本数据类型与对象之间的转换方法 分类: ios学习 OC 2015-06-18 20:01 11人阅读 评论(0) 收藏

    1.Foundation框架中提供了很多的集合类如:NSArray,NSMutableArray,NSSet,NSMutableSet,NSDictionary,NSMutableDictionary ...

  7. ZOJ2748 Free Kick 2017-04-18 20:40 40人阅读 评论(0) 收藏

    Free Kick Time Limit: 2 Seconds      Memory Limit: 65536 KB In a soccer game, a direct free kick is ...

  8. ZSTU4269 买iphone 2017-03-22 14:31 73人阅读 评论(0) 收藏

    4269: 买iphone Time Limit: 3 Sec  Memory Limit: 128 MB Submit: 1710  Solved: 316 Description 自从上次仓鼠中了 ...

  9. 各种排序算法的分析及java实现 分类: B10_计算机基础 2015-02-03 20:09 186人阅读 评论(0) 收藏

    转载自:http://www.cnblogs.com/liuling/p/2013-7-24-01.html 另可参考:http://gengning938.blog.163.com/blog/sta ...

随机推荐

  1. 在Windows Server 2012启用或关闭Internet Explorer增强的安全配置

    在 Windows Sever 2012 中打开 IE 浏览器时,IE10 会出现[已启用 Internet Explorer 增强的安全配置]的提示信息. 在安全性等级中会设置以[高安全性],如果我 ...

  2. python logging 重复写日志问题

    用Python的logging模块记录日志时,遇到了重复记录日志的问题,第一条记录写一次,第二条记录写两次,第三条记录写三次...很头疼,这样记日志可不行.网上搜索到了原因与解决方案: 原因:没有移除 ...

  3. 使用sqoop从Oracle或mysql抽取数据到HDFS遇到的报错及解决

    一.参考文档: 1.https://www.rittmanmead.com/blog/2014/03/using-sqoop-for-loading-oracle-data-into-hadoop-o ...

  4. ElasticSearch 基础概念学习(未完)

    1.基本定义 摘自百度百科 elasticseaElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.Elastic ...

  5. springboot 测试 有注入HttpSession的bean

    question: nested exception is java.lang.IllegalStateException: No thread-bound request found: Are yo ...

  6. 基于sersync海量文件实时同步

    项目需求:最近涉及到数百万张图片从本地存储迁移到云存储,为了使完成图片迁移,并保证图片无缺失,业务不中断,决定采用实时同步,同步完后再做流量切换.在实时同步方案中进行了几种尝试. 方案1:rsync+ ...

  7. JS表单常见表达式(正则)

    整数或者小数:^[0-9]+\.{0,1}[0-9]{0,2}$ 只能输入数字:"^[0-9]*$". 只能输入n位的数字:"^\d{n}$". 只能输入至少n ...

  8. [转]js清除所有cookies

    来源:http://blog.csdn.net/zzl1120/article/details/6592332 var cookies = document.cookie.split(";& ...

  9. Rhythmk 学习 Hibernate 03 - Hibernate 之 延时加载 以及 ID 生成策略

    Hibernate 加载数据 有get,跟Load 1.懒加载: 使用session.load(type,id)获取对象,并不读取数据库,只有在使用返回对象值才正真去查询数据库. @Test publ ...

  10. leetcode110

    /** * Definition for a binary tree node. * public class TreeNode { * public int val; * public TreeNo ...