链接:https://www.nowcoder.com/acm/contest/163/F

来源:牛客网

2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it

时间限制:C/C++ 3秒,其他语言6秒
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld

题目描述

There is a matrix A that has N rows and M columns. Each grid (i,j)(0 ≤ i < N, 0 ≤ j < M) is painted in white at first.
Then we perform q operations:
For each operation, we are given (xc, yc) and r. We will paint all grids (i, j) that meets to black.
You need to calculate the number of white grids left in matrix A.

输入描述:

The first line of the input is T(1≤ T ≤ 40), which stands for the number of test cases you need to solve.
The first line of each case contains three integers N, M and q (1 ≤ N, M ≤ 2 x 104; 1 ≤ q ≤ 200), as mentioned above.
The next q lines, each lines contains three integers x

c

, y

c

 and r (0 ≤ x

c

 < N; 0 ≤ y

c

 < M; 0 ≤ r ≤ 10

5

), as mentioned above.

输出描述:

For each test case, output one number.

输入例子:
2
39 49 2
12 31 6
15 41 26
1 1 1
0 0 1
输出例子:
729
0

-->

示例1

输入

复制

2
39 49 2
12 31 6
15 41 26
1 1 1
0 0 1

输出

复制

729
0

题意还是比较简单的,给你n和m的格子让你去画圆,如果这个点在圆内,就要被染色,问你还剩多少点没有被染色

这个题目可以直接暴力扫描线,也就成了维护线段的并

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+;
vector<pair<int,int> >V[N];
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
for(int i=; i<N; i++)V[i].clear();
int n,m,q;
scanf("%d%d%d",&n,&m,&q);
for(int j=,x,y,r; j<q; j++)
{
scanf("%d%d%d",&x,&y,&r);
for(int i=max(,y-r),d; i<=min(m-,y+r); i++)
d=(sqrt(r*r-(y-i)*(y-i)+1e-)),V[i].push_back(make_pair(max(,x-d),min(x+d,n-)));
}
int s=n*m;
for(int i=; i<m; i++)
{
int l=V[i].size();
if(l>)
{
sort(V[i].begin(),V[i].end());
int r=-;
for(auto X:V[i])
{
if(X.second<=r)continue;
if(X.first>r) s-=X.second-X.first+;
else s-=X.second-r;
r=X.second;
}
}
}
cout<<s<<"\n";
}
return ;
}

2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it的更多相关文章

  1. 2018 ACM 国际大学生程序设计竞赛上海大都会部分题解

    题目链接 2018 ACM 国际大学生程序设计竞赛上海大都会 下午午休起床被同学叫去打比赛233 然后已经过了2.5h了 先挑过得多的做了 .... A题 rand x*n 次点,每次judge一个点 ...

  2. 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it (扫描线)

    2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it (扫描线) 链接:https://ac.nowcoder.com/acm/contest/163/F来源:牛客网 时间 ...

  3. 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP)

    2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP) 链接:https://ac.nowcoder.com/acm/contest/163/ ...

  4. 2018 ACM 国际大学生程序设计竞赛上海大都会赛

    传送门:2018 ACM 国际大学生程序设计竞赛上海大都会赛 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛2018-08-05 12:00:00 至 2018-08-05 17:00:0 ...

  5. 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位dp)

    题目链接:https://ac.nowcoder.com/acm/contest/163/J 题目大意:给定一个数N,求区间[1,N]中满足可以整除它各个数位之和的数的个数.(1 ≤ N ≤ 1012 ...

  6. 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 A,D

    A链接:https://www.nowcoder.com/acm/contest/163/A Fruit Ninja is a juicy action game enjoyed by million ...

  7. 2018 ACM 国际大学生程序设计竞赛上海大都会 F - Color it (扫描线)

    题意:一个N*M的矩形,每个点初始都是白色的,有Q次操作,每次操作将以(x,y)为圆心,r为半径的区域涂成黑点.求最后剩余白色点数. 分析:对每行,将Q次操作在该行的涂色视作一段区间,那么该行最后的白 ...

  8. 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛-B-Perfect Numbers(完数)

    题目描述 We consider a positive integer perfect, if and only if it is equal to the sum of its positive d ...

  9. 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛-K-Matrix Multiplication(矩阵乘法)

    题目描述 In mathematics, matrix multiplication or matrix product is a binary operation that produces a m ...

随机推荐

  1. copyout函数

    copyout Kernel Service   Purpose Copies data between user and kernel memory. Syntax #include <sys ...

  2. SharePoint Server 2016 WEB 网站浏览器支持

    SharePoint Server 2016支持多种常用的Web浏览器,如Internet Explorer,Google Chrome,Mozilla Firefox,Apple Safari和Mi ...

  3. 将C4C Service Request中的summary和其他附件同步到ERP的Billing Request去

    C4C里将Service Request称为Work Ticket. 比如现在我的Service Request有两个行项目,只有第一个需要同步到ERP去.但是第二个行项目对于客户检查Invoice来 ...

  4. windows系统下使用.net简单操作redis

    首先.net需要引入如下几个文件,在gitub或者官网应该是有的: 然后配置一下redis服务器: 端口: IP: 然后先启动  redis-server.exe: 出现如下效果表示成功 再启动:re ...

  5. flash jquery 调用摄像头 vue chrome49浏览器

    flash jquery 调用摄像头 vue chrome49浏览器 这个摄像头,不能一个页面加载多个,只能一个页面显示一次,所以 调用的时候,记得加v-if 把组件销毁,然后从新加载新的 <! ...

  6. cityspace

    类别的网址:https://blog.csdn.net/u010069760/article/details/77847595 r,g,b:  250 170 160 parking   244 35 ...

  7. Java字符串池(String Pool)深度解析(转)

    出自  http://www.cnblogs.com/fangfuhai/p/5500065.html 在工作中,String类是我们使用频率非常高的一种对象类型.JVM为了提升性能和减少内存开销,避 ...

  8. shell脚本,awk里面的BEGIN讲解。

    解释: BEGIN{}这个特殊的pattern最常用的就是 变量赋值. BEGIN这个pattern就是文件没开始读的时候 执行 awk 'BEGIN{FS=":";OFS=&qu ...

  9. C++中有三种创建对象的方法

    #include <iostream> using namespace std; class A { private: int n; public: A(int m):n(m) { } ~ ...

  10. 01 Web框架介绍

    一.Web框架本质 所有的web应用程序本质上都是socket,用户的浏览器其实就是一个socket客户端. python中常用的web框架有: Django Flask web.py WSGI(we ...