自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(277)
  • 资源 (1)
  • 收藏
  • 关注

原创 Numbers Line

Come to play the interesting and addicitive puzzle game! Take adventure in the city, desert, farm with the farmer and grandson. Be prepared to line digital blocks and magic blocks with challenging le...

2018-10-21 22:17:56 354

原创 Four In A Row

一款利用Game Center Turn Base 框架实现的经典游戏

2016-05-28 13:56:36 1328

原创 hdu 4763 Theme Section kmp

这个next[i]表示的就是最长前后缀,那么头和尾的就不next就可以得出了 那么就剩下判断中间是否存在了,中间的只要不重叠的那部分存在一个next[j]大于的就可以了。 中间的部分是不断扩大的,那么就头尾不断next,中间不断更新新加入的节点即可。 #include #include #include using namespace std; const int maxn=1e6+9

2013-12-06 18:59:29 967

原创 hdu 4052 Adding New Machine 扫描线求矩形面积并

这个每一个矩形都确定了一个不能放的矩形空间,那么就是可以转化成求矩形面积并了。 #include #include #include #include #include #define ll long long #define midt (tr[t].l+tr[t].r>>1) #define ls t<<1 #define rs t<<1|1 using namespace std;

2013-12-04 15:04:52 937

原创 hdu 3667 Transportation 费用流

很明显的费用流的题目,把一条边拆成5条即可。 #include #include #include using namespace std; const int maxn=1e2+9; int n,m,p; int head[maxn],lon; struct { int next,to,c,w,from; }e[222222]; void edgeini() { mems

2013-11-30 23:31:04 908

原创 Codeforces Round #216 (Div. 2) D. Valera and Fools

这个题目很多人都是用记忆化搜索的办法来做的,确实这样比较不容易错并且好写。 不过我用了另外一种办法,枚举加判断, 判断dp[i][j]是否可行,首先计算前j-1个人死亡的最少回合数,然后再看看后i个人是否不存在神枪手,再判断j号人物是否具有杀伤力,然后再把之前的回合数加上杀死j到i的人的回合数,看看是否比k小,如果这些条件都满足,则这个状态可达。 然后剩下的问题就是怎么计算前j-1个人死亡的

2013-11-30 13:21:12 1267

原创 hdu 4117 GRE Words 11年成都现场赛

离线建树,然后按顺序把值插入,每插入一个值的时候就按着fail算出该节点的最优解。 一个优化,那些值小于0的节点直接去掉。 #include #include #include #include using namespace std; const int maxn=3e5+9,N=26,root=0,maxm=2e4+9; int cas=0; int lon; struct {

2013-11-29 15:14:44 899

原创 hdu 4114 dp

ans[i][j],i表示去过的景点和拿到的票的状态,j表示现在在哪个景点。 然后spfa即可 #include #include #include using namespace std; const int maxn=59; int n,m,p; int cost[10][2]; int a[maxn][10],top[maxn]; int num[maxn]; int tt=0;

2013-11-26 22:15:11 1013

原创 hdu 4125 树状数组+kmp

这个建树的过程用了树状数组+二分找区间的做法,很麻烦。 #include #include #include #include #include using namespace std; const int maxn=6e5+9; int a[maxn]; char s[maxn<<1]; int top,tt=0,f[maxn]; char c[maxn]; int n; int l

2013-11-26 19:43:20 708

原创 csdn 4090 GemAnd Prince

写了个最朴素的dfs #include #include #include using namespace std; int a[10][10],sum[10],ans; int n,m,k; int quex[111],quey[111],front,end; bool chk(int t,int s,int use[10][10]) { int ret=0; int x

2013-11-25 21:15:11 777

原创 hdu 4085 斯坦纳树

#include #include #include using namespace std; const int maxm=11e2+9,maxn=10e1+9; int dp[maxm][maxn],num[maxn],d[maxn][maxn]; int n,m,k; bool visit[maxn],chk[maxm]; void getdp() { memset(dp,50

