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 ...
随机推荐
- apple-touch-icon-precomposed
<link rel="apple-touch-icon-precomposed" href=""> apple-touch-icon-precomp ...
- C语言的sprintf()和snprintf()
1.sprintf()函数 送格式化输出到字符串中,返回实际输出到字符串中的个数. 例如: char buffer[80]; sprint(buffer,"1234567890") ...
- 安装python3后,没有Scripts目录的解决办法
设置好python环境变量后,执行命令即可:python -m ensurepip
- jspscriptlet标签
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding= ...
- 洛谷 P3143 [USACO16OPEN]钻石收藏家Diamond Collector
题目描述 Bessie the cow, always a fan of shiny objects, has taken up a hobby of mining diamonds in her s ...
- coredata栈
上下文包含所有信息 NSManagedObjectModel The NSManagedObjectModel instance describes the data that is going to ...
- idea存留
1.导师匿名评价系统 类似看准网 2.在线降重软件 基于翻译api,或者后期写算法 在线查重导流 公众号: e搜罗
- 【PowerShell语音计算器】
[PowerShell语音计算器]带中文发音功能的计算器程序,支持鼠标和小键盘输入,支持多种数值转人民币大写,如:123.4--->壹佰贰拾叁点肆圆. 版本号 1.51 下载:http://fi ...
- mutt+msmtp做linux邮件客户端
mutt+msmtp做linux邮件客户端 1. 安装配置msmtp l 安装 wget https://sourceforge.net/projects/msmtp/files/msmtp/1.4 ...
- 作业题:闰年 if((year%4==0&&year%100!=0)||year&400==0)
作业题:闰年 if((year%4==0&&year%100!=0)||year&400==0)