自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

sepNINE的专栏

As brief as possible

  • 博客(462)
  • 收藏
  • 关注

原创 poj 3263 Tallest Cow 差分数列或线段树解区间修改

#include <iostream>#include <map>using namespace std;const int max_n = 10024;int c[max_n], d[max_n];map<pair<int, int>, bool> existed;int main() { int N, I, H, R; ...

2019-06-21 23:05:02 234

原创 poj1485 Fast Food 动态规划

//poj 1485//fenix_bao#include &lt;iostream&gt;using namespace std;const int MAXN=256,MAXK=32;int pos[MAXN],dp[MAXN][MAXK],dis[MAXN][MAXN],one_cover[MAXN][MAXN];int sum_dis[MAXN][MAXN],sum_dis_r...

2018-03-21 20:04:52 400

原创 poj 1313 Booklet Printing 模拟水题

//poj 1314//sep9#include using namespace std;const int MAXN=128;struct Page{ int front1,front2; int back1,back2;}pages[MAXN];int n;void print(int x){ if(x>n) printf(" Blank"); else printf

2017-09-04 22:04:11 626

原创 poj 1769 Minimizing maximizer 单点更新线段树

//poj 1769//sep9#include using namespace std;const int MAXN=100012;const int MAXX=9999999;int n,m;int minv[MAXN*4];void build(int l,int r,int k) { minv[k]=MAXX; if(l==r) ret

2017-08-30 21:15:25 679

原创 poj 2286 The Rotation Game 迭代加深搜索

//poj 2286//sep9#include using namespace std;int move[8][9]={{0,2,6,11,15,20,22}, {1,3,8,12,17,21,23}, {10,9,8,7,6,5,4}, {19,18,17,16,15,14,13}, {23,21,17

2017-08-24 19:18:44 463

原创 poj 1180 Batch Scheduling dp斜率优化