2013-11-25 16:59:03 1111

原创 hdu 4123 Bob’s Race 树形dp+单调队列

树形dp求树上最长距离,然后单调队列维护。 #include #include #include #include using namespace std; const int maxn=5e4+9; vector > e[maxn]; int n,m; int dist[maxn][2]; void dfs(int t,int from) { for(vector >::

2013-11-24 18:25:33 928

原创 hdu Holiday's Accommodation dfs

#include #include #include #include #define ll long long #pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const int maxn=1e5+9; vector > e[maxn]; int n; int son[maxn]

2013-11-24 02:39:45 1051

原创 hdu 4115 Eliminate the Conflict

2sat题目,正确理解2sat即可。 #include #include #include using namespace std; const int maxn=(1e4+9)*2; int n,m; int a[maxn][2]; int dfn[maxn],low[maxn],stack[maxn],instack[maxn],s[maxn],un[maxn]; int count

2013-11-24 02:05:48 1195

原创 poj 1389

求矩形的面积并 #include #include #include #include using namespace std; const int maxn=1101; int ans; struct { int l,r,x; int y1,y2; bool ture; int count; }tr[10000]; struct data {

2013-11-23 20:59:15 957

原创 hdu 4059 The Boss on Mars 容斥原理

容斥原理的题目,用容斥来做还是比较明显,关键是要去推那个4次方的公式。 然后注意公式里面要除以30,那么就先求%(mod*30),然后再除以30再%mod。 #include #include #include #include #define ll long long using namespace std; const ll mod=1e9+7; int a[1111],lon;

2013-11-23 20:30:57 921

原创 hdu 4089 概率dp

带循环的概率dp 但是这个题目的问题是精度很难处理,为什么不特判p4就a不了,表示不能理解。 #include #include #include using namespace std; const int maxn=2e3+9; int n,m,k; double p1,p2,p3,p4; double dp[maxn][maxn]; void solve() { mems

2013-11-23 16:01:48 893

原创 poj 2151 Check the difficulty of problems dp

概率dp的题目,不过我的做法可能比较不一样,先计算出每个人答对1~n-1,n~m道题目的概率。 然后dp[i][0] 表示前i个人,有一个人至少答对n道题,并且每个人至少一个题目的概率。 dp[i][1] 表示前i个人,每个人至少答对一道题目的概率。 状态转移就很明显了。 #include #include #include using namespace std; const in

2013-11-22 14:09:33 931

原创 hdu 4468 spy kmp+dp

首先可以用递推的思想来考虑,如果已经求得了dp[i]的答案,怎么得到dp[i+1]的答案。这个dp值是不考虑最后一个字符需要完整的。 只需要判断所有以i+1个字符为结尾的串中有没有一个是现在的模式串的前缀,有的话证明dp[i]的值就是dp[i+1]的值。 否则这个i+1号字符及它之前的还未匹配的串就一定要加入到模式串中。 #include #include #include using

2013-11-20 21:34:38 1304

原创 hdu 4704 费马小定理

费马小定理+快速幂 费马小定理可以用来求解a的高次幂mod质数的值。前提是a与质数互质。 #include #include #include using namespace std; const int maxn=1e6+9,mod=1e9+7; char a[maxn],s[111]={0,'1','0','0','0','0','0','0','0','0','6'}; bool

2013-11-20 14:42:37 1061

原创 hdu 4248 A Famous Stone Collector dp+组合数学

预处理出c[10000][100],然后dp递推。 #include #include #include #define ll long long using namespace std; const int maxn=1e4+9,mod=1e9+7; ll dp[maxn],c[maxn][111]; int a[maxn]; int n,sum; ll getdp() { m

2013-11-19 23:32:32 1118

原创 2013 成都 hdu 4784 Dinner Coming Soon dp

