2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it
链接:https://www.nowcoder.com/acm/contest/163/F
来源:牛客网
2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld
题目描述
Then we perform q operations:
For each operation, we are given (xc, yc) and r. We will paint all grids (i, j) that meets
You need to calculate the number of white grids left in matrix A.
输入描述:
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
-->
输出
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的更多相关文章
- 2018 ACM 国际大学生程序设计竞赛上海大都会部分题解
题目链接 2018 ACM 国际大学生程序设计竞赛上海大都会 下午午休起床被同学叫去打比赛233 然后已经过了2.5h了 先挑过得多的做了 .... A题 rand x*n 次点,每次judge一个点 ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it (扫描线)
2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it (扫描线) 链接:https://ac.nowcoder.com/acm/contest/163/F来源:牛客网 时间 ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP)
2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP) 链接:https://ac.nowcoder.com/acm/contest/163/ ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会赛
传送门:2018 ACM 国际大学生程序设计竞赛上海大都会赛 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛2018-08-05 12:00:00 至 2018-08-05 17:00:0 ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位dp)
题目链接:https://ac.nowcoder.com/acm/contest/163/J 题目大意:给定一个数N,求区间[1,N]中满足可以整除它各个数位之和的数的个数.(1 ≤ N ≤ 1012 ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 A,D
A链接:https://www.nowcoder.com/acm/contest/163/A Fruit Ninja is a juicy action game enjoyed by million ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会 F - Color it (扫描线)
题意:一个N*M的矩形,每个点初始都是白色的,有Q次操作,每次操作将以(x,y)为圆心,r为半径的区域涂成黑点.求最后剩余白色点数. 分析:对每行,将Q次操作在该行的涂色视作一段区间,那么该行最后的白 ...
- 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 ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛-K-Matrix Multiplication(矩阵乘法)
题目描述 In mathematics, matrix multiplication or matrix product is a binary operation that produces a m ...
随机推荐
- 事务回滚 DEMO
因为有些事物回滚 查询的时候 可能查出来空值 我们肯定不愿意把空值添加数据库里面 一般基本的是这么写 if (object_id('add_T_Disclose_DiscloseList', 'P' ...
- method 'redisConnectionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError
spring boot 整合redis是报了如下错误 org.springframework.beans.factory.UnsatisfiedDependencyException: Error c ...
- codeforecs Gym 100286B Blind Walk
交互式程序,要用到一个函数fflush,它的作用是对标准输出流的清理,对stdout来说是及时地打印数据到屏幕上,一个事实:标准输出是以『行』为单位进行的,也即碰到\n才打印数据到屏幕.这就可能造成延 ...
- [机器视觉] SIFT特征-尺度不变特征理解
SIFT特征-尺度不变特征理解 简介 SIFT,即尺度不变特征变换(Scale-invariant feature transform,SIFT),是用于图像处理领域的一种描述.这种描述具有尺度不变性 ...
- HTTP、HTTP2.0、HTTPS、SPDY
本文原链接:https://cloud.tencent.com/developer/article/1082516 HTTP,HTTP2.0,SPDY,HTTPS你应该知道的一些事 1.web始祖HT ...
- python_92_面向对象初体验
class dog: def __init__(self,name): self.name=name def bulk(self): print('%s汪汪汪!'%self.name) d1=dog( ...
- 安装python3.6 pip3 flake8
apt-get install python3-pip # Python3 ➜ ~ pip3 -V pip 9 ...
- JavaScript——图片懒加载
前言 有一个朋友问我这个问题,刚好有时间,现在就简单的写个Demo~ github | https://github.com/wangyang0210/bky/tree/picLoadLazy 内容 ...
- 万恶之源 Python
学IT真他妈难受 从早上起来坐到晚上 一天对着电脑啪啪啪
- JS实用技术
JS外部引用其他文件(建议) <script src="myScript1.js"></script> JS输出显示方式 使用 window.alert() ...