摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1754线段树入门题:求区间段的最大值#include "iostream"#include "stdio.h"using namespace std;const int MAX = 200001;int big;struct node{ int r, l, max;}tree[MAX * 3];void Create(int t, int left, int right) //建树{ tree[t].l = left; tree[t].r = right; tree[t 阅读全文
摘要:
http://poj.org/problem?id=1129四色定理#include "stdio.h"#include "iostream"#include "cstring"using namespace std;bool g[27][27];int color[27];bool dfs(int nColor, int now, int n) //nColor:所用颜色总数;now:当前待填颜色的物品的编号{ if(now > n) return true; for(int i = 1; i <= nColor; i+ 阅读全文
摘要:
http://poj.org/problem?id=1164提交的时候正遇oj挂了,害我白白错了几次,却不知情。。。#include "iostream"#include "stdio.h"#include "string.h"using namespace std;struct room{ bool vis; int val;}castle[51][51];int area;void dfs(int x, int y){ if(!castle[x][y].vis) { area++; castle[x][y].vis = true; 阅读全文
摘要:
两道题都是求最小生成树的最长边。poj 2395 Out of Hay http://poj.org/problem?id=2395kruskal实现:#include "stdio.h"#include "string.h"#include "algorithm"#include "iostream"using namespace std;const int INF = 1e9, MAX = 2001;int fa[MAX];struct edge{ int s, e, val;};edge edges[1000 阅读全文
摘要:
第一次写SPFA,小激动一下。。。http://poj.org/problem?id=1511#include "iostream"#include "stdio.h"#include "queue"#include "string.h"using namespace std;const int MAX = 1000010;const int INF = 1e9;struct edge{ int s, e; int val; int nextedge;};struct edge edges1[MAX], edges 阅读全文