这个题目虽然描述的比较麻烦,但是还是不难的,因为t是递增的,所以有拓扑序,那么就可以用dp解了。 dp[i][j][p][q] 表示在i点,j宇宙,p时间,q包盐的最优解。 但是这个题目最大的问题是让人容易用spfa来解,因为复杂度看起来还是可以的。。。。可是tle到死。 #include #include #include using namespace std; const int

2013-11-18 22:30:19 1035

原创 hdu 4790 Just Random 数论

成都赛区的j题,表示没有想到太好的做法,就用了个比较麻烦的,先把问题转换成%p==0的 a+=p-m; b+=p-m; m=0; #include #include #include #define ll long long using namespace std; long long a,b,c,d,p,m; long long x,y; long long cal(ll a,l

2013-11-18 19:17:53 1314

原创 hdu 4779 Tower Defense

组合数学的题目,很明显这个题目的难点在于重塔的设定,所以一定要从重塔下手,但是一直因为一个误区没找到办法。 题解的办法,先枚举有两个重塔的行和列,再枚举独占行列的塔中的重塔数量。 #include #include #include using namespace std; const int maxn=2e2+9,mod=1e9+7; int n,m,p,q; long long pp

2013-11-18 17:18:55 1483

原创 hdu 4436 str2int 后缀数组

递推的办法不难想到,但是要去重,那就要后缀数组来找最长前缀了。后面递推的没想好,写搓了。 #include #include #include #include #include using namespace std; const int maxn=1e5+1e5+9,mod=2012; char a[maxn]; int r[maxn]; int next[maxn]; lon

2013-11-13 00:49:51 1064

原创 hdu 4466 Triangle

对于长度为n的三角形的个数是靠打表找出来的规律,就不解释了。 然后这个三角形最大公约数为1,那么就可以用筛选法来做。 最后计算答案就o(n)扫描的计算,这个比较简单,不解释了。 #include #include #include using namespace std; const int maxn=5e6+111,mod=1e9+7,N=5e6; int sum[maxn],p

2013-11-12 00:28:15 948

原创 hdu 4776 Ants 杭州现场赛G题

杭州现场赛的题目,首先求出每个节点到根节点的xor值,那么两个节点路径的xor值就等于他们到根节点的xor值再xor。 那么就会有n*n个xor值,但是题目值要求前面的k个,并且k小于200000. 那么就可以这么搞了,先找xor之后最高位为1的,看看有多少个,如果大于k,那么证明前k大的全部在里面,再找次高位的就可以,否者,把这些数全部找出来并排序,剩下的再在这一位不为一的那里找。 #

2013-11-10 23:41:51 2490

原创 hdu 4426 Palindromic Substring 字符串hash

这个题目真的wa了两天,最后居然是求最长回文子串的地方边界条件没有处理好,真心跪了。 #include #include #include #include #include using namespace std; const int maxn=4e5+9,maxm=11371111;; const long long mod=777777777; char a[maxn]; i

2013-11-09 11:00:59 1193

原创 hdu 4429 Split the Rectangle

读懂题意之后就是简单的暴力找一个最小的矩形去包围这两个点,然后把这个矩形内部的点全部去掉,就可以得出答案。 #include #include #include using namespace std; const int maxn=2e3+9,inf=1e9; int n,q; int lonl,lonr; struct { int x1,x2,y1,y2; }line[m

2013-11-06 20:15:43 881

原创 hdu 4424 Conquer a New Region 并查集

去年长春的时候没做出来,现在看起来也并不困难,反着把大的边开始加就好。 #include #include #include #include using namespace std; const int maxn=2e5+9; int n; int fa[maxn]; long long sum[maxn],son[maxn]; struct E { int from,to

2013-11-04 20:12:31 711

原创 hdu 4099 Revenge of Fibonacci

暴力求出前十万的斐波那契数列,然后存储起来,后面再查找就好了。 存储的话建议两种方式,一种是字典树,一种是hash,当然这个题目用字典树会更好。 #include #include #include #pragma comment(linker, "/STACK:36777216") using namespace std; const int mod=10; struct add

