- 博客(33)
- 收藏
- 关注
原创 QuickHull 快速凸包
#include #include #include using namespace std;struct Point{ double x, y; Point(double x = 0, double y = 0): x(x), y(y) {}};typedef Point Vector;typedef vector Polygon;double Cross(Vector
2016-05-24 19:54:17 3259
原创 UVA 1220 树形dp
#include using namespace std;const int INF = 0x3f3f3f3f;const int maxn = 2E2 + 10;vectorv[maxn];mapmp;int dp[maxn][3], n, tol;bool vis[maxn][3];void Treedp(int u){ if (v[u].size() == 0) {dp[
2016-05-24 15:06:57 351
原创 HDU 4819 二维线段树
#include #include #include #include #include const int maxn = 1E3 + 10;const int INF = 0x3f3f3f3f;using namespace std;struct Nodey{ int l, r; int Max, Min;};int locy[maxn], locx[maxn];st
2016-05-22 11:21:12 447
原创 HDU 4727 水题
#include #include const int maxn = 1E5 + 10;int T, n, inp[maxn], kase;int main(int argc, char const *argv[]){ scanf("%d", &T); while (T--) { scanf("%d", &n); for (int i = 0; i < n; i++)
2016-05-21 21:31:50 361
原创 HDU 4726 贪心
#include #include #include using namespace std;const int maxn = 1E6 + 10;char str1[maxn], str2[maxn], ans[maxn];int a[10], b[10], T, kase;vector>W[10], K[10];//W without 0,K within 0;void init
2016-05-21 21:29:42 441
原创 HDU 4722 规律
#include #include using namespace std;const int maxn = 20;int T, kase;long long a, b;int main(int argc, char const *argv[]){ // init(); scanf("%d", &T); while (T--) { scanf("%lld%lld", &a
2016-05-21 21:24:48 359
原创 HDU 4720 模拟退火
#include #include #include #include using namespace std;struct Point{ double x, y; Point(double x = 0, double y = 0): x(x), y(y) {} void read() { scanf("%lf%lf", &x, &y); }};typedef Poi
2016-05-21 21:21:58 414
原创 HDU 4717 三分
#include #include #include #include using namespace std;const int maxn = 3E2 + 10;const double eps = 1E-8;int n, T, kase;struct Point{ double x, y; Point(double x = 0, double y = 0): x(x),
2016-05-21 21:17:03 338
原创 HDU 4302 优先队列
#include #include #include #include using namespace std;const int INF = 0x3f3f3f3f;priority_queue, greater >r;priority_queue, less >l;int T, kase, n, L, t, cur, ans, num;int main(int argc, ch
2016-05-19 15:59:31 382
原创 HDU 5612 dfs
#include #include #include const int maxn = 100 + 10;const double eps = 1E-8;const int dir[][2] = {1, 0, 0, 1, -1, 0, 0, -1};char str[maxn][maxn];bool vis[maxn][maxn];int n, m, T;double sum;
2016-05-17 20:16:27 311
原创 HDU 5616 枚举子集
#include #include const int maxn = 100 + 10;int T, kase, n, m, k, inp[maxn], vis[maxn * maxn * 3];int main(int argc, char const *argv[]){ scanf("%d", &T); while (T--) { scanf("%d", &n); kase
2016-05-17 20:15:10 499
原创 HDU 2612 简单bfs
#include #include #include #include using namespace std;const int maxn = 2E2 + 10;const int INF = 0x3f3f3f3f;const int dir[][2] = {1, 0, 0, 1, -1, 0, 0, -1};int n, m, mp[maxn][maxn][2], dis[ma
2016-05-17 20:13:09 311
原创 HDU 5676 贪心
#include #include using namespace std;const int maxn = 1E6 + 10;long long res[maxn], n, len, T;void dfs(int a, int b, long long x){ if (a == b && x) res[len++] = x; if (a < 9) dfs(a + 1, b, x
2016-05-17 20:10:11 359
原创 HDU 1044 bfs+dfs
#include #include #include #include using namespace std;#define check(x,y) x>=0&&x=0&&y<m&&!vis[x][y]&&mp[x][y]!='*'const int maxn = 50 + 10;const int dir[4][2] = { -1, 0, 1, 0, 0, -1, 0, 1};i
2016-05-17 20:06:35 318
原创 HDU 1560 IDA*
#include #include const int maxn = 10;const char DNA[] = {"ACGT"};char str[maxn][maxn];int T, n, m, len[maxn], res[maxn];bool dfs(int* cur, int x, int dep){ int tmp[maxn]; for (int i = 0; i <
2016-05-17 20:02:26 380
原创 ZOJ 2412 dfs
#include #include #include using namespace std;const int dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, { -1, 0}};const int wat[][4] = {0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1,
2016-05-12 22:31:43 319
原创 ZOJ 1649 BFS
#include #include #include using namespace std;const int INF = 0x3f3f3f3f;const int maxn = 2E2 + 10;const int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, { -1, 0}};struct Node{ int x, y; int
2016-05-12 21:48:05 449
原创 POJ 1222 高斯消元法解开关问题
#include #include #include const int maxn = 30;int inp[maxn + 5][maxn + 5], kase, T;void gauss(){ for (int i = 0; i < maxn; i++) { int k = i; while (k < maxn && !inp[k][i])k++; for (int
2016-05-10 21:30:30 895
原创 POJ 2773 容斥与二分
#include #include const int maxn = 1E6 + 10;int p[maxn], cnt, m, k;void init(){ cnt = 0; for (int i = 2; i * i <= m; i++) if (m % i == 0) { p[cnt++] = i; while (m % i == 0) {m /= i;}
2016-05-10 15:55:26 423
原创 HDU 1796 容斥
#include #include #include using namespace std;const int maxn = 25;long long ans, inp[maxn];int n, m, t, len;long long gcd(long long a, long long b){ return b == 0 ? a : gcd(b, a % b);}long
2016-05-09 22:40:37 428
原创 0-1 背包 改良版
#include #include using namespace std;const int maxn = 200;template void Traceback(int n,Type w[],Type v[],Type p[maxn][maxn],int *head,int x[]);template Type Knapsack(int n,Type c,Type v[],Typ
2016-05-09 17:19:41 763
原创 HDU 3757 dp
#include #include #include #include using namespace std;const int maxn = 4E3 + 10;const long long INF = 1LL << 60;short path[maxn][maxn];long long f[maxn];struct Node{ long long d;
2016-05-08 22:17:52 647
原创 HDU 4902 线段树
#include #include #include #include using namespace std;const int maxn = 1E5 + 10;int T, m, n, inp[maxn], l, r, op, x;struct Node{ int l, r, val; bool update; std::vector X;};Node node[m
2016-05-03 18:07:01 538
原创 POJ 3164 最小树形图
#include #include #include #include using namespace std;const int maxn = 1E2 + 10;const int INF = 1 << 30;struct Edge{ int u, v; double w;};Edge edge[maxn * maxn];struct Node{ double x,
2016-05-02 22:37:16 404
原创 POJ 3254 状压dp
#include #include #include #include #include using namespace std;const int maxn = 1 << 10 + 10;const int MOD = 1E8;int dp[15][maxn], mp[15][15], n, m;std::vector vec[15];int fun(int x){ in
2016-05-02 21:51:59 311
原创 POJ 2947 高斯消元法解同余方程组
#include #include #include #include using namespace std;const int maxn = 1E3 + 10;const int MOD = 7;char s1[5], s2[5];int n, m, k, tmp, inp[maxn][maxn], x[maxn];int gcd(int a, int b){ if (b
2016-05-02 21:08:10 449
原创 POJ 1753 搜索
#include bool mp[6][6];int cnt;bool cmp(){ for (int i = 1; i <= 4; i++) for (int j = 1; j <= 4; j++) if (mp[i][j] != mp[1][1]) return 0; return 1;}void flip(int x, int y){ mp[x][y]
2016-05-02 19:56:47 387
原创 HDU 3085 双向BFS
#include #include #include #include using namespace std;const int maxn = 1e3 + 10;#define Dis(a,b) abs((a).x-(b).x)+abs((a).y-(b).y)int dir[4][2] = {{ -1, 0}, {1, 0}, {0, -1}, {0, 1}};bool vis
2016-05-02 16:13:27 355
原创 HDU 5386 构造
#include #include #define H (c[j] == 'H'?x[j]:i)#define L (c[j] == 'L'?x[j]:i)const int maxn = 5E2 + 10;char c[maxn];int T, n, m, inp[maxn][maxn], x[maxn], y[maxn], ans[maxn], cnt;int main(int
2016-05-02 13:51:49 333
原创 codeforce 401C 构造
#include #include using namespace std;int n, m;int main(int argc, char const *argv[]){ while (~scanf("%d%d", &n, &m)) { if (m 2 * n + 2) printf("-1"); else if (n >= m) { for (int i =
2016-05-01 21:42:00 374
原创 uva 11419 最大匹配
#include #include #include #include #include #include using namespace std;const int maxn = 1E4 + 5;int r, c, n, x, y;struct BPM{ int n, m; vectorG[maxn]; int left[maxn], right[maxn]; boo
2016-05-01 21:14:37 344
原创 HDU 3678 2-SAT
#include #include #include #include #include using namespace std;const int maxn = 2e5 + 10;int n, m, a, b, c;char s[100];int DFN[maxn], vis[maxn], low[maxn], Stack[maxn * 10], Belong[maxn], t
2016-05-01 20:10:17 417
原创 HDU 1236 强连通分量
#include #include #include #include using namespace std;const int maxn = 110;const int maxm = maxn * maxn;struct Edge{ int to, next;};Edge edge[maxm];int head[maxn], tol, v, n, low[maxn],
2016-05-01 20:03:46 349
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人