zoukankan      html  css  js  c++  java
  • Nordic Collegiate Programming Contest 2015​ G. Goblin Garden Guards

    In an unprecedented turn of events, goblins recently launched an invasion against the Nedewsian city of Mlohkcots. Goblins—small, green critters—love nothing more than to introduce additional entropy into the calm and ordered lives of ordinary people. They fear little, but one of the few things they fear is water.

    The goblin invasion has now reached the royal gardens, where the goblins are busy stealing fruit, going for joyrides on the lawnmower and carving the trees into obscene shapes, and King Lrac Fatsug has decreed that this nonsense stop immediately!

    Thankfully, the garden is equipped with an automated sprinkler system. Enabling the sprinklers will soak all goblins within range, forcing them to run home and dry themselves.

    Serving in the royal garden guards, you have been asked to calculate how many goblins will remain in the royal garden after the sprinklers have been turned on, so that the royal gardeners can plan their next move.

    Input Format

    The input starts with one integer 1g100000, the number of goblins in the royal gardens.

    Then, for each goblin follows the position of the goblin as two integers, 1xi10000 and1yi10000. The garden is flat,

    square and all distances are in meters. Due to quantum interference, several goblins can occupy exactly the same spot

    n the garden.Then follows one integer 1m20000, the number of sprinklers in the garden.Finally, for each sprinkler follows the location of the sprinkler as two integers 1xi10000 and 1yi10000, and the integer radius 1r100 of the area it covers,meaning that any goblin at a distance of at most rr from the point (xi,yi) will be soaked by this sprinkler.

    There can be several sprinklers in the same location.

    Output Format

    Output the number of goblins remaining in the garden after the sprinklers have been turned on.

    样例输入

    5
    0 0
    100 0
    0 100
    100 100
    50 50
    1
    0 0 50

    样例输出

    4

    题目来源

    Nordic Collegiate Programming Contest 2015​

     

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <vector>
     5 #include <string>
     6 #include <string>
     7 #include <map>
     8 #include <cmath>
     9 #include <set>
    10 #include <algorithm>
    11 using namespace std;
    12 typedef long long ll;
    13 int g,m;
    14 const int N=1e5+9;
    15 const int M=1e4+9;
    16 struct Node{
    17     int x, y;
    18 }nod[N];
    19 bool  vis[M][M];//bool变量占用一个字节的内存1k==1024字节
    20 //int vis[M][M] int : 4字节
    21 int  main()
    22 {
    23    scanf("%d",&g);
    24    for(int i=0;i<g;i++){
    25        scanf("%d%d",&nod[i].x,&nod[i].y);
    26    }
    27    scanf("%d",&m);
    28    int x,y,r;
    29    memset(vis,0,sizeof(vis));
    30    //20000*10^8==2*10^12
    31    for(int i=0;i<m;i++){
    32        scanf("%d%d%d",&x,&y,&r);
    33        for(int kx=max(0,x-r);kx<=min(x+r,10000);kx++){
    34            for(int ky=max(0,y-r);ky<=min(y+r,10000);ky++){
    35                if(((x-kx)*(x-kx))+((y-ky)*(y-ky))<=r*r){
    36                    vis[kx][ky]=1;
    37                }
    38            }
    39        }
    40    }
    41        int ans=0;
    42        for(int i=0;i<g;i++){
    43            if(!vis[nod[i].x][nod[i].y]) 
    44                ans++;
    45        }
    46        printf("%d
    ",ans);
    47    return  0;
    48 }
  • 相关阅读:
    DOCTYPE
    js——类型转换
    对象Object
    Array数组
    es6学习笔记
    springboot第一个项目【mybatis】
    springboot第一个项目【创建】
    项目管理和流程的拙见
    树莓派 Zero作为飞控图传
    一根数据线玩转树莓派Zero
  • 原文地址:https://www.cnblogs.com/tingtin/p/9384428.html
Copyright © 2011-2022 走看看