Luo Gu P1847 II bombing

Topic background

This enhanced version entitled bombing data

Title Description

A city was bombed M times, each time the bombing of a rectangle with each side of the boundary are parallel

After the bombing, there are N key points, commander wanted to know, they have not been subjected to bombing, if any, was bombed several times, the last time was the first rounds.

Input Format

The first line, two integers: M, N

The following M rows, each row four integers: x1, y1, x2, y2, upper left corner and lower-right coordinates of a rectangular coordinate bombed (such as 13,710 where it is expressed from the bombed (1,3) to (7,10) of the rectangle).

Then the following N lines of two integers, a graph of the critical point.

Output Format

A total of N lines,

The first character of each line to YES or NO, indicating whether the bombing, if it is YES, after a space for the two integer representing the bombed several times and the last time was the first rounds.

Sample input and output

Input # 1
1 1 
1 1 10 10
11 11
Output # 1
NO

Description / Tips

1<=N,M<=2000

1<=x1,y1,x2,y2<=maxlongint

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 { 
 5     long long tot,ans,n,m;
 6     cin>>m>>n;
 7     long long a[n+1],b[n+1],x[n+1],y[n+1],i,j;
 8     for(int k=1;k<=m;k++)
 9         cin>>a[k]>>b[k]>>x[k]>>y[k];
10     for(int o=1;o<=n;o++)
11     {cin>>i>>j;
12     for(int k=1;k<=m;k++)
13        if(i>=a[k]&&i<=x[k]&&j>=b[k]&&j<=y[k])
14        {
15            tot++;
16           ans=k;
17        } 
18     if(tot==0)cout<<"NO"<<endl;
19     else cout<<"YES"<<" "<<tot<<" "<<ans<<endl;
20     tot=0;
21     }
22 } 

Guess you like

Origin www.cnblogs.com/anbujingying/p/11323516.html