摘要: http://poj.org/problem?id=2182线段树,单点更新,单点查询#include <stdio.h>#define lson l, m, root<<1#define rson m+1, r, root<<1|1#define N 80008int sum[N<<2];void push_up(int root){ sum[root] = sum[root<<1] + sum[root<<1|1];}void build(int l, int r, int root){ int m; if(l == 阅读全文
posted @ 2013-03-12 11:30 Yuan1991 阅读(164) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=2945字符串,可以用字典树,我用qsort做的~ 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 5 char s[20010][23]; 6 int n, m; 7 8 int cmp(const void *a, const void *b) 9 {10 return strcmp((char *)a, (char *)b);11 }12 13 int main()14 {15 int i, sum[20010], 阅读全文
posted @ 2013-03-12 10:36 Yuan1991 阅读(124) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=2941随机算法 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <time.h> 4 5 int a[1234][1234], n, stack[1234]; 6 7 int check() 8 { 9 int i, j, temp, sum1 = 0, sum2, m;10 for(i=1; i<=n; i++)11 {12 sum1 += a[i][i];13 stack[i] = i;14 }15 m... 阅读全文
posted @ 2013-03-12 10:31 Yuan1991 阅读(186) 评论(0) 推荐(0)