2013-11-04 19:42:44 752

原创 poj 1966 Cable TV Network

枚举源点和汇点。 #include #include #include using namespace std; const int maxn=109,inf=1e8; int n,m; int a[maxn][maxn]; int que[maxn],level[maxn]; int head[maxn],lon; struct { int next,to,c; }e[max

2013-11-02 00:23:37 931

原创 poj 3042 Grazing on the Run

这个题目原型应该是吃完所有的草丛的最小时间,现在变成了每个草丛被吃的时间和,貌似如果还是按照原来的dp方法dp[i][j]表示吃完i到j的草丛的花掉的时间的话,有两个因素会影响后面的决策,一个是花掉的时间,一个是吃掉的草丛的时间累加和。 但是仔细观察这个问题会发现,第一个走的距离,会被计算n次,第二个走的距离,会被计算n-1次。如果我们把这个代价转移到该草丛上的话。那么dp[i][j]表示转移后

2013-10-31 23:51:32 1043

原创 hdu 4494 Teamwork 网络流

网上比较多的代码都是用费用流做的,但是这个题目简单的描述就是求最小路径覆盖,每个点覆盖的次数不是1了而已。简单修改求最小路径覆盖的方法即可,源点向顶点,顶点向汇点连的边都变成点需要被覆盖的次数即可。 #include #include #include using namespace std; const int maxn=15e1+9,inf=1e9; int n,m; int su

2013-10-28 22:45:32 1007

原创 poj 2446 网络流

先黑白染色,然后每个覆盖必须覆盖一个黑点一个白点,那么就是一个二分图,一个覆盖就是一次匹配,那么就求一下最大匹配就好了。 #include #include #include using namespace std; const int maxn=1100,inf=1e9; int n,m,k; int flag[35][35]; int level[maxn],que[maxn];

2013-10-27 22:25:40 645

原创 poj 3308 Paratroopers 网络流

由于最后结果是相乘,所以先log一下,转化成想加。 然后点做边,行,列做点。最小权覆盖。 #include #include #include #include using namespace std; const int maxn=2e2+9; const double inf=1e20,epx=1e-4; int que[maxn],level[maxn]; int head[

2013-10-27 21:45:44 718

原创 poj 3281 网络流

经典题目,拆点网络流。 #include #include #include using namespace std; const int maxn=4e2+9,inf=1e9; int n,f,d; int level[maxn],que[maxn]; int head[maxn],lon; struct { int next,to,c; }e[maxn*maxn<<1];

2013-10-27 16:56:16 702

原创 poj 2699 The Maximum Number of Strong Kings 网络流

#include #include #include using namespace std; const int maxn=19; int a[maxn],e[70][70],flag[maxn]; int n; void makegraph() { memset(e,0,sizeof(e)); int ret=0; for(int i=1;i<=n;i++)

2013-10-27 16:37:30 783

原创 poj 2391 Ombrophobic Bovines 网络流

二分答案+网络流判定,一定得拆点。 #include #include #include #include using namespace std; const int maxn=2e2+9,inf=1e9; long long d[maxn][maxn]; int n,m,sum; int level[maxn<<1],que[maxn<<1]; int head[maxn<<1],l

2013-10-27 16:29:08 704

原创 poj 1637 Sightseeing tour 网络流

经典题目,很多书上都有解答。 首先得用一个结论,一个联通的有向图存在欧拉回路当且仅当每个点的入度等于出度。 那么这个题目的做法就是先给无向边任意定向,然后源点向入度大于出度的点连边,出度大于入度的向汇点连边,网络流判断能不能使得最后每个点的入度都等于出度。 #include #include #include using namespace std; const int maxn=

2013-10-27 12:19:40 754

poj 3947 题解

经典O(n)求最长回文 acmer新手可看

2013-09-24

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除