Nordic Collegiate Programming Contest 2015? G. Goblin Garden Guards

Posted tingtin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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, 1xi?10000 and1yi?10000. 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 1xi?10000 and 1yi?10000, 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 }

 

以上是关于Nordic Collegiate Programming Contest 2015? G. Goblin Garden Guards的主要内容,如果未能解决你的问题,请参考以下文章

Nordic Collegiate Programming Contest 2015? G. Goblin Garden Guards

复盘8.3训练:Nordic Collegiate Programming Contest 2020

(寒假GYM开黑)2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)

Gym .101933 Nordic Collegiate Programming Contest (NCPC 2018) (寒假gym自训第四场)

2017-2018 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2017)

2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018) A. Altruistic Amphibians DP(示