04 2013 档案
摘要:判断是否有前缀...明显就是一个trie了...裸的不能再裸注意用动态的trie额外分配内存的时候会TLE...所以就用静态的...不过静态trie一开始还不太会用...不过后来感觉思路和静态邻接表感觉差不多...#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #in...
阅读全文
摘要:题目列表 > 无尽的编号时间限制: 1000ms 内存限制: 256MB描述在一条公路上,将要依次建造N座建筑。在每个建筑建成之后,都会用一个01串来给它编号。整条公路从起点到终点,所有建筑的编号都严格按照字典序递增的顺序来排列,而每在一个新的地方建起一个建筑时,它的编号会按以下规则确定:1) 编号要比前一个建筑(起点方向)的字典序大,比后一个建筑(终点方向)的字典序小3) 编号一定以1结尾2) 编号要尽可能短,满足该条件时,字典序尽可能小最开始时,公路的起点和终点上各有一个建筑,编号分别是0和1。接下来依次给出N个坐标 a1, a2, ..., aN,依次表示下一个建筑将要建造的位置,
阅读全文
摘要:一开始用邻接矩阵交TLE 分析以后发现 O(n^3) = 1500^3 必须超时但是对于 邻接表 O(m*n) = 1500 * 15000 对于两秒来说完全够了所以我把木板推倒重写了一遍二分图...还是挺有成就感的...至少以后的题目都可以用把原来低效的木板推掉了都忘记说题意了...就是给你一棵树, 求最小的点能覆盖所有的边...他们说用什么树形DP做我想想貌似也能搞...但这题对于二分图木板就完全就是裸题了然后这图是无向图,所以最后的结果要/2 这个应该很容易证明了 我就不赘述了二分图邻接表木板如下/********************* Template **************
阅读全文
摘要:substr()函数用法:substr(起始位置,长度)#include#includeusing namespace std;main(){ string s("12345asdf"); string a=s.substr(0,4); //获得字符串s中 从第0位开始的长度为4的字符串 cout#includeusing namespace std;main(){ string str1, str2 = "War and Peace"; str1.assign( str2, 4, 3 ); //str2 字符串的第4个字符位置开始赋值给str1,长度为
阅读全文
摘要:#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;//typedef long long LL;//typedef __int64 LL;//typedef long double DB;//typedef unisigned __int64 LL;
阅读全文
摘要:就算是水题了...因为K比较大所以在加起来的时候用分治矩阵快速幂也是用分治的思想所以就是分治+分治的一个水题了...做这个题主要是为了自己写个模板防止以后出类似的题傻逼调试不出来...#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;//typede
阅读全文
摘要:#include
#include
#include
#include
using namespace std;
#define LL long long
//#define __int64 LL
LL dp[22][3];
int pos[22];
//[][0] 包含49
//[][1] 最高位是9 但不含49
//[][2] 不含49
void initial()
{ dp[0][2]=1; for(int i = 1; i 10) { pos[cnt++] = a % 10; a /= 10; } pos[cnt]...
阅读全文