2018湘潭大学程序设计竞赛【C】

题目链接:https://www.nowcoder.com/acm/contest/105/C

 

题意:给你几个矩形的左上角和右下角的坐标,让你算有几个矩形相交。

 

题解: 每次都暴力标记一下炸弹区域里的点,因为一定是矩形爆炸区域。。QAQ,然后找最大的就是最多波及的炸弹啦。注意边界不考虑。。坑死。

 

 1 #include<iostream>
 2 #include<algorithm>
 3 #include<cstring>
 4 using namespace std;
 5 int cnt[105][105];
 6  
 7 int main(){
 8     int t;
 9     cin >> t;
10     int x1,y1,x2,y2;
11     while(t--){
12         memset(cnt,0,sizeof(cnt));
13         int n;
14         cin >> n;
15         int ans = 0;
16         for(int k = 0 ; k < n ; k++){
17             scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
18             if(x1 > x2){
19                 swap(x1,x2);
20             }
21             if(y1 > y2){
22                 swap(y1,y2);
23             }
24             for(int i = x1; i < x2; i++){
25                 for(int j = y1; j < y2; j++){
26                     cnt[i][j]++;
27                     ans = max(ans,cnt[i][j]);
28                 }
29             }
30 
31         }
32          printf("%d\n",ans);
33              
34     } 
35  
36 } 
View Code

 

posted @ 2018-05-04 17:15  甜酒果。  阅读(195)  评论(0)    收藏  举报