上一页 1 ··· 137 138 139 140 141 142 143 144 145 ··· 182 下一页
摘要: 题意:给出一个有向图,求一共有多少个点,满足这样的条件:所有其它的点都可以到达这个点。分析:强连通分支+缩点,然后统计每个强连通分支的出度,如果只有一个为0,则输出其内部点的个数,如果有多个为0,说明没有答案。View Code #include #include #include #include usingnamespace std;#define maxn 10005#define maxm 50005struct Edge{ int v, next;} edge[maxm], opedge[maxm];int n, m, head[maxn], ophead[maxn], nco... 阅读全文
posted @ 2011-06-05 00:21 undefined2024 阅读(906) 评论(0) 推荐(0)
摘要: 题意:1~n,乱序排列,告诉每个位置的前面的数字中比它小的数的个数,求每个位置的数字是多少分析:用树状数组来做,第i位如果是1,表示i在数列中的位置已经确定。全部读入到f[]后,从最后向前依次求出是几,因为每次对于未确定的最后一个数来说是可以根据它前面有多少数字比它小以及之前确定的数字(在它后面的数字)而确定它是几的。二分查找当前位置填几,设这个数字为a,应满足树状数组求和结果sum(a),即后面已经填好的比a小的个数,加上f[i],即前面比a小的个数,等于a-1。猜大了则结果大于a-1,猜小了则小于。找到后把树状数组第a位标1。时间复杂度为O((logn)^2 * n)View Code # 阅读全文
posted @ 2011-06-04 22:05 undefined2024 阅读(2159) 评论(0) 推荐(0)
摘要: 简单dpView Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;int n, even, odd;int main(){// freopen("t.txt", "r", stdin); scanf("%d", &n); if (n == 1) { int a; scanf("%d", &a); printf 阅读全文
posted @ 2011-06-04 21:25 undefined2024 阅读(224) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <algorithm>using namespace std;char st1[106], st2[106];int f1[27], f2[27];void make(char *st, int *f){ gets(st); for (int i = 0; i < strlen(st); i++) { if (st[i] >= ' 阅读全文
posted @ 2011-06-04 21:00 undefined2024 阅读(227) 评论(0) 推荐(0)
摘要: 二维树状数组,对于一个矩阵,迅速修改其一个点的值,迅速求其左上角连续子矩阵的和。对于每个翻转修改矩阵的四个角,对于询问求出该点的左上角矩阵和看奇偶性。#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 1005int c[maxn][maxn];int Row, Col;inline int Lowbit(const int &x){ return x & (-x);}int 阅读全文
posted @ 2011-06-04 20:44 undefined2024 阅读(1814) 评论(0) 推荐(1)
上一页 1 ··· 137 138 139 140 141 142 143 144 145 ··· 182 下一页