日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

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

發(fā)布時(shí)間:2025/7/14 53 豆豆
生活随笔 收集整理的這篇文章主要介紹了 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

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

來(lái)源:??途W(wǎng)

2018 ACM 國(guó)際大學(xué)生程序設(shè)計(jì)競(jìng)賽上海大都會(huì)賽重現(xiàn)賽 F Color it

時(shí)間限制:C/C++ 3秒,其他語(yǔ)言6秒
空間限制:C/C++ 262144K,其他語(yǔ)言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. 示例1

輸入

復(fù)制 2 39 49 2 12 31 6 15 41 26 1 1 1 0 0 1

輸出

復(fù)制 729 0

題意還是比較簡(jiǎn)單的,給你n和m的格子讓你去畫圓,如果這個(gè)點(diǎn)在圓內(nèi),就要被染色,問你還剩多少點(diǎn)沒有被染色

這個(gè)題目可以直接暴力掃描線,也就成了維護(hù)線段的并

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

?

轉(zhuǎn)載于:https://www.cnblogs.com/BobHuang/p/9493577.html

《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。