摘要: int a[maxn]; vector<int>v; struct node{ int ch[2]; int s; }tr[maxn*22]; int root[maxn],idx; void build(int &x,int l,int r){ x=++idx; if(l==r)return; i 阅读全文
posted @ 2025-03-13 20:36 Marinaco 阅读(13) 评论(0) 推荐(0)
摘要: 题目链接:https://www.luogu.com.cn/problem/P4551 题意: 给定义一颗带权树,求其中两个节点边权异或和最大值 思路: 结论是:树上两个节点i,j由于 x ^ x=0 的异或性质,所以其异或和为(根节点,i)路径异或和 xor (根节点,j)路径异或和 所以dfs求 阅读全文
posted @ 2025-03-13 19:37 Marinaco 阅读(33) 评论(0) 推荐(0)
摘要: 用于快速求出一个序列 其中两个值 的xor最大值 由于 从高位到低位 找与给定数 数位相反 的路径 所以底层逻辑是贪心,并且正确性显然 struct trie{ int ch[maxn*31][2],idx; void insert(int x){ int p=0; for(int i=31;i>= 阅读全文
posted @ 2025-03-13 19:31 Marinaco 阅读(20) 评论(0) 推荐(0)
摘要: 记得每次输入样例时都要清空数组 此板子适用于求输入的字符串s有多少个(标准) struct trie{ int ch[maxn][80],cnt[maxn],idx; void build(){ for(int i=0;i<=idx;i++){ for(int j=0;j<79;j++){ ch[i 阅读全文
posted @ 2025-03-13 18:55 Marinaco 阅读(14) 评论(0) 推荐(0)
//雪花飘落效果