摘要: 题意:给定许多根木棒,两边分别涂有不同颜色,问能否将他们连成一条直线。规定只能将相同颜色的两端相连。思路:用TRIE树储存单词,TRIE树最后一个字母的节点编号就是这个单词的编号(可以和<map>类比)并查集检查是否连通——有欧拉路的前提是图连通最后加上无向图欧拉路的判定就好了~奇数度的节点只能有0或2个View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 #include <string> 5 #include <iostream&g 阅读全文
posted @ 2012-10-07 22:03 proverbs 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 求区间第k小值~详细注释见代码:View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 #include <algorithm> 5 #define M 100005 6 using namespace std; 7 int sorted[M],toleft[30][M],tree[30][M],m,n; 8 void read() 9 {10 for(int i=1;i<=m;i++)11 {12 scanf("%d",&am 阅读全文
posted @ 2012-10-07 09:25 proverbs 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 裸题~注意三维的前缀体积怎么算就好View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 5 #define N 120 6 7 using namespace std; 8 9 int n,c[N][N][N];10 11 inline int lowbit(int x)12 {13 return x&-x;14 }15 16 void updata(int x,int y,int z,int dt)17 {18 while(x<=n)19 {20 i 阅读全文
posted @ 2012-10-07 09:18 proverbs 阅读(275) 评论(0) 推荐(0) 编辑