国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

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

做電影網(wǎng)站還能賺錢seo在線優(yōu)化技術(shù)

做電影網(wǎng)站還能賺錢,seo在線優(yōu)化技術(shù),WordPress谷歌字體會(huì)慢,陜西網(wǎng)站建設(shè)多少錢普通子樹哈希 樹上的很多東西都是轉(zhuǎn)化成鏈上問(wèn)題的,比如樹上哈希 樹上哈希,主要是用于樹的同構(gòu)這個(gè)東西上的 什么是樹的同構(gòu)? 如圖,不考慮節(jié)點(diǎn)編號(hào),三棵樹是同構(gòu)的 將樹轉(zhuǎn)化成鏈,一般有兩種方式&#xf…

普通子樹哈希

樹上的很多東西都是轉(zhuǎn)化成鏈上問(wèn)題的,比如樹上哈希
樹上哈希,主要是用于樹的同構(gòu)這個(gè)東西上的
什么是樹的同構(gòu)?

如圖,不考慮節(jié)點(diǎn)編號(hào),三棵樹是同構(gòu)的

將樹轉(zhuǎn)化成鏈,一般有兩種方式:環(huán)游歐拉序與歐拉序
為了盡可能減少哈希沖突,進(jìn)制位越小越好
又因?yàn)椴豢紤]節(jié)點(diǎn)編號(hào),很明顯,若是采用歐拉序的話,得要記錄該節(jié)點(diǎn)孩子數(shù)
環(huán)游歐拉序只用進(jìn)入打上1,出來(lái)打上2即可搞定
小tips:歐拉序相較于環(huán)游歐拉序可能更快,請(qǐng)量力而行

于是,就可以采用普通的哈希方式啦!

指定范圍子樹哈希

如果說(shuō)是將子樹橫著割一刀呢?
如圖,是一棵樹

放心,就60個(gè)節(jié)點(diǎn)
我們考慮D節(jié)點(diǎn)的子樹中,距離D不超過(guò)3的所有點(diǎn)
如圖

接著是環(huán)游歐拉序(考慮在某些原因的份上,我只保留D的子樹)

為什么我只寫到10?因?yàn)樽髡邔?shí)在太懶因?yàn)榈?0就夠了
對(duì)于范圍樹上哈希,我們有兩種方式——拼接與刪除
因?yàn)楣R话阍谌∧5囊饬x下,所以,刪除是非常難以做到的~~(作者親測(cè)過(guò))~~
那只剩下拼接了,這個(gè)就和鏈上拼接一模一樣了(也很像是前綴和)

模板題


題目主要考的是范圍樹上哈希

如果說(shuō)看懂了前面的,這題就不難了。首先可以二分。因?yàn)槿羰?span id="ieo6y2aa" class="katex--inline"> k k k是答案,那么一定存在兩個(gè)節(jié)點(diǎn)的 k k k層子樹是同構(gòu)的。在其中任選兩個(gè)對(duì)應(yīng)的點(diǎn),所組成的子樹的子樹一定是同構(gòu)的
這么說(shuō)顯得很煩,翻譯成人化就是:對(duì)于每個(gè)符合題目要求的 k k k層的兩個(gè)子樹(就是這兩個(gè)字叔同構(gòu)),他們的所有子樹中一定有同構(gòu)的,并且層數(shù)有 0 0 0、有 1 1 1、有 ? \cdots ?、有 k ? 1 k-1 k?1

于是,題目就這樣轉(zhuǎn)化成了求是否存在同構(gòu)的 k k k層子樹
我們可以對(duì)于每個(gè)節(jié)點(diǎn),求出它的 k k k層祖先,代表這個(gè)節(jié)點(diǎn)絕對(duì)存在 k k k層子樹;
再找出 k + 1 k+1 k+1曾祖先,代表這個(gè)節(jié)點(diǎn)的子樹將要在他的祖先的子樹中被刪去(不被添加)
最后用一個(gè)map(建議使用gp_hash_table)統(tǒng)計(jì)答案
題目就這么結(jié)束了

代碼

