bzoj2957 樓房重建,分塊

2022-05-13 18:09:22 字數 1158 閱讀 4926

分塊沒學過的可以看,分塊入門。

題解:把房子分成√n塊每塊裡面維護乙個遞增的子串行,每次更新之後,在每乙個小塊內二分查詢第乙個大於前面最大的斜率,開始斜率為0,每次找完一塊更新一次,暴力加進答案。

#include#include

#include

#include

#include

#include

#include

#include

#include

#include

#define pb push_back

#define mp make_pair

#define ll long long

#define pi 3.14159265

#define ls l,m,rt<<1

#define rs m+1,r,rt<<1|1

#define eps 1e-7typedef unsigned

long

long

ull;

const

int mod=1e9+7

;const

int maxn=1e5+5

;const ll inf=0x3f3f3f3f

;const

int block=550

;using

namespace

std;

struct

bloc

a[1000

];int

n,m,num,belong[maxn],l[maxn],r[maxn];

double y;int

x;double

xl[maxn];

void

built()

for(int i=1;i<=num;i++)

r[num]=n;

}int slove(int x,double

y) a[p].cnt=cnt;

int ans=a[1].cnt;last=a[1].s[a[1].cnt-1

];

for(int i=2;i<=num;i++)

return

ans;

}int

main()

return0;

}

BZOJ2957 樓房重建 分塊

貌似是一道線段樹的題,然而線段樹太燒腦想不出來,只能暴力的玩分塊。分塊很好想的,維護 n 個塊,每塊都按照斜率單調遞增的標準來維護。查詢把所有塊for一遍。因為每個塊的斜率都是單調遞增的,對於每個塊使用二分可以節省一點點時間,就可以偷稅 愉悅 的accepted了 玩個斜率就不該用float 就為了...

bzoj 2957 樓房重建 分塊

time limit 10 sec memory limit 256 mb submit 2420 solved 1153 submit status discuss 小a的樓房外有一大片施工工地,工地上有n棟待建的樓房。每天,這片工地上的房子拆了又建 建了又拆。他經常無聊地看著窗外發呆,數自己能夠...

分塊 bzoj2957 樓房重建

orz 分塊大爺。思路很神奇也很清晰。把 塊內最值 和 塊內有序 兩種良好的性質結合起來,非常棒地解決了這個問題。圖中黑色的樓房即為每個塊內的 可視序列 顯而易見,在塊內它們的k 斜率 是單增的。由於上圖中第乙個塊的maxk比後面兩個塊的maxk都要大,所以後兩個塊對答案沒有貢獻,這也是顯然的。這就...