Solutions to the 14th Blue Bridge Cup C++ Group A

J flips the coin

can't write

I pixels

Enumerate row i

binary enumeration state

Then check(i) is legal, if it is legal, dfs(i+1)

check is the core
to judge whether the first row == A[i][j]
judge whether the i-th row is less than or equal to A and c+3>=A
judge whether the next row is less than or equal to A and c+6>=A

H XOR and sum

Just do it bit by bit.
For example,
5
1 2 3 4 5
bit=0 array becomes 10101
bit=1 array becomes 01100

Considering bit=0 alone, in the sense of modulo 2, the prefix sum becomes 11001 to
open an array c[2],
the contribution of this bit becomes sum+=c[1-b[i]]
and then record c[b[ i]]++

ans+=(1<<bit)*sum

G

Kruskal reconstructs a maximum tree. For each query,
I did not expect lca at the beginning. I also want to divide the answer to judge whether the connectivity from u to v can be constructed with an edge whose weight is greater than mid.

F

No, I played violently.
Blind guessing and one-handed half-search can handle it.

E

Heuristic merging on the tree
Maintain a ma[u] and sz[u]
ma represents the maximum number of colors
sz represents size
mp[u].size() represents color segment
judgment (sz%mp.size()==0 && sz /mp.size()==ma) ans++

D

Interval dp preprocessing

for(len=2~n)
	for(l=1~)
		int r=l+len-1;
		if(s[l]>s[r])f[l][r]=1;
		else if(s[l]==s[r])f[l][r]=f[l+1][r-1]

for(i=2~n)
	for(j)
		ans+=f[j][i];

cout<<ans

Guess you like

Origin blog.csdn.net/supreme567/article/details/130027829