trie树
trieeeeeee
VL——MOESR
ga
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【2022年11月18日提高A组】首尾匹配【tire】
tire原创 2022-11-18 15:49:45 · 302 阅读 · 0 评论 -
【集训DAY N】词典【暴力】【字典树】
字典树原创 2022-08-16 18:59:52 · 94 阅读 · 0 评论 -
【集训DAY4】异或【字典树】
字典树原创 2022-08-08 19:46:14 · 170 阅读 · 0 评论 -
【YBTOJ进阶训练指导】lowbit求和【字典树trie】
思路:考虑lowbit:取出最低位的1异或:不同1,相同0那么直接建一个trie,如果碰到相同的就往下走,如果有分叉,那么加上贡献codecodecode#include<iostream>#include<cstdio>using namespace std;unsigned long long mod=199907210507;long long n, tot=1ll;long long a[6010101];long long trie[6010..原创 2022-02-18 00:00:00 · 310 阅读 · 0 评论 -
【YBTOJ】阅读理解
思路:这道题直接打板子,然后用一个数组标记一下就行了codecodecode#include<iostream>#include<cstdio>#include<cstring>using namespace std;int n, m, tot=1;int tire[500010][30];struct node{ int v[1010];}e[500010];void insert_s(string s, int l){ int..原创 2021-04-01 16:45:32 · 126 阅读 · 0 评论 -
【YBTOJ】最长异或路径
思路:我们可以先预处理出1~i的异或路径是多少,然后在他们中选两个异或最大的这样就转化成了最大异或对codecodecode#include<iostream>#include<cstdio>using namespace std;int n, head[100010], tot, a[100010];int trie[3000010][2];struct node{ int to, next, w;}b[200010];void add(int..原创 2021-03-27 08:17:02 · 120 阅读 · 0 评论 -
【YBTOJ】最大异或对
思路:首先异或是相同则0,不同则1,那我们考虑已经选了一个数,那么要使异或值尽可能大就要使最高位尽可能不等那么直接triecodecodecode#include<iostream>#include<cstdio>using namespace std;int n, m, tot=1;int a[1010010];int trie[1001000][2];void insert_n(int x){ int p=1; for(int i=31; i..原创 2021-03-26 21:25:51 · 140 阅读 · 0 评论 -
【YBTOJ】前缀统计
思路:直接一个trie树codecodecode#include<iostream>#include<cstdio>using namespace std;int n, m, tot=1;int trie[1001000][110];int e[100010];void insert_t(string s){ int lon=s.size(); int p=1; for(int i=0; i<lon; i++) { int c=s[i..原创 2021-03-26 20:06:01 · 131 阅读 · 0 评论 -
【Luogu_P1983】车站分级
链接思路:把没有停靠的车站向停靠了的车站连一条边,然后在拓扑排序#include<iostream>#include<cstdio>#include<cmath>#include<algorithm>#include<queue>#include<stack>#include<map>using namespace std;int n, m, tot;int pt[10010], now[10原创 2020-08-17 15:37:48 · 123 阅读 · 0 评论 -
【Luogu_P4017】最大食物链计数
链接思路:我们要设两个数组分别记录它的入度和出度,在拓扑排序时判断它是否是最高级消费者,就把它的总链数加起来代码:#include<iostream>using namespace std;int n,m,k,x,y,tot;struct node{ int next,to;}b[5000001];int head[5001],rd[5001],cd[5001],f[50005000],num[5001];void ljb(int x,int y){ tot++;原创 2020-08-17 11:22:13 · 193 阅读 · 0 评论 -
【Luogu_P1347】排序
题目链接思路:直接附代码#include<iostream>#include<cstdio>#include<cmath>#include<algorithm>#include<queue>#include<stack>#include<map>using namespace std;int n, m, tot, head[100], d[100], du[100], f[100100], v[1原创 2020-08-17 09:58:54 · 121 阅读 · 0 评论 -
【SSL2876】工程
Description张三是某工程公司的项目工程师。一天公司接下一项大型工程,该公司在大型工程的施工前,先要把整个工程划分为若干个子工程,并把这些子工程编号为1、2、…、N;这样划分之后,子工程之间就会有一些依赖关系,即一些子工程必须在某些子工程完成之后才能施工,公司需要工程师张三计算整个工程最少的完成时间。对于上面问题,可以假设:1、根据预算,每一个子工程都有一个完成时间。2、子工程之间的依赖关系是:部分子工程必须在一些子工程完成之后才开工。3、只要满足子工程间的依赖关系,在任何时刻可以有任何多原创 2020-08-16 21:21:47 · 144 阅读 · 0 评论 -
P1137 旅行计划
链接模板题,只不过在走的时候统计一下#include<iostream>using namespace std;int m,n,k,x,y,f[100000100],b[1000101],a[1000100];struct node{ int to,next;}b2[10001000];int tot,hd[10010010];void add(int x,int y...原创 2020-01-17 21:48:17 · 130 阅读 · 0 评论 -
08年东莞特长生 奖金
Description由于无敌的凡凡在2005年世界英俊帅气男总决选中胜出,Yali Company总经理Mr.Z心情好,决定给每位员工发奖金。公司决定以每个人本年在公司的贡献为标准来计算他们得到奖金的多少。 于是Mr.Z下令召开m方会谈。每位参加会谈的代表提出了自己的意见:“我认为员工a的奖金应该比b高!”Mr.Z决定要找出一种奖金方案,满足各位代表的意见,且同时使得总奖金数最少。每位员...原创 2020-01-17 19:57:29 · 128 阅读 · 0 评论
分享