当前位置:网站首页>Luogu P1110 report statistics multiset stl good question

Luogu P1110 report statistics multiset stl good question

2022-08-09 07:40:00 swust_fang

Question link

In the beginning, what I thought was that multiset maintains the order structure, and then finds the predecessor and successor of the current point added when all the value differences are the smallest, and then uses the line segment tree to maintain a minimum difference value when looking for two adjacent ones~,But later found out that it is global, just open another multiset to maintain the difference between adjacent segments, but it is time-consuming to delete the set, not all adjacent points are installed in the set, such as adding in a certain segmentAt one point, the difference of the previous point is directly stored with an ans to store the minimum value, and then the minimum value in the set of the output time difference can be compared with ans.

#include#include#include#include#include#include#include#include#include#include#include#define myself i,l,r#define lson i<<1#define rson i<<1|1#define Lson i<<1,l,mid#define Rson i<<1|1,mid+1,r#define half (l+r)/2#define inff 0x3f3f3f3f#define lowbit(x) x&(-x)#define PI 3.14159265358979323846#define min4(a, b, c, d) min(min(a,b),min(c,d))#define min3(x, y, z) min(min(x,y),min(y,z))#define pii make_pair#define pr pair#define li __int128void print(li x) {if(x>9) print(x/10);putchar(x%10+48);}const int dir[4][2] = {0, -1, -1, 0, 0, 1, 1, 0};typedef long long ll;typedef unsigned long long ull;const ll inFF = 9223372036854775807;using namespace std;const int maxn=1e6+5;int st[maxn],ed[maxn];multiset s,ss;char str[20];int main(){int n,m,x,val;cin>>n>>m;int ans=inff,anss=inff;for(int i=1;i<=n;i++){scanf("%d",&x);st[i]=ed[i]=x;}for(int i=1;i<=n;i++){if(i

原网站

版权声明
本文为[swust_fang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/221/202208090700344471.html