当前位置: 首页 > news >正文

8_21_2013_Problem D: BUREK_纯模拟

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

Problem D: BUREK

Time Limit: 1 Sec   Memory Limit: 32 MB
Submit: 22   Solved: 14
[ Submit][ Status][ Web Board]

Description

Baker  Crumble  has  just  baked N triangular  burek
2
 pastries.  Each  pastry  can  be  represented  in  the 
Cartesian coordinate system as a triangle with vertices in integer coordinate points. 
The baker's mischievous son Joey has just taken a large knife and started to cut the pastries. Each cut 
that Joey makes corresponds to a horizontal (y = c) or vertical (x = c) line in the coordinate  system. 
Help the baker assess the damage caused by Joey's pastry cutting. Your task is to determine, for each 
Joey's cut, how many pastries are affected (such that both the left and right parts of the cut pastry have 
areas greater than zero).

Input

The first line of input contains the positive integer N (2 ≤ N ≤ 100 000), the number of burek pastries. 
Each of the following N lines contains six nonnegative integers smaller than 10
6
. These numbers are, in 
order, the coordinates (x1, y1), (x2, y2), (x3, y3) of the three pastry-triangle vertices. The three vertices will 
not all be on the same line. The pastries can touch as well as overlap. 
The following line contains the positive integer M (2 ≤ M ≤ 100 000), the number of cuts. 
Each of the following M lines contains a single cut line equation: “x = c” or “y = c” (note the spaces 
around the equals sign), where c is a nonnegative integer smaller than 10
6
.

Output

For each cut, output a line containing the required number of cut pastries.

Sample Input

3 1 0 0 2 2 2 1 3 3 5 4 0 5 4 4 5 4 4 4 x = 4 x = 1 y = 3 y = 1 4 2 7 6 0 0 5 7 1 7 10 11 11 5 10 2 9 6 8 1 9 10 10 4 1 4 y = 6 x = 2 x = 4 x = 9

Sample Output

0 1 1 2 3 2 3 2

HINT

In test data worth at least 40 points, M ≤ 300. 

In  test  data  worth an additional 40 points, the  vertex  coordinates  of  all  triangles  will  be  smaller  than 

1000.

#include <iostream>
using namespace std;

struct point{
	int x, y;
};
struct tri{
	point p[4]; 
}t[100010];

int compare(int k, char line, int num){
	int dis[5];
	if(line=='x'){
		for(int i=1; i<=3; i++){
			dis[i]=t[k].p[i].x-num;
		}
		if( dis[1]>=0&&dis[2]>=0&&dis[3]>=0 ||
		    dis[1]<=0&&dis[2]<=0&&dis[3]<=0
		  )
		  {
			return 0;
		  }
	}
	else{
		for(int i=1; i<=3; i++){
			dis[i]=t[k].p[i].y-num;
		}
		if( dis[1]>=0&&dis[2]>=0&&dis[3]>=0 ||
		    dis[1]<=0&&dis[2]<=0&&dis[3]<=0
		  )
			return 0;
		
	}
	return 1;
}
 
int 
main()
{
	int n, m, num, sum, ans;
	char line, s[10];
	char ch;
	while(cin>>n){
		for(int i=1; i<=n; i++){
			for(int j=1; j<=3; j++){
				cin>>t[i].p[j].x>>t[i].p[j].y;
			}
		}
		cin>>m;
		for(int i=1; i<=m; i++){
			ans=0;
			cin>>line>>ch>>num;
			//cout<<line<<ch<<num<<endl;
			for(int i=1; i<=n; i++){
				sum=compare(i, line, num);
				//cout<<sum;
				ans+=sum;
			}
			//cout<<"**";
			cout<<ans<<endl;
		}
	}
	return 0;
}


转载于:https://my.oschina.net/dianpaopao/blog/155922

相关文章:

  • 计算机网络方向技能需求
  • linux centos 磁盘分区 逻辑卷
  • .cn根服务器被攻击之后
  • MAC地址验证之本地验证
  • testing
  • [转载]ARP表和FDB表的区别
  • [每日一题] 11gOCP 1z0-052 :2013-08-31   数据库的存储结构.....................................................
  • 2 curses库IO处理--字符属性函数
  • 求两个字符串的不连续的公共字串
  • Javascript时间字符串比较
  • IE关闭时出错解决办法
  • 线程间通信----Handler
  • 虚拟化安全解决方案vShield Endpoint之Deep Security Manager 9.0 SP1部署测试
  • 实现怎样支持Android重力感应器Sensor编程
  • “反应性编程”和“事件驱动Web”
  • CNN 在图像分割中的简史:从 R-CNN 到 Mask R-CNN
  • github从入门到放弃(1)
  • HTTP那些事
  • Js基础知识(一) - 变量
  • Less 日常用法
  • Mac转Windows的拯救指南
  • Promise初体验
  • spring cloud gateway 源码解析(4)跨域问题处理
  • 成为一名优秀的Developer的书单
  • 初探 Vue 生命周期和钩子函数
  • 少走弯路,给Java 1~5 年程序员的建议
  • 小试R空间处理新库sf
  • 看到一个关于网页设计的文章分享过来!大家看看!
  • Nginx实现动静分离
  • postgresql行列转换函数
  • 支付宝花15年解决的这个问题,顶得上做出十个支付宝 ...
  • ​MySQL主从复制一致性检测
  • (02)Hive SQL编译成MapReduce任务的过程
  • (8)STL算法之替换
  • (C语言)共用体union的用法举例
  • (Forward) Music Player: From UI Proposal to Code
  • (差分)胡桃爱原石
  • (第二周)效能测试
  • (附程序)AD采集中的10种经典软件滤波程序优缺点分析
  • (附源码)基于ssm的模具配件账单管理系统 毕业设计 081848
  • (图)IntelliTrace Tools 跟踪云端程序
  • (一)RocketMQ初步认识
  • (已解决)报错:Could not load the Qt platform plugin “xcb“
  • .NET CLR基本术语
  • .Net Framework 4.x 程序到底运行在哪个 CLR 版本之上
  • .Net FrameWork总结
  • .Net mvc总结
  • .net 后台导出excel ,word
  • .net 使用ajax控件后如何调用前端脚本
  • .net 验证控件和javaScript的冲突问题
  • .NetCore Flurl.Http 升级到4.0后 https 无法建立SSL连接
  • .netcore如何运行环境安装到Linux服务器
  • .NET正则基础之——正则委托
  • .pub是什么文件_Rust 模块和文件 - 「译」
  • /dev/sda2 is mounted; will not make a filesystem here!