清華集訓2014 簡單迴路 插頭DP

2021-09-03 01:10:09 字數 1312 閱讀 1856

鏈結

直接做q

qq次插頭dp得分為60

6060

。考慮題目中只詢問了豎直的邊,所以考慮分別做一遍前字尾插頭dp,記錄下每一行的每種輪廓線對應的方案數,詢問時合併輪廓線。

兩條輪廓線互補相當於把輪廓線上的邊連起來能形成乙個環,用並查集判就行了。

#include

using

namespace std;

typedef

long

long lint;

const

int maxn =

1005

, maxm =

10, mod =

1e9+7;

int n, m, k, g[maxn]

[maxm]

;unordered_map<

int,

int> f[2]

, pre[maxn]

, suf[maxn]

;int fa[maxn]

, q1[maxn]

, q2[maxn]

;inline

intgi()

inline

void

inc(

int&a,

int b)

intfind

(int x)

void

solve

(int d, unordered_map<

int,

int> sum[maxn]

)elseif(

!b1 &&

!b2)

elseif(

!b1 ||

!b2)

else

if(b1 ==

1&& b2 ==1)

}}else

if(b1 ==

2&& b2 ==2)

}}else

if(b1 ==

2&& b2 ==1)

inc(f[now ^1]

[s], v);}

}}swap

(sum[d ==

1? n :1]

, f[now ^1]

);}int

main()

}if(s ==1)

inc(ans,

(lint)it1 -

> second * it2 -

> second % mod);}

}printf

("%d\n"

, ans);}

return0;

}

清華集訓 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,...