题意:       设dp[i]=min dp[j]+(S+sumT[i]-sumT[j])*F[i]  1分析:       dp[i]=min (S+sumT[i])*sumF[i]+dp[j]-sumT[j]*F[i],由于F[i]随i减小单增,sumT[j]随i减小单增,按照i从N到1倒推dp[i]满足单调队列优化的条件dp[i]=S(i)+min{fj(i)|i代码:

2017-08-23 20:18:19 379

原创 poj 3155 Hard Life 最大密度子图

//poj 3155//sep9#include #include using namespace std; const int MAXN=512; const int MAXM=20000;const double MAX=1e7; typedef double cap_type; struct Edge { int v,nxt; ca

2017-08-04 06:01:04 421

原创 poj 1022 Packing Unit 4D Cubes 搜索

//poj 1022//sep9#include using namespace std;const int MAXN=128;const int MAX_INDEX=1024;int g[MAXN][MAXN][10];int vis[MAXN],map[MAX_INDEX],minx[4],maxx[4],x[4];int cases,n,cnt;void dfs(int

2017-08-02 19:36:10 428

原创 poj 1033 Defragment 模拟+递归

//poj 1033//sep9#include using namespace std;const int MAXN=10024;int a[MAXN],vis[MAXN],N,K;int zero_pos,flag;void dfs(int i){ if(a[i]==i||a[i]==0) return; if(vis[a[i]]==1){ printf("%d %

2017-07-31 22:36:24 454

原创 poj 2440 DNA 递推在模下存在循环节

题意和分析:       题意都是废话,用动态规划列个方程化下简,最后也是这题有意思的地方是求a(n)=a(n-1)+a(n-3)+a(n-3) 在模2005下的值。       你可能会说,这个简单啊,弄个数组,搞个for循环就行啊,没错,但这是O(n)。能快点么?       嗯,那用矩阵相乘表示递推,在乘法矩阵结合律的保证下幂运算加速足够快了吧?嗯,是快不少,但这是O(logn)

2017-07-28 23:19:50 498

原创 poj 2138 Travel Games 搜索+自动机水题

//poj 2138//sep9#include using namespace std;const int MAXN=1024;const int MAXL=80;int n,ecnt;struct edge{ char s[MAXL+4]; bool exist; int nxt;}first,e[MAXN+4];int head[MAXL+4];bool judg

2017-07-28 00:29:49 381

原创 poj 1145 Tree Summing 栈+模拟

题意:给一个数a和一棵带权树T,判断T根到叶子的若干路径的权和中是否有和a相等的。分析:       栈用来表达式求值有两种办法,一是将表达式转为后序再求值,二是利用单调符号栈一次扫描。单调符号栈一次扫描法求值时维护单调符号栈(栈中总是优先级低的符号在下,‘(’在栈外优先级最高,栈中优先级最低,‘)’在栈外优先级最低,不可能出现在栈中)。先搞清楚表达式求值的单调符号栈一次扫描法这题就容

2017-07-27 12:57:51 396

原创 poj 1966 Cable TV Network 无向图最小割

//poj 1966//sep9#include #include using namespace std;const int MAXN=512;const int MAXM=20000;struct Edge{ int v,nxt,f;}e[MAXM],e_copy[MAXM];queue que;int src,sink;int g[MAXN],dist[MAX

2017-07-20 13:16:22 294

原创 poj 1040 Transportation 深搜剪枝

//poj 1040//sep9#include using namespace std;int n,m,order_num,ans;struct Order{ int s,t,num,val; }orders[32];int passengers[16],most_earn[32];void dfs(int cur,int sum_value){ if(cur>=ord

2017-07-19 22:35:15 496

原创 poj 1815 Friendship 求字典序最小的最小割

题意:拆点后是求无向图字典序最小的最小割。分析:       设有边e(u,v),则下面三点等价:       1:e可以作为割边(最小割集不唯一)。       2:去掉e后最小割值变小。       3:残量网络中不存在u到v的增广路。       所以从编号小的边开始,判断该边可不可能是割边,如果可能,把这条边去了,退流。如果不可能,保持原状,处理下一条边。代

2017-07-19 06:07:53 676

原创 poj 1176 Party Lamps 模拟

//poj 1176//sep9#include #include #include using namespace std;const int MAXN=128;int N,C,limit[MAXN],tmp[MAXN];string pass_string[20];string get_string(){ string res; for(int i=0;i<N;++i

2017-07-15 02:30:10 521

原创 poj 1120 A New Growth Industry 模拟

//poj 1120//sep9#include using namespace std;const int SIZE=20;int D[SIZE+4],mat[SIZE+4][SIZE+4],sum[SIZE+4][SIZE+4];int dx[4]={0,0,-1,1};int dy[4]={-1,1,0,0};char ch[4]={'.','!','X','#'};int

2017-07-13 22:37:37 534

原创 poj 1079 Ratio 模拟

模拟题,只是涉及分数精度的一个技巧:c++中如何取整?如果a是一个浮点数,int b=(int)a; b是a的整数部分么??        答案是不一定,因为在一般实际的算法中,不是int b=(int)a这么简单 a可能经过了很多运算,有精度丢失。比如a的真值是8 计算机不小心搞成了7.999999或8.000001这样直接取整就会有问题(假设我们的计算机误差范围不超过1e-6,计算机不能保

2017-07-09 22:14:07 497

原创 poj 3044 City Skyline 单调栈

//poj 3044//sep9#include #include using namespace std;const int MAXN=80000;int x,y[MAXN];int main(){ int n,w; while(scanf("%d%d",&n,&w)==2){ for(int i=0;i<n;++i){ scanf("%d%d",&x,&y[i]

2017-02-28 17:03:15 738

原创 poj 1053 Set Me 枚举水题

//poj 1053//sep9#include using namespace std;struct Card{ char characters[8]; }tableau[16];bool judge(int p,int i,int j,int k){ if(tableau[i].characters[p]==tableau[j].characters[p]) if(t

2017-01-20 09:59:35 593

原创 poj 1737 Connected Graph 组合递推计数+高精度

题意:求n个点的无向联通图有多少个。分析:递推计数,需要高精度,我这个模版里的乘法利用了m位数乘n位数不超过m+n位数的原理采用了延迟进位技术,无需设置进位,乘法代码不超过10行。代码://poj 1737//sep9#include using namespace std;struct H { int a[100],len; H(){me

2017-01-19 10:10:07 567

原创 poj 3511 Fermat's Christmas Theorem 筛素数

//poj 3511//sep9#include using namespace std;const int max_prime_num = 1000010;const int max_n = 1000010; int primes[max_prime_num];int vis[max_n],num;void init(){ memset(vis,0,sizeof(vis

2016-12-11 18:15:01 481

原创 poj 1099 Square Ice 模拟

//poj 1099//sep9#include using namespace std;const int MAXM=12;char g[4*MAXM+5][4*MAXM+5];int mat[MAXM+5][MAXM+5];int m;void solve(){ memset(g,' ',sizeof(g)); for(int i=0;i<4*m-1;++i) g[

2016-12-03 15:09:54 554

原创 poj 2987 Firing 最大权闭合图

题意:裸的最大权闭合图。分析:       国家集训队论文>里有完整的建模推导证明,建议搜了学习下~这里直接用dinic搞了。代码://poj 2987//sep9#include #include using namespace std;typedef long long INT; const INT MAXN=5000; const INT MA

2016-11-30 22:23:10 484

原创 poj 1128 Frame Stacking 字典序输出拓扑序

//poj 1128//sep9 #include using namespace std; const int MAXLEN=36; const int MAXANS=72; char s[MAXLEN][MAXLEN]; int l[MAXLEN],r[MAXLEN],u[MAXLEN],d[MAXLEN],g[MAXLEN][MAXLEN]; int in_degre

2016-10-12 10:04:26 444

原创 poj 1951 Extra Krunch 字符串处理水题

//poj 1951//sep9#include using namespace std;bool vis[256];char str[1024],ans[1024];int main(){ gets(str); memset(vis,0,sizeof(vis)); int cur=0; for(int i=0;i<strlen(str);++i){ if(str[i]

2016-10-07 05:04:30 868

原创 poj 3436 ACM Computer Factory 网络流EK算法

题意:      有n台机器编号为1,2,3,..i..n,每台机器可以加工qi台计算机,计算机的状态由他的p个零件的有无表示,再给出每台机器对计算机状态的改变情况,求这个系统最多能生产多少台计算机和机器间计算机的传递情况。分析:     理解题意有点难,因为有最大加工数限制建图记得拆点,然后EK解决,EK比dinic慢但是简洁而且比较好展示各条边上的流量情况。代码://poj

2016-09-30 18:24:40 525

原创 poj 3007 Organize Your Train part II 哈希判重

//poj 3007//sep9#include #include using namespace std;const int MAXN=1024;const int HASHLEN=1000024;int n,cnt;char s[MAXN],s1[MAXN],s2[MAXN],s3[MAXN],s4[MAXN];struct HashNode{ char str[MAXN]

2016-09-24 00:12:22 1010

原创 poj 1322 Chocolate 概率dp

//poj 1322 AC//sep9#include using namespace std;int c,n,m;double dp[2][128];int main(){ while(scanf("%d",&c)==1&&c){ scanf("%d%d",&n,&m); if(m>c||m>n||(m+n)%2){ puts("0.000"); conti

2016-09-20 09:58:11 419

原创 poj 3308 Paratroopers最小点权覆盖

//poj 3308//sep9#include #include #include using namespace std;const int MAXN=128;const int MAXM=10024;const double MAX=100000.0;struct Edge { int v,nxt; double f; }e[MAXM*2+10];

2016-09-12 23:12:33 443

原创 poj 3404 Bridge over a rough river 贪心

//poj 3404//sep9#include #include using namespace std;int n;int a[128];int main(){ scanf("%d",&n); for(int i=1;i<=n;++i) scanf("%d",&a[i]); sort(a+1,a+n+1); int sum=0; while(n>0){

2016-08-31 21:53:19 542

原创 poj 1027 The Same Game 模拟

//poj 1027//sep9#include using namespace std;int leave,score;int rx,ry,n,cnt;char g[20][20];bool vis[20][20];int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};bool inGraph(int x,int y){ return x>=

2016-08-31 20:05:52 599

原创 poj 2054 Color a Tree 贪心

//poj 2054//sep9#include using namespace std;const int MAXN=1024;int n,root,e_cnt;int vis[MAXN],num[MAXN],c[MAXN],prev[MAXN];int head[MAXN],adj[MAXN],next[MAXN]; int find_root(){ double maxx

2016-08-01 22:27:22 534

原创 poj 1376 Robot 广搜

//poj 1376//sep9#include #include using namespace std;const int maxN=128;int n,m,sx,sy,sdir,ex,ey;int g[maxN][maxN],vis[maxN][maxN][4];int dx[]={-1,0,1,0};int dy[]={0,1,0,-1};struct NODE{

2016-07-15 13:26:08 473

原创 poj 1505 Copying Books 动态规划

//poj 1505//sep9#include using namespace std;const int MAXN=512;int sum[MAXN],path[MAXN],dp[MAXN][MAXN];int main(){ int cases; scanf("%d",&cases); while(cases--){ int m,k; scanf("%d%d",

2016-06-04 14:29:29 985 1

原创 poj 2271 HTML 模拟

//poj 2271//sep9#include #include using namespace std;int main(){ string s; int i,cnt=0; while(cin>>s){ if(s==""){ cout<<endl; cnt=0; }else if(s==""){ if(cnt) cout<<endl;

2016-05-17 16:27:53 715

原创 poj 2151 Check the difficulty of problems 概率dp

//poj 2151//sep9#include using namespace std;int n,m,t;double p[1024][35],dp[1024][35][35],s[1024][35];int main(){ while(scanf("%d%d%d",&m,&t,&n)==3){ if(!(n+m+t)) break; for(int i=1;i<=t;

2016-05-16 22:43:15 453

原创 poj 1521 Entropy 并查集+优先队列实现哈夫曼编码

//poj 1521//sep9#include #include using namespace std;typedef pair pii;char s[10024];int height[512];int cnt[512];int f[512];int find(int u){ return f[u]==u?f[u]:f[u]=find(f[u]);}void so

2016-05-16 07:17:37 696

原创 poj 1189 钉子和小球 概率dp转化为计数dp

//poj 1189//sep9#include using namespace std;typedef long long ll;int n,m;char g[64][64];ll dp[64][64];ll gcd(ll a,ll b){ return a%b==0?b:gcd(b,a%b);}void print(ll a,ll b){ ll d=gcd(a,b

2016-05-06 09:56:08 507

原创 poj 1054 The Troublesome Frog 枚举

//poj 1054//sep9#include #include using namespace std;struct NODE{ int x,y;}p[5012];bool vis[5012][5012];int n,r,c;int cmp(NODE a,NODE b){ return a.y!=b.y?a.y<b.y:a.x<b.x; }int main(){

2016-05-05 17:41:47 779

空空如也

空空如也

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

TA关注的人

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