HDU2555(模拟暴力)

来源:互联网 发布:小米网络摄像头怎么用 编辑:程序博客网 时间:2024/05/22 13:59

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2555


解题思路:

对每个人都检查一遍他是否扔到了陷阱里,扔到了就加上相应的周长。最后从大到小排个序输出。


完整代码:

#include <functional>#include <algorithm>#include <iostream>#include <fstream>#include <sstream>#include <iomanip>#include <numeric>#include <cstring>#include <climits>#include <cassert>#include <complex>#include <cstdio>#include <string>#include <vector>#include <bitset>#include <queue>#include <stack>#include <cmath>#include <ctime>#include <list>#include <set>#include <map>using namespace std;#pragma comment(linker, "/STACK:102400000,102400000")typedef long long LL;typedef double DB;typedef unsigned uint;typedef unsigned long long uLL;/** Constant List .. **/ //{const int MOD = int(1e9)+7;const int INF = 0x3f3f3f3f;const LL INFF = 0x3f3f3f3f3f3f3f3fLL;const DB EPS = 1e-9;const DB OO = 1e20;const DB PI = acos(-1.0); //M_PI;const int maxn = 30001;int b[maxn];struct node{    int x , y;}k[maxn];struct node2{    int x1 , x2 , y1 , y2;}k2[maxn];bool cmp(int a ,int b){    return a > b;}int main(){    #ifdef DoubleQ    freopen("in.txt","r",stdin);    #endif    std::ios::sync_with_stdio(false);    std::cin.tie(0);    int n , m;    while(cin >> n >> m)    {        for(int i = 0 ; i < n ; i ++)        {            cin >> k[i].x >> k[i].y ;        }        for(int i = 0 ; i < m ; i ++)        {            cin >> k2[i].x1 >> k2[i].y1 >> k2[i].x2 >> k2[i].y2;        }        memset(b ,  0 , sizeof(b));        for(int i = 0 ; i < n ; i ++)        {            for(int j = 0 ; j < m ; j ++)            {                if( k[i].x >= k2[j].x1 && k[i].x <= k2[j].x2 && k[i].y >= k2[j].y1 && k[i].y <= k2[j].y2 )                {                    b[i] += 2 * (abs(k2[j].x1 - k2[j].x2) + abs(k2[j].y1 - k2[j].y2) );                    break;                }            }        }        sort(b , b + n , cmp);        for(int i = 0 ; i < n ; i ++)            cout << b[i] << endl;    }}


0 0
原创粉丝点击