清華集訓2014 卡常數

2022-09-20 09:39:14 字數 2511 閱讀 8250

好像k-d樹也不是很難啊,為啥以前就學不會呢?

就把這道題當做k-d樹入門題好了,只需要記住k-d樹就是每次輪換一維分割空間即可。

uojdarkbzoj

題目大意:

\(1\le n,m\le 65536.\) 座標的絕對值在 \(100\) 以內。

值得注意的是題目建議開long double以保證精度,但是實際上double就可以過,而我的**開long double在darkbzoj上會t乙個點...

設函式 \(f(x)=ax-b\sin x\),加密後的值為 \(f(lastans\times 原值+1)\),乍一看完全不會,但是我們注意到 \(0\le a的關鍵條件,這決定了這個函式的單調性,於是可以二分解密。實數二分的小技巧是用次數作閾值而非精度。

接下來就是k-d樹的模板部分了,我們直接建樹,然後暴力詢問,用邊界判斷後剪枝,具體來說剪枝就是維護k-d樹的時候記錄一下子樹所圍成的長方體,然後判斷球與其是否有交,如果有再遞迴下去找。

而且由於這道題資料隨機,所以不需要用替罪羊的思路重新建樹,修改直接打刪除標記然後暴力插入即可。

不是很會算時間複雜度qwq

//12252024832524

//cz_xuyixuan orz

#include #define tt templateusing namespace std;

typedef long long ll;

const int maxn = 65536 << 2;

const int inf = 0x3f3f3f3f;

const double l = -100;

const double r = 100;

const double eps = 1e-6;

int n,m,nxt[3] = ;

double a,b,lst = 0.1;

ll read()

while(c >= '0' && c <= '9')

return x * f;

}double readf()

tt void put1(t x)

tt void put(t x,char c = -1)

tt t max(t x,t y)

tt t min(t x,t y)

tt t abs(t x)

int tot,rt,mode,pos[maxn];

struct point

};bool operator < (point p,point q)

struct infotmp[maxn];

bool operator < (info p,info q)

struct node

t[maxn];

double sq(double x)

double dis(point p,point q)

#define lc t[x].ch[0]

#define rc t[x].ch[1]

#define lx t[x].l.x

#define ly t[x].l.y

#define lz t[x].l.z

#define rx t[x].r.x

#define ry t[x].r.y

#define rz t[x].r.z

void up1(int x,int son)//pot1 & 4

void up(int x)

,t[x].r = point;

up1(x,lc); up1(x,rc);

}void build(int &x,int l,int r,int now)

void access(int x)

void ins(int &x,info val,int now)

mode = now;

if(val < t[x].info) ins(lc,val,nxt[now]),t[lc].fa = x;

else ins(rc,val,nxt[now]),t[rc].fa = x;

up(x);//do not forget to do it!

}void modify(int id,point p)

,0);

}double closest(int x,point p)

double farthest(int x,point p)

int query(int x,point p,double r)

void print(int x)

double f(double x)

double decrypt(double l,double r,double x)

return (l+r) / 2;

}int main()

); }

else//query

,r);

put((int)lst,'\n');

} }return 0;

}

清華集訓 2014 玄學

update text update 我之前講的是個什麼鬼 如果想看看人話版本 戳這。感覺自己被坑騙了。題目明明寫了所有資料不超過int,敢情是輸入資料不超int?迷惑行為 題目感覺有點繞,我盡量 不口胡。首先我們搞一顆線段樹1,樹表示插入序列的編號。如,在q行中第i個出現插入操作 其實拿到這道題我...

清華集訓2014 mex

有乙個長度為n的陣列。m次詢問,每次詢問乙個區間內最小沒有出現過的自然數。考慮用線段樹維護,維護什麼?我們把這些點分布在數軸上,那麼我們要在這個數軸上找到答案,就要把區間轉換到數軸上,也就是要維護每個數的下標。那麼滿足維護這個東西的,可以用權值線段樹。這樣,我們可以衍生出兩種做法 離線做法 把所有的...

46 清華集訓2014 玄學

一開始腦子進水了 把這題想簡單了 複雜度算錯了 每次都用nlogn的時間修改 而且還狂寫stl 然後就直播自爆8小時qaq。先掛個5分 include include include include include includeusing namespace std define rep i,j,...