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. JZ2440 裸机驱动 第5章 GPIO接口

    本章目标:     掌握嵌入式开发的步骤:编程.编译.烧写程序.运行     通过GPIO的操作了解软件如何控制硬件 5.1 GPIO硬件介绍     S3C2440A有130个多功能输入/输出口引脚 ...

  2. 彻底解密C++宽字符(二)

    彻底解密C++宽字符(二) 转:http://club.topsage.com/thread-2227977-1-1.html 4.利用codecvt和use_facet转换 locale和facet ...

  3. USACO 2016 February Contest, Gold解题报告

    1.Circular Barn   http://www.usaco.org/index.php?page=viewproblem2&cpid=621 贪心 #include <cstd ...

  4. app遍历——appCrawler的使用

    1.appCrawler环境配置 1.1 apkinfo获取安装包的报名和mainActivity https://github.com/codeskyblue/apkinfo/releases 使用 ...

  5. jenkins之构建触发器

    build whenever a snapshot dependency is built 当job依赖的快照版本被build时,执行本job. build after other projects ...

  6. 七、配置ssh keys连通github跟ssh-agent

    jenkins+github配置完成后,能够实现在提交pull request或者直接push时,能够将提交的代码拉去一份到服务器本地,并自动merge:但是代码拉去下来了,部署环境的时候却需要输入登 ...

  7. jsp页面获取地址栏中的参数

  8. Configure、中间件与ErrorHandlingMiddleware全局异常捕获

    一.Configure Startup.cs中的Configure方法主要是http处理管道配置.中间件和一些系统配置,其中 IApplicationBuilder: 定义一个类,该类提供配置应用程序 ...

  9. 【bzoj3437】小P的牧场

    3437: 小P的牧场 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 947  Solved: 542[Submit][Status][Discuss ...

  10. Linux基石【第四篇】基本Linux命令

    Linux 系统上一切皆文件 命令: pwd  -- 查看当前目录  / 代表根目录 clear -- 清屏命令 cd(change directory) -- 切换目录 cd / -- 切换到根目录 ...