- 博客(24)
- 收藏
- 关注
原创 BZOJ 2440: [中山市选2011]完全平方数
二分,然后用莫比乌斯做就行了...#include using namespace std;typedef long long LL;const int maxn = 50005;int not_prime[maxn];int prime[maxn];int mu[maxn];int K, p_cnt;void Init(){ mu[1] = 1; p_cnt =
2015-09-30 15:06:24 611
原创 DP HDOJ 5492 Find a path
化简公式然后递推....#include using namespace std;typedef long long LL;const int INF = 0x3f3f3f3f;int dp[33][33][60 * 33];int g[33][33], n, m;void update(int &x, int y){ if(x > y) x = y;}void w
2015-09-29 20:00:14 416
原创 HDOJ 5483 Nux Walpurgis
先做出最小生成树,然后对每个点dfs判断树边是否可删.....#include using namespace std;typedef long long LL;const int maxn = 3005;const int maxm = 6005;const int INF = 0x3f3f3f3f;struct Edge{ int v; Edge *next;}E[
2015-09-29 14:51:43 426
原创 DP Codeforces Round #322 (Div. 2) F. Zublicanes and Mumocrates
树形dp,记录一下根节点的状态即可...#include using namespace std;typedef long long LL;const int maxn = 5005;const int maxm = 10005;const int INF = 0x3f3f3f3f;struct Edge{ int v; Edge *next;}E[maxm], *H[
2015-09-28 21:40:39 643
原创 HDOJ 5487 Difference of Languages
记dp[i][j] 代表走到了第一个dfa的i号节点,走到了第二个自动机的j号节点.....然后就可以转移了......#include using namespace std;typedef long long LL;const int maxn = 1005;struct node{ int s1, s2, pre, tran; node(int s1 = 0, int
2015-09-28 15:17:23 448
原创 HDOJ 5469 Antonidas 树分治
经典的树分治,找字符串用hash找就行了....#include using namespace std;typedef long long LL;#define mp(x, y) make_pair(x, y)const int maxn = 10005;const int maxm = 20005;const int INF = 0x3f3f3f3f;const int m
2015-09-28 13:12:10 428
原创 [DP] HDOJ 5456 Matches Puzzle Game
数位DP...#include using namespace std;typedef long long LL;LL dp[505][2][2][2];int cnt[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};int mod;void add(LL& a, LL b){ a += b; if(a > mod) a -= mod;}LL
2015-09-25 13:28:45 394
原创 [半平面交] HDOJ 5462 Manors
很容易就能看出半平面交的公式...但是比赛的时候这题看都来不及看...#include using namespace std;typedef long long LL;const int maxn = 1005;const double eps = 1e-7;struct Point{ double x, y; Point(double x = 0, double y =
2015-09-23 20:00:30 524
原创 [网络流] HDOJ 5457 Hold Your Hand
建出字典树,然后做最小割就行了...#include using namespace std;typedef long long LL;const int maxn = 5005;const int maxm = 400005;const int INF = 0x3f3f3f3f;struct Edge{ int v, c, next; Edge() {} Edge(i
2015-09-23 18:20:45 511
原创 [线段树] HDOJ Excited Database
把一个矩阵化成3个三角形容斥,然后用等差线段树就可以做了...#include using namespace std;typedef long long LL;#define now o, L, R, tree#define lson o << 1, L, mid, tree#define rson o << 1 | 1, mid+1, R, tree#define ls o
2015-09-21 20:13:26 428
原创 hihocoder #1236 : Scores
高维bitset....#include using namespace std;typedef long long LL;const int maxn = 50005;struct node{ int val, id; node(int val = 0, int id = 0) : val(val), id(id) {} bool operator < (const no
2015-09-21 14:28:32 735
原创 [动态树] HDOJ 5467 Clarke and hunger games
按时间点建树,然后递归实现LCT的可持久化....#include using namespace std;typedef long long LL;#define mp(x, y) make_pair(x, y)const int maxn = 300005;const int maxm = 300005;const int INF = 0x3f3f3f3f;const in
2015-09-21 10:07:57 540
原创 HDOJ 5458 Stability
由于没有看到图在任意时刻都是连通的..这一条件..于是只好打了动态树..#include using namespace std;typedef long long LL;const int maxn = 30005;const int maxm = 400005;struct Node *null;struct Node{ Node *fa, *ch[2]; int s
2015-09-19 18:44:40 429
原创 【NTT】 ZOJ 3874 Permutation Graph
推出公式以后分治ntt优化即可。。。#include using namespace std;typedef long long LL;const int maxn = 100005;const int maxm = 300005;const int mod = 786433;LL a[maxm], b[maxm], c[maxm];LL f[maxn], dp[maxn
2015-09-18 13:06:22 593
原创 【NTT】 HDOJ 5279 YJC plays Minecraft
推出公式以后就可以ntt了。。。#include using namespace std;typedef long long LL;const int mod = 998244353;const int maxn = 700005;LL dp[100005],dp2[100005];LL a[maxn], b[maxn], c[maxn], xp[maxn];LL f[100
2015-09-17 18:21:27 428
原创 【矩阵快速幂】 HDOJ 5434 Peace small elephant
对每一列状态压缩,然后矩阵加速即可。。。#include using namespace std;typedef long long LL;const int mod = 1e9+7;const int maxn = 130;LL mat[maxn][maxn];LL mid[maxn][maxn];LL res[maxn][maxn];int n, m;void ca
2015-09-16 14:04:13 354
原创 【树分治】 ZOJ Travel
离线每个询问,然后做树分治。。#include using namespace std;typedef long long LL;#define lowbit(x) (x&(-x))#define pii pair #define mp(x, y) make_pair(x, y)const int maxn = 100005;const int maxm = 200005;c
2015-09-16 11:08:54 317
原创 HDOJ 5448 Marisa’s Cake
计算每一条线段对答案的贡献,然后用前缀和优化就行了。。。。#include using namespace std;typedef long long LL;const int maxn = 100005;const int mod = 1e9+7;struct Point{ LL x, y; Point(LL x = 0, LL y = 0) : x(x), y(y) {
2015-09-14 15:53:01 402
原创 【NTT】 ZOJ 3899 State Reversing
先找出第二类斯特林数的公式,然后把公式分解成卷积的形式,先做一遍NTT,然后对于每次询问只要用线段树求出有多少个空闲的房间就可以了。#include using namespace std;typedef long long LL;#define lson o << 1, L, mid#define rson o << 1 | 1, mid+1, R#define ls o <<
2015-09-14 13:11:49 756
原创 【DP】 HDOJ 4804 Campus Design
轮廓线dp一下就行了。。和大白书上的轮廓线dp类似。。。#include using namespace std;typedef long long LL;const int maxn = 105;const int mod = 1e9+7;char g[maxn][11];int dp[2][1 << 10][22];int n, m, C, D;void add(in
2015-09-11 19:59:04 307
原创 【后缀自动机】 HDOJ 5431 AB String
在sam上做dp统计有多少的串不是a的子串,然后找到长度,dfs找串就行了。。#include using namespace std;typedef long long LL;const int alpha = 2;const int maxn = 40005;const int maxm = 25;struct node{ int len; LL cnt[maxm];
2015-09-06 16:20:28 379
原创 【polya】 HDOJ Count the Tetris
套用polya计算出奇偶,旋转,反射16钟情况的方案数。。import java.util.*;import java.io.*;import java.math.*;import java.lang.*;public class Main { public static void main(String args[]) { Scanner cin = new Scanne
2015-09-03 18:33:38 364
原创 【DP】HDOJ 5426 Rikka with Game
把子树合并到根上考虑三种转移。1)切断根与子树的边,建立外交。2)切断根与子树的边,不建立外交。3)不切断根与子树的边。#include using namespace std;typedef long long LL;const int maxn = 100005;const int maxm = 505;const LL INF = 4e18;struct Edge{
2015-09-02 10:16:07 477
原创 HDOJ 5425 Rikka with Tree II
和上次的上海邀请赛的那个dp优化技巧类似。都是考虑double精度,来减少枚举次数。。。#include using namespace std;typedef long long LL;const int maxn = 100005;const int maxm = 200005;struct Edge{ int v; Edge *next;}*H[maxn], E[m
2015-09-01 14:14:08 320
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人