## 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

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;
}t;

int compare(int k, char line, int num){
int dis;
if(line=='x'){
for(int i=1; i<=3; i++){
dis[i]=t[k].p[i].x-num;
}
if( dis>=0&&dis>=0&&dis>=0 ||
dis<=0&&dis<=0&&dis<=0
)
{
return 0;
}
}
else{
for(int i=1; i<=3; i++){
dis[i]=t[k].p[i].y-num;
}
if( dis>=0&&dis>=0&&dis>=0 ||
dis<=0&&dis<=0&&dis<=0
)
return 0;

}
return 1;
}

int
main()
{
int n, m, num, sum, ans;
char line, s;
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;
}`````` ### 電泡泡

fumingfu
2013/03/12
329
6
hi 林峰~~在线急等求解,万分感谢！！！

@Kener-林峰 你好，想跟你请教个问题： 我阅读了API发现在echart上中对横坐标为日期的情况都是穷举 如： xAxis : [ { type : 'category', boundaryGap : true, axisTick: {onGap:false}, sp...

jessya
2014/05/08
179
1

1.启动数据库：STARTUP命令后，执行顺序如下 首先使用服务器上的SPFILESID文件启动实例，如未找到，使用服务器上默认的SPFILE启动实例；如未找到默认SPFILE,使用INITSID文件启动实例，如仍未...

2013/09/17
276
0
AppleScript 判断按键事件的脚本文章收集

AppleScript support for SplitPanes 来自：http://code.google.com/p/iterm2/issues/detail?id=559 Reported by samantha...@gmail.com , Jan 29, 2011 Hi, I would like to be able to sc......

FreeBlues
2013/12/17
0
0

WolfX
2016/02/28
43
0

filebeat multiline配置(转)

xiaomin0322
26分钟前
1
0
ConstraintLayout的基本使用

<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="ht......

SuShine
29分钟前
1
0
ActiveMQ多个消费者消费不均匀问题

31分钟前
1
0
【机器学习PAI实战】—— 玩转人工智能之综述

34分钟前
1
0

xiaogg
39分钟前
3
0 