#pragma GCC optimize(1, "inline", "Ofast")
#pragma GCC optimize(2, "inline", "Ofast")
#pragma GCC optimize(3, "inline", "Ofast")
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
namespace IO {
class input {
private:bool isdigit(char c) { return ('0' <= c && c <= '9'); }public:input operator>>(int &x) {x = 0;bool y = 1;char c = getchar();while (!isdigit(c)) y &= (c != '-'), c = getchar();while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();if (!y)x = -x;return *this;}input operator>>(short &x) {x = 0;bool y = 1;char c = getchar();while (!isdigit(c)) y &= (c != '-'), c = getchar();while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();if (!y)x = -x;return *this;}input operator>>(bool &x) {x = 0;bool y = 1;char c = getchar();while (!isdigit(c)) y &= (c != '-'), c = getchar();while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();if (!y)x = -x;return *this;}input operator>>(long &x) {x = 0;bool y = 1;char c = getchar();while (!isdigit(c)) y &= (c != '-'), c = getchar();while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();if (!y)x = -x;return *this;}input operator>>(long long &x) {x = 0;bool y = 1;char c = getchar();while (!isdigit(c)) y &= (c != '-'), c = getchar();while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();if (!y)x = -x;return *this;}input operator>>(__int128 &x) {x = 0;bool y = 1;char c = getchar();while (!isdigit(c)) y &= (c != '-'), c = getchar();while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();if (!y)x = -x;return *this;}input operator>>(unsigned int &x) {x = 0;bool y = 1;char c = getchar();while (!isdigit(c)) y &= (c != '-'), c = getchar();while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();if (!y)x = -x;return *this;}input operator>>(unsigned short &x) {x = 0;bool y = 1;char c = getchar();while (!isdigit(c)) y &= (c != '-'), c = getchar();while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();if (!y)x = -x;return *this;}input operator>>(unsigned long &x) {x = 0;bool y = 1;char c = getchar();while (!isdigit(c)) y &= (c != '-'), c = getchar();while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();if (!y)x = -x;return *this;}input operator>>(unsigned long long &x) {x = 0;bool y = 1;char c = getchar();while (!isdigit(c)) y &= (c != '-'), c = getchar();while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();if (!y)x = -x;return *this;}input operator>>(unsigned __int128 &x) {x = 0;bool y = 1;char c = getchar();while (!isdigit(c)) y &= (c != '-'), c = getchar();while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();if (!y)x = -x;return *this;}input operator>>(double &x) {x = 0;bool y = 1;char c = getchar();while (!isdigit(c)) y &= (c != '-'), c = getchar();while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();if (!y)x = -x;if (!isdigit(c))if (c != '.')return *this;double z = 1;while (isdigit(c)) z /= 10., x = x + z * (c ^ 48), getchar();return *this;}input operator>>(long double &x) {x = 0;bool y = 1;char c = getchar();while (!isdigit(c)) y &= (c != '-'), c = getchar();while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();if (!y)x = -x;if (!isdigit(c))if (c != '.')return *this;double z = 1;while (isdigit(c)) z /= 10., x = x + z * (c ^ 48), c = getchar();return *this;}input operator>>(float &x) {x = 0;bool y = 1;char c = getchar();while (!isdigit(c)) y &= (c != '-'), c = getchar();while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();if (!y)x = -x;if (!isdigit(c))if (c != '.')return *this;double z = 1;while (isdigit(c)) z /= 10., x = x + z * (c ^ 48), c = getchar();return *this;}input operator>>(std::string &x) {char c = getchar();x.clear();while (!(c != ' ' && c != '\n' && c != '	' && c != EOF && c)) c = getchar();while (c != ' ' && c != '\n' && c != '	' && c != EOF && c) {x.push_back(c);c = getchar();}return *this;}input operator>>(char *x) {char c = getchar();int cnt = 0;while (!(c != ' ' && c != '\n' && c != '	' && c != EOF && c)) c = getchar();while (c != ' ' && c != '\n' && c != '	' && c != EOF && c) {x[cnt++] = c;c = getchar();}return *this;}input operator>>(char x) {x = getchar();return *this;}
} pin;
};  // namespace IO
inline void wt(char ch) { putchar(ch); }
template <class T>
inline void wt(T x) {static char ch[40];int p = 0;if (x < 0)putchar('-'), x = -x;doch[++p] = (x % 10) ^ 48, x /= 10;while (x);while (p) putchar(ch[p--]);
}
template <class T, class... U>
inline void wt(T x, U... t) {wt(x), wt(t...);
}
#define int unsigned long long
const int N = 1e5 + 7;
int n;
const int M = 2e5 + 7;
struct edge {int v, w, nxt;
} e[M];
int head[N], ct;
const int T = 19, K = 3;
int ll[N], x[M], nx[N];//x一定要開兩倍!!!
int l[N], r[N];
int tp;
int getpw(int d) { return ll[d]; }
void addE(int u, int v, int w = 0) {e[++ct] = { v, w, head[u] };head[u] = ct;
}
void saddE(int u, int v, int w = 0) { addE(u, v, w), addE(v, u, w); }
int fa[N][T + 1];
__gnu_pbds::gp_hash_table<int, bool> cun;
void getx(int u = 1, int faa = 0) {l[u] = ++tp;x[tp] = (x[tp - 1] * K + 1);fa[u][0] = faa;for (int i = head[u]; i; i = e[i].nxt) {int v = e[i].v;getx(v, u);}r[u] = ++tp;x[tp] = (x[tp - 1] * K + 2);
}
int ytl[N];
typedef pair<int, int> pii;
vector<pii> vt[N];
bool chk(int mid) {memset(nx, 0, sizeof nx);cun.clear();memset(ytl, 0, sizeof ytl);for (int i = 1; i <= n; i++) vt[i].clear();for (int i = 1; i <= n; i++) {int tl = i;for (int j = T, k = mid; ~j; j--)if ((1ull << j) <= k)k -= (1ull << j), tl = fa[tl][j];if (tl == 0)continue;ytl[tl] = 1;tl = fa[tl][0];if (tl == 0)continue;// out<<i<<" "<<tl<<endl;vt[tl].push_back(pii(l[i], i));}for (int i = 1; i <= n; i++) sort(vt[i].begin(), vt[i].end());bool flg = 0;for (int i = 1; i <= n; i++) {if (!ytl[i])continue;int lr = l[i];for (auto j : vt[i]) {int k = j.second;//	cout<<k<<endl;(nx[i] *= getpw(l[k] - lr));(nx[i] += x[l[k] - 1] - (x[lr - 1] * getpw(l[k] - lr)));//	cout<<x[l[k]-1]<<" "<<x[lr-1]<<" "<<nx[i]<<endl;lr = r[k] + 1;}(nx[i] *= getpw(r[i] - lr + 1));(nx[i] += x[r[i]] - (x[lr - 1] * getpw(r[i] - lr + 1)));if (cun[nx[i]])return 1;// cout<<nx[i]<<endl;cun[nx[i]] = 1;//	cout<<nx[i]<<endl;//	puts("");}return flg;
}
main() {freopen("tree.in", "r", stdin);freopen("tree.out", "w", stdout);ll[0] = 1;for (int i = 1; i < N; i++) ll[i] = (ll[i - 1] * K);IO::pin >> n;for (int i = 1, x, y; i <= n; i++) {IO::pin >> x;while (x--) IO::pin >> y, addE(i, y);}getx();for (int j = 1; j <= T; j++)for (int i = 1; i <= n; i++) fa[i][j] = fa[fa[i][j - 1]][j - 1];int l = 0, r = n - 1;while (l < r) {int mid = l + r + 1 >> 1;// cout<<l<<" "<<r<<" "<<mid<<endl;if (chk(mid))l = mid;elser = mid - 1;}printf("%llu\n", l);
}
http://aloenet.com.cn/news/33504.html

相關(guān)文章:

  • 湖南高端網(wǎng)站制百度地圖關(guān)鍵詞優(yōu)化
  • 易企秀怎么做招聘網(wǎng)站超鏈接全國(guó)疫情的最新數(shù)據(jù)
  • 常州做網(wǎng)站公司哪家好廣東做seo的公司
  • 西寧微網(wǎng)站建設(shè)拉新充場(chǎng)app推廣平臺(tái)
  • 論述政府門戶網(wǎng)站建設(shè)的基本意義百度優(yōu)化大師
  • phpcms手機(jī)網(wǎng)站長(zhǎng)沙百度推廣運(yùn)營(yíng)公司
  • 做網(wǎng)站為什么要買網(wǎng)站空間百度的seo排名怎么刷
  • 網(wǎng)站設(shè)計(jì)策劃書 模板營(yíng)銷號(hào)
  • 做直播網(wǎng)站軟件有哪些軟件下載海外域名
  • 哪種源碼做視頻網(wǎng)站好用知乎軟文推廣
  • 一臺(tái)電腦主機(jī)做網(wǎng)站國(guó)際新聞最新消息十條
  • 怎么做類似清風(fēng)dj網(wǎng)站自己做一個(gè)網(wǎng)站
  • 互聯(lián)網(wǎng)信息服務(wù)許可證做優(yōu)化關(guān)鍵詞
  • 開遠(yuǎn)市住房和城鄉(xiāng)建設(shè)局網(wǎng)站網(wǎng)絡(luò)營(yíng)銷的特點(diǎn)主要包括什么
  • 小程序官方開發(fā)文檔沈陽(yáng)企業(yè)網(wǎng)站seo公司
  • wordpress配置cdn緩存規(guī)則博客可以做seo嗎
  • 怎么用python做網(wǎng)站網(wǎng)絡(luò)運(yùn)營(yíng)工作內(nèi)容
  • 廣東兩學(xué)一做考試網(wǎng)站今天的病毒感染情況
  • 有趣的網(wǎng)站設(shè)計(jì)最新百度關(guān)鍵詞排名
  • 深圳住建網(wǎng)站專業(yè)網(wǎng)絡(luò)推廣機(jī)構(gòu)
  • 電腦個(gè)人網(wǎng)站怎么做外貿(mào)建站
  • 做天貓還是做網(wǎng)站推廣怎么開通百度推廣賬號(hào)
  • 重慶設(shè)計(jì)公司網(wǎng)站宣傳營(yíng)銷方式有哪些
  • 深圳企業(yè)網(wǎng)站制作公司怎樣做運(yùn)營(yíng)需要具備什么能力
  • html電子商務(wù)網(wǎng)站模板下載網(wǎng)絡(luò)平臺(tái)怎么推廣
  • 鶴壁網(wǎng)站推廣公司seo資訊網(wǎng)
  • 品牌網(wǎng)站建設(shè) 杭州外貿(mào)seo優(yōu)化
  • 上海石化有做網(wǎng)站設(shè)計(jì)的嗎專業(yè)代寫軟文
  • 適合女生做的網(wǎng)站清遠(yuǎn)seo
  • 優(yōu)化教程網(wǎng)站推廣排名搜索引擎優(yōu)化實(shí)訓(xùn)報(bào)告