当前位置:网站首页>[diary of supplementary questions] [2022 Niuke summer school 1] c-grab the seat
[diary of supplementary questions] [2022 Niuke summer school 1] c-grab the seat
2022-07-24 02:24:00 【cls1277】
Pro
https://ac.nowcoder.com/acm/contest/33186/C
Sol
Through the explanatory diagram of the sample, we can find , The question is actually the number of points on the left of a broken line . According to the range of a point that can be seen, it can be known by the boundary of the screen , Figure to the right of this polyline It is the union of the area surrounded by each point in the graph and the connecting line between the upper and lower points on the screen .
Consider how to maintain this broken line , For each point, the slope of two lines can be maintained : The line between the point and the upper boundary of the screen ; The line between the point and the lower boundary of the screen . Next, consider why you can calculate the area in this way .

Take the line between the point and the lower boundary of the screen as an example , We enumerate the ordinates from small to large , For each ordinate, if you can find the abscissa of the point on the far right of the polyline , You can subtract to get the number of points that are not blocked , Summation is the answer .
We know , When the ordinate grows from small to large , A line with a small slope may be covered by a line with a large slope , So we save the maximum value of the slope when enumerating , As the slope of the line most likely to block to this point .
Because we maintain the slope , And because the enumeration is the ordinate , So we can directly find the coordinates of the intersection , Because the coordinates of the intersection point may be an integer , So here we have to consider whether we can get the intersection . It's easy to think , If the point is on the line of sight , You can't get , Therefore, the abscissa of the intersection should be subtracted e p s eps eps!!!
In this way, the abscissa value of the intersection can be maintained for each ordinate of the enumeration , The same is true for the other slope of maintenance , Because union set , So take the minimum value in the two cases . The sum of the abscissa of the final intersection is the answer .
Code
//By cls1277
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define Fo(i,a,b) for(LL i=(a); i<=(b); i++)
#define Ro(i,b,a) for(LL i=(b); i>=(a); i--)
#define Eo(i,x,_) for(LL i=head[x]; i; i=_[i].next)
#define Ms(a,b) memset((a),(b),sizeof(a))
#define endl '\n'
//const LL maxn = ;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef DEBUG
freopen("data.txt","r",stdin);
#endif
LL n, m, k, q; cin>>n>>m>>k>>q;
vector<set<LL>> a(m+1);
vector<pair<LL, LL>> b(k+1);
Fo(i,1,k) {
LL x, y; cin>>x>>y;
b[i] = {
x, y};
a[y].insert(x);
}
while(q--) {
vector<LL> ans(m+1, 0);
LL id, x, y; cin>>id>>x>>y;
a[b[id].second].erase(b[id].first);
b[id] = {
x, y};
a[y].insert(x);
Fo(i,1,m) {
if(!a[i].size()) ans[i] = n;
else ans[i] = (*a[i].begin())-1;
}
double mx = 0;
Fo(i,2,m) {
if(mx) ans[i] = (int)min((double)ans[i], (i-1)*1.0/mx-(1e-6));
if(!a[i].size()) continue;
double k = (i-1)*1.0/(*a[i].begin());
mx = max(mx, k);
}
mx = 0;
Ro(i,m-1,1) {
if(mx) ans[i] = (int)min((double)ans[i], (i-m)*1.0/mx-(1e-6));
if(!a[i].size()) continue;
double k = (i-m)*1.0/(*a[i].begin());
mx = min(mx, k);
}
LL res = 0;
Fo(i,1,m) res+=ans[i];
cout<<res<<endl;
}
return 0;
}
边栏推荐
- 1000 okaleido tiger launched binance NFT, triggering a rush to buy
- Go基础笔记_5_数组切片
- 我国科学家在高安全量子密钥分发网络方面取得新进展
- 微信小程序实现折线面积图-玫瑰图-立体柱状图
- MySQL---four JDBC
- 暗黑系王者,低照度图像增强技术解析
- Backward quantum cryptography migration! NIST announces 12 Partners
- Diablo king, analysis of low illumination image enhancement technology
- Cinq ans de contact avec près d'une centaine de patrons, en tant que chasseur de têtes, j'a i découvert que le secret de la promotion n'est que quatre mots
- 【补题日记】[2022杭电暑期多校1]C-Backpack
猜你喜欢

2022.7.22 JS entry common data types and methods

Writing of graph nodes that trigger different special effects during the day and at night in Tiktok

以科技传递温度,vivo守护生物多样性之美

IBM: realize the quantum advantage of fault tolerance by 2030

The combination sum of C language power deduction question 39. Backtracking method and traversal method

Digital transformation behind the reshaping growth of catering chain stores

我国科学家在高安全量子密钥分发网络方面取得新进展

Running around, market and quantitative page function optimization! Stock quantitative analysis tool qtyx-v2.4.5

ASP.NET CORE写一个缓存Attribute工具

ggplot2显示png
随机推荐
5年接触近百位老板,身为猎头的我,发现升职的秘密不过4个字
Emmet syntax summary
Qml- use listview to build a three-level treeview architecture
[important notice] the third phase of planet online training is coming! Explain how to build your own quantitative strategy on qtyx
Visual full link log tracking
NetApp FAS系列一个CIFS bug引起的控制器重启案例分享
STM32安装教程和J-link烧录驱动安装教程【第二天】
关于 SAP Fiori 应用的离线使用
Wenxin big model raises a new "sail", and the tide of industrial application has arrived
Draw pictures with canvas
Vue3 uses keep alive to cache pages, but every time you switch the tab to enter the page, it will still enter onmounted, resulting in no caching effect. Why?
Ardunio - ULN2003 drive board and DC motor fan - control fan speed
Leetcode 70 climbing stairs, 199 right view of binary tree, 232 realizing queue with stack, 143 rearranging linked list
This article shows you how to use SQL to process weekly report data
View Binding 混淆问题。我两天都在研究混淆。
Tdengine helps Siemens' lightweight digital solution simicas simplify data processing process
ACM SIGIR 2022 | interpretation of selected papers of meituan technical team
Crud operation of mongodb (2)
Phpcms realizes product multi condition screening function
【补题日记】[2022牛客暑期多校1]C-Grab the Seat