摘要:
本来是并查集,我用BFS做的。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxm 2000005#define maxn 2005struct Edge{ int v, next;} edge[maxm];int m, n;int count, head[maxn];int q[maxn], front, rear;int sex[maxn];void addedge(i 阅读全文
posted @ 2011-05-22 15:53
undefined2024
阅读(233)
评论(0)
推荐(0)
摘要:
简单跳马搜索View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 26struct Point{ int x, y;} way[maxn * maxn];bool map[maxn][maxn];int p, q;bool found;int dir[8][2] ={{ -2, -1 },{ -2, 1 },{ -1, -2 },{ -1, 2 },{ 1, -2 },{ 阅读全文
posted @ 2011-05-22 15:08
undefined2024
阅读(752)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;#define maxn 1005int stamp[maxn];bool cmp(const int &a, const int &b){ return a > b;}int main(){ //freopen("t.txt", "r& 阅读全文
posted @ 2011-05-22 14:29
undefined2024
阅读(194)
评论(0)
推荐(0)
摘要:
最小生成树View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 505#define inf 0x3f3f3f3fint n, cost[maxn][maxn];bool vis[maxn];int lowcost[maxn];void input(){ scanf("%d", &n); for (int i = 0; i < n; i++ 阅读全文
posted @ 2011-05-22 13:19
undefined2024
阅读(318)
评论(0)
推荐(0)
摘要:
树状数组,难点在于处理相同区间,对于相同区间,只是把答案直接拷贝过来,并把其加入树状数组,不可以直接在树状数组中求和。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;#define maxn 100005struct Interval{ int s, e; int pos;} interval[maxn];int n;int ar[maxn] 阅读全文
posted @ 2011-05-22 11:45
undefined2024
阅读(412)
评论(0)
推荐(0)