摘要: P3294 [SCOI2016]背单词 贪心+Trie+dfs 贪心:对于一个串和他的前缀子串,尽可能把前缀放在前面 把后缀反向插转化为为前缀 trie插一遍 并查集重构树dfs求子树大小 按规则求和 Code #include<cstdio> #include<iostream> #include 阅读全文
posted @ 2022-10-31 13:56 watasky 阅读(26) 评论(0) 推荐(0) 编辑
摘要: Trie+dfs #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #include<bitset> using namespace std; const int N=500007; char s[10 阅读全文
posted @ 2022-10-31 11:41 watasky 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 题目传送门:P4683 [IOI2008] Type Printer 板子题 贪心+字典树+dfs 贪心:把最长的字符留在最后打或者最先打 把每个字母插入字典树 对trie树dfs一遍 #include<cstdio> #include<cstring> #include<iostream> #in 阅读全文
posted @ 2022-10-31 11:40 watasky 阅读(38) 评论(0) 推荐(0) 编辑