- 博客(48)
- 资源 (2)
- 收藏
- 关注
转载 北大ACM试题分类
转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 最近AC题:2528 更新时间:2011.09.22 已AC题数:146初级题已在2011.06.30全部完成 部分解题报告添加新内容,除了原有的“大致题意”和“解题思路”外,新增“So
2012-12-15 00:32:55 986 2
原创 poj 2391 二分+最大流 (dinic模板+优化)
/* * ===================================================================================== * * Filename: 2391.cpp * Version: 1.0 * Created: 09/08/2013 10:04:09 AM * R
2013-09-09 16:17:39 842
原创 poj 3693 (后缀数组)
/* * ===================================================================================== * * Filename: c.cpp * Version: 1.0 * Created: 08/20/2013 03:06:41 PM * Rev
2013-08-29 21:57:12 904
原创 poj 2288 (状态压缩+spfa)
dp[i][j][k] 表示状态为i (二进制第k位为1表示第(k+1)顶点在当前路径里),倒数第二个点为j,最后一个点为k的最大值之后类似spfa求最常路一样求解,初始把所有单个顶点的状态加入队列里,n==1是特判。/* * =============================================================================
2013-08-28 22:55:04 767
原创 poj 2411 (状态压缩)
第一道状态压缩,撒花~~~/* * ===================================================================================== * * Filename: a.cpp * Version: 1.0 * Created: 2013-08-27 23:01:05
2013-08-27 23:30:44 802
原创 poj 1625 (AC自动机 + dp + 高精度(java) )
RE 了n久,没想到最后是因为死在了编码上import java.util.*;import java.math.*;import java.io.*;public class Main { final static int NODE = 105; final static BigInteger ZERO = BigInteger.ZERO, ONE = BigIntege
2013-08-26 14:21:25 759
原创 hdu 2243 (AC自动机 + dp + 矩阵快速幂)
略恶心人的东东/* * ===================================================================================== * * Filename: 2243.cpp * Version: 1.0 * Created: 2013-08-25 21:28:30 *
2013-08-25 22:52:13 851
原创 poj 2778 (AC自动机+dp+矩阵快速幂)
断断续续看了一周AC自动机和Trie图,总算明白一些了,A的不易啊/* * ===================================================================================== * * Filename: 2778.cpp * Version: 1.0 * Created
2013-08-25 01:27:14 984
原创 poj 1204 (AC自动机)
#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define PB push_back#define SIZE(
2013-08-13 22:05:30 867
原创 AC自动机模板先存着,还不会...
//my first ACAutomaton# include # include # include # include # include # include # include # include # include # include # include # include # include using namespace std ;# define l
2013-06-10 22:44:57 789
原创 poj 1743 -- Musical Theme (后缀数组模板题)
就当存个模板# include # include # include # include # include # include # include # include # include # include # include # include # include using namespace std ;# define PB p
2013-06-10 22:41:46 962
原创 poj 3395 -- Shift Cipher ( stl + dp )
题本身挺水,就是有点坑人,字典大概10W个,用Trie树存会MLE,用map存就好,字符串有26种变化,枚举一遍,输出单词数最小的,n^2 的dp解决,还有一个坑,The answer will be considered correct if no adjacent words are single character and the average number of characters
2013-05-21 10:20:18 994
原创 poj 1274 -- The Perfect Stall (二分图)
小小纪念# include # include # include # include # include # include # include # include # include # include # include # include # include # define ll long longusing namespace std ;stru
2013-05-19 14:31:55 765
转载 ZOJ Monthly, March 2013 解题报告
首先是题目及比赛情况:A Simple Tree Problem 10.81% (93/860)The Review Plan I 17.14% (18/105)The Review Plan II 22.97% (34/148)Digging 21.94% (97/442)
2013-05-02 08:02:31 1813
转载 转自matrix67 十个利用矩阵乘法解决的经典问题
十个利用矩阵乘法解决的经典题目 好像目前还没有这方面题目的总结。这几天连续看到四个问这类题目的人,今天在这里简单写一下。这里我们不介绍其它有关矩阵的知识,只介绍矩阵乘法和相关性质。 不要以为数学中的矩阵也是黑色屏幕上不断变化的绿色字符。在数学中,一个矩阵说穿了就是一个二维数组。一个n行m列的矩阵可以乘以一个m行p列的矩阵,得到的结果是一个n行p列的矩阵,
2013-04-29 20:43:37 751
原创 矩阵类备份
# include # include # include # include # include # include # include # include # include # include # include # include # include # define ll long longusing namespace std ;const ll m
2013-04-29 09:46:48 824
原创 POJ 2559 -- Largest Rectangle in a Histogram ( 单调栈 )
# include # include # include # include # include # include # include # include # include # include # include # include # include # define ll long longusing namespace std ;struct HEHE
2013-04-25 20:02:50 723
原创 树形dp纪念
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3003# include # include # include # include # include # include # include # include
2013-04-06 19:25:16 596
原创 poj 3159 -- Candies ( spfa + 栈 )
很普通的差分约束 ,可就是用队列会超时。。。。。。# include # include # include # include # include using namespace std ;const int MAX = 2100000000 ;struct Edge{ int v , w , next ;} edge [ 200000 ] ;int hea
2013-04-02 20:54:07 672
原创 poj 2513 -- Colored Sticks ( Trie + 并查集 + 欧拉 )
WA了很久的一道题了,今天终于过了判断条件有两个1 、出现次数为奇数的颜色2 、判断图是否连通用Trie处理效率较高,判断连通可以将颜色映射成数字用并查集# include # include # include # include # include # include # include # include # include # include
2013-04-02 16:59:58 660
原创 poj 3386 -- Frequent values (RMQ/线段树)
给一串不降序列,每次询问给出一个区间,求区间元素出现最多的次数。可以用线段树或RMQ, 我这里用的RMQ ,想了很久,写了很久,WA了很久,小处理有点麻烦,解释在代码中# include # include # include # include # include # include # include # include # include # inclu
2013-03-30 09:48:45 827
原创 poj 3264 -- Balanced Lineup (区间最值,线段树/RMQ)
第一次RMQ ,还好RMQ版:# include # include # include # include # include # include # include # include # include # include # include # include # include using namespace std ;const in
2013-03-30 09:32:18 714
原创 poj 3842 -- An Industrial Spy ( 全排列 )
用递归写了个全排列,还好 , 素数处理我是先打了个1000W 的素数表 , 测了一下打标大约500ms , 还不如直接暴力算素数 。。。。。# include # include # include # include # include # include # include # include # include # include # include # incl
2013-03-25 14:09:55 1132
原创 poj 3468 -- A Simple Problem with Integers ( 线段树 , 段更新 , 段求和 )
# include # include # include # include # include # include # include # include # include # include # include # include # include using namespace std ;const int maxn = 110000 ;long lo
2013-03-22 13:29:03 637
原创 poj 2828 -- Buy Tickets ( 线段树 / 树状数组 )
题意就不说了,从后往前扫, 每次寻找和为 pos i 的点 , 开始本来想用并查集维护没有被占的点 ,可WA了很久,直接思路就是线段树或二分+树状数组 线段树版: # include # include # include # include # include # include # include # include # include # include
2013-03-21 13:01:48 869
原创 poj 2001 -- Shortest Prefixes ( 字典树 )
给出一个字典 , 输出每一个单词唯一的最短前缀 数据不是很大, 排序暴力应该也可以处理 ,我这里用了Trie树# include # include # include # include # include # include # include # include # include # include # include # include # inc
2013-03-21 12:44:46 683
原创 poj 1716 -- Integer Intervals ( 差分约束 )
这个可能用贪心也能做 , 没想那么多 , 觉得差分约束复杂度可以接受就水下了由于点的范围有0 , 要把所有点的值加1 , 用dis [ i ] 表示从0 到 i 一共有多少个元素 , 还要注意隐藏条件和注意事项,代码中会标出。# include # include # include # include # include # include # include # in
2013-03-21 12:39:23 767
原创 poj 1775 -- Sum of Factorials ( 够坑 )
100W以内,判断一个数是否能表示成几个数阶乘的和 0! 竟然是1 啊, 渣渣了,阶乘在100W以内的数有10个 , 暴力 复杂度 2^10 , 完全可以接受 , 那个0坑了好久# include # include # include # include # include # include # include # include # include # in
2013-03-21 12:29:49 646
原创 poj 2777 -- Count Color ( 线段树 )
WA了两天后终于A掉了,好开心, 按自己的理解实现的lazy ,实现上可能麻烦点 , 效率也略低 ,等看看别人代码学习下# include # include # include # include # include # include # include # include # include # include # include # include
2013-03-21 12:18:24 750
原创 poj 2492 -- A Bug's Life(并查集)
判断bug中是否有guy。。。。。。。。。。用n和n+max表示逻辑正反两反面,两个同一集合内的两个都小于max代表有相同,一个小于一个大于代表不同#include#includeusing namespace std;const int maxn=10010;int pre[2*maxn];int cnt;int find(int x){ if(pre[x]
2013-02-08 00:25:59 791
原创 poj 3984 -- 迷宫问题 (bfs)
就是普通的跑迷宫了,但要注意他让输出每一步的坐标,这里就要在每一步保存上一步的坐标,最后递归输出,具体看实现#include#include#includeusing namespace std;struct Link{ int n,pre;};Link a[5][5];int next[]= {-1,0,0,1,0,-1,1,0};void bfs(){
2013-01-27 23:46:14 420
原创 poj 2243 -- Knight Moves (bfs)
一个跳马的题,直接bfs就好。。。。。水过#include#includeusing namespace std;int a[9][9];char i1,i2;int j1,j2;int jump[]={-2,-1,-1,-2,-1,+2,-2,+1,1,2,1,-2,2,1,2,-1};void init(){ for(int i=1;i<9;i++)
2013-01-27 23:32:14 453
原创 poj 3176 -- Cow Bowling (dp)
求从顶端到低端经过点的最大和水dp,状态转移方程 dp[i+1][j]+=max(dp[i][j],dp[i][j-1])#includeusing namespace std;int dp[400][400]= {0};int cnt;int main(){ cin>>cnt; for(int i=1; i<=cnt; i++) fo
2013-01-26 01:16:49 462
原创 poj 2323 -- PERMS (dp)
求1--n个数排列,逆序对为k时排列可能情况这道题就是找递推关系,dp[ i ] [ j ]保存个数为i ,逆序对为j时的结果,则对于i+1,若 i+1放在末尾,逆序对数都不变,则dp[ i+1 ] [ j ]=dp[ i ][ j ] ; 若 i+1插在倒数第二个,逆序对数都+1,则dp[ i+1 ] [ j ]=dp[ i ][ j-1 ]...........可知 dp[ i+1 ]
2013-01-26 01:10:36 768
原创 poj 3278 -- Catch That Cow (最短路)
建图,以n为源点,n-1,n+1,2*n分别与n建立权值为1的边,题目即转化为了求n到k的最短路注意搜索加限定条件,容易re#include#includeusing namespace std;int a[100001]={0};int bfs(int n,int k){ a[n]=0; queue q; q.push(n); int t=-
2013-01-26 01:00:12 504
原创 poj 3083 -- Children of the Candy Corn (走迷宫)
分别求出每次遇到叉路向左、向右和最短路的长,用dfs和bfs模拟,写的很长,也懒的简化了#include#includeusing namespace std;int a[50][50]= {0};int w,h,cnt;struct Coor{ int i,j;} start,end;int dfsr(int i,int j,int d){ if(i==
2013-01-26 00:56:00 517
原创 poj 1125 -- Stockbroker Grapevine (最短路)
题挺长,其实就是求单源最短路中最长的枚举每个点求单源最短路的最大值,然后取这些值中最小的#include#includeusing namespace std;const int MAX=1000000000;int cnt;int a[101][101];int dis[101];int bellman(int v){ bool isin[101]= {0};
2013-01-26 00:49:05 446
原创 poj 2253 -- Frogger (并查集+贪心)
给出石头的坐标,求从起始到终点路途中每步最短距离(注意不是总距离最短)只需枚举每两个石头间距离,排序,从小到大依此加入图中,直到起始和终点在同一个集合中即可,证明略#include#include#include#includeusing namespace std;struct Coor{ int x,y;} coor[201];struct Edge{
2013-01-20 00:34:12 501
原创 poj 1062 -- 昂贵的聘礼
本来会是很水的题,但添了等级差这个东西,麻烦了点,还好数据量小,枚举完全能跑开,枚举每个下限,取最小的即可#includeusing namespace std;const int MAX=1000000000;int cnt,limit;int a[101][101];int worth[101];int level[101];int dis[101];int dijkstr
2013-01-20 00:27:03 476
原创 poj 3259 -- Wormholes(最短路,负环)
农场间有若干条双向路,还有一些单向的虫洞,在虫洞中走会使时间倒流,问会不会从某点出发,在负时间返回其实就是一个求负环的问题,注意这句话“Two fields might be connected by more than one path.”,小处理下即可#include#includeusing namespace std;const int MAX=50000000;
2013-01-20 00:19:35 730
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人