摘要: 只能说数据比较水而已结点应该得开到le10的,刚开始那么开的时候,编译出错了,说是数组开太大了,后来改成le6就过了。 1 #include 2 #include 3 const int maxnode=1e4; 4 int ch[maxnode][10]; 5 int val[maxnode]; 6 int sz; 7 void insert(char *s) 8 { 9 int u=0,n=strlen(s);10 for(int i=0;i=2) return 0;29 return 1;30 }31 int main()32 {33 int t;34 ... 阅读全文
posted @ 2013-08-26 13:20 sooflow 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 线段树单点更新 因为CASE之间的换行WA了两次 1 #include 2 #include 3 const int maxn=200000+5; 4 int sum[maxn>1;18 build(l,m,rt>1;30 if(x>1;41 int ret=0;42 if(Lm) ret+=query(L,R,m+1,r,rt<<1|1);44 return ret;45 }46 int main()47 {48 int n;49 while(scanf("%d",&n)&&n)50 {51 if(CASE!=1... 阅读全文
posted @ 2013-08-25 15:36 sooflow 阅读(323) 评论(0) 推荐(0) 编辑
摘要: 线段树加二分查找 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=50001; 6 const int INF=100000; 7 int sum[maxn>1; 36 build(l,m,rt>1; 46 sum[rt>1; 71 if(Lm) update(L,R,v,m+1,r,rt>1; 87 int ret=0; 88 if(Lm) ret+=query(L,R,m+1,r,rtlen-query(a,n,1,n,1))120... 阅读全文
posted @ 2013-08-25 14:39 sooflow 阅读(606) 评论(0) 推荐(0) 编辑
摘要: 好题。 1 #include 2 #include 3 #include 4 using namespace std; 5 int CASE=1; 6 const int maxn=500000+5; 7 typedef long long LL; 8 typedef pair Interval; 9 int qL,qR; 10 LL s[maxn]; 11 Interval max_sub[maxnsum(b)?a:b; 26 } 27 void build(int l,int r,int rt) 28 { 29 if(l==r) 30 { 31 m... 阅读全文
posted @ 2013-08-24 23:59 sooflow 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 这道题很狗血啊 赋值的时候那个v是大于等于0来着,主要考察区间赋值和更新,pushdown同时要有两个操作。代码如下: 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=1000000+5; 6 const int INF=1000000009; 7 int sum[maxn=0) 23 { 24 add[rt>1; 52 build(l,m,rt>1; 68 if(Lm) update(L,R,inc,m+1,r,rt>1; 84 if(Lm... 阅读全文
posted @ 2013-08-24 23:56 sooflow 阅读(383) 评论(0) 推荐(0) 编辑
摘要: 利用递推关系构建矩阵 然后矩阵快速幂 1 #include 2 #include 3 typedef long long LL; 4 const int mod=1000000007; 5 struct matrix 6 { 7 LL m[5][5]; 8 matrix(){memset(m,0,sizeof(m));} 9 matrix operator*(const matrix &a)const10 {11 matrix tmp;12 for(int i=0;i<5;i++)13 for(int j=... 阅读全文
posted @ 2013-08-21 15:02 sooflow 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 构建概率矩阵,然后矩阵快速幂,直接输出答案。 1 #include 2 #include 3 #include 4 using namespace std; 5 int n,m,k; 6 vector g[201]; 7 struct matrix 8 { 9 float m[201][201];10 matrix(){memset(m,0,sizeof(m));}11 matrix operator *(const matrix &a)const12 {13 matrix tmp;14 for(int i=0;i<n;i++)1... 阅读全文
posted @ 2013-08-21 14:59 sooflow 阅读(237) 评论(0) 推荐(0) 编辑
摘要: 第一道RMQ就因为vector没有清空而WA了。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=100000+5; 6 vector interval[maxn]; 7 int s[maxn]; 8 int value[maxn]; 9 int count[maxn];10 int num[maxn];11 int left[maxn];12 int right[maxn];13 int n,m;14 int d[maxn][100];15 int RMQ(int L,int R)16 {17 阅读全文
posted @ 2013-08-17 18:29 sooflow 阅读(191) 评论(0) 推荐(0) 编辑
摘要: //相同元素编号大较大 这么就可以避免处理有重复元素的情况。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=500000+5; 6 struct item 7 { 8 int num; 9 int id;10 bool operator a.id;13 return num>a.num;14 }15 }s[maxn];16 int n;17 int c[maxn];18 int lowbit(int x)19 {20 return x&-x... 阅读全文
posted @ 2013-08-17 16:08 sooflow 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=100000+5; 6 int c[maxn]; 7 int ans[maxn]; 8 struct pos 9 {10 int s,e;11 int id;12 bool operator s;15 return a.e0)26 {27 ret+=c[x];28 x-=lowbit(x);29 }30 return ret;31 }32 void ad... 阅读全文
posted @ 2013-08-16 19:23 sooflow 阅读(145) 评论(0) 推荐(0) 编辑