自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(691)
  • 收藏
  • 关注

原创 POJ Treasure Exploration(DAG最小可相交路径覆盖)

这题一开始题目没看清,一般的最小路径覆盖是不能有重点的,但是这题目有一句You should notice that the roads of two different robots may contain some same point. 说明可以一个点可以经过多个机器人,之前在论文里看到过,这种情况只需用floyd处理一下闭包关系,只用关心是否能到达,而不用关心怎么到达。#include #

2017-01-06 19:34:43 375

原创 UVA 11865 Stream My Contest(最小树形图+二分)

#include #include #include using namespace std; const int maxn=60+5; const int maxm=10000+5; const int inf=100000000; int in[maxn],pre[maxn],vis[maxn],color[maxn],s[maxm],e[maxm],dis[maxm],cost[maxm];

2017-01-01 21:32:54 276

原创 UVA 11354 Bond(最小生成树+LCA倍增)

这题本来想用Prim来求最小瓶颈路的,但是n太大了,所以用LCA倍增来求。 #include #include #include #include using namespace std; const int maxn=50000+5; const int maxm=100000+5; const int logmax=20; const int inf=1000000000; int fa[m

2017-01-01 11:24:36 589

原创 UVA 1078 Password Suspects(AC自动机+dp)

状态方程d[u][len][st],代表最后一个节点是u,长度为len,已经有st个串所能构成的密码数,记忆化搜索就行了。 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<queue> typedef long lo...

2016-11-09 21:55:35 1512 1

原创 2016 ACM/ICPC Asia Regional Qingdao Online 青岛赛区(已完成8题)

1001 <pre name="code" class="cpp">#include <iostream> #include <cstdio> #define min(a,b) ((a)<(b)?(a):(b)) #define min4(a,b,c,d) min(min(a,b),min(c,d)) using namespac...

2016-09-17 21:01:18 341

原创 HDU 1060 Leftmost Digit(数学)

(转自网上牛人解题报告) 题目大意是输入N,求N^N的最高位数字。1 估计大家看到N的范围就没想法了。 确实N的数字太大,如果想算出结果,即使不溢出也会超时。 题目是这样转化的。 首先用科学计数法来表示      N^N  = a*10^x;     比如N = 3;  3^3 = 2.7 * 10^1;

2017-01-25 17:29:21 419

原创 HDU 1755 A Number Puzzle

#include #include using namespace std; const int maxn=400000+5; int v[maxn],cnt; int main() { int n,m; int a[10]; while(~scanf("%d%d",&n,&m)) { cnt=0; for(int i=1;i<=n;

2017-01-25 11:06:20 426

原创 HDU 1717 小数化分数2

思路来源:点击打开链接 #include #include #include using namespace std; int gcd(int a,int b){ return b==0?a:gcd(b,a%b); } int main() { string s; int t; cin>>t; while(t--) { cin>>s

2017-01-24 19:04:52 357

原创 HDU 1719 Friend 打表

#include #include #include using namespace std; vector v; int main() { v.push_back(1);v.push_back(2); for(int i=0;i<v.size();i++){ if(v.size()>1000) break; v.push_back((v[i]+1)

2017-01-24 18:01:01 541

原创 HDU 1718 Rank

#include using namespace std; int m[1005]; int main() { int a; while(~scanf("%d",&a)) { int mark; int b,c=0; while(scanf("%d%d",&b,&m[c++])&&(b+m[c-1])) {

2017-01-24 18:00:38 438

原创 HDU 1716 排列2

#include #include #include using namespace std; vector v[10]; int main() { int a[5]; bool first=true; while(scanf("%d%d%d%d",&a[1],&a[2],&a[3],&a[4])&&(a[1]+a[2]+a[3]+a[4])) {

2017-01-24 18:00:14 437

原创 HDU 1715 大菲波数

#include using namespace std; const int maxn=1000+5; string f[maxn]={"0","1","1"}; string operator + (string s1,string s2)//大数相加 { if(s1.size()<s2.size()) { string temp=s1;

2017-01-24 17:59:31 266

原创 HDU 1703 PBD(递推)

假设当人数是x时,传递完成需要f次,那么添加一个人时,只需要把新的人与任意一个人连接,那么这个人带有了新人的信息,然后再进行f次,旧的人都带有所有人的信息,新人再与任意一个人连接即可,f[n]=f[n-1]+2。#include using namespace std; const int maxn=10000+5; int f[maxn]={0,0,1,3,4}; int main() {

2017-01-24 15:22:45 358

原创 HDU 1702 ACboy needs your help again!

#include #include #include #include using namespace std; int main() { int t; cin>>t; while(t--) { int n;string cmd; cin>>n>>cmd; queue q; stack ss;

2017-01-24 14:30:31 281

原创 HDU 1701 ACMer

这题意太蛋疼了,要求人数最少,那么x从1枚举,人数最少也就是说ACMer数也是最少。#include using namespace std; int main() { int t; cin>>t; while(t--) { int x=1; double p,q; cin>>p>>q; while((

2017-01-24 14:17:27 292

原创 HDU 1215 七夕节(打表)

这题一开始想用唯一分解定理做,蠢哭。#include using namespace std; const int maxn=500000+5; int a[maxn]; int main() { for(int i=1;i<maxn;i++){ for(int j=i+i;j<maxn;j+=i){ a[j]+=i; } }

2017-01-24 13:27:06 417

原创 HDU 1214 圆桌会议

#include using namespace std; int main() { int n; while(~scanf("%d",&n)) { int ans=(n-n/2)*(n-n/2-1)/2+(n/2-1)*(n/2)/2; printf("%d\n",ans); } return 0; }

2017-01-24 12:17:56 311

原创 HDU 1213 How many table(dfs)

#include using namespace std; const int maxn=1000+5; bool map[maxn][maxn],used[maxn]; int n,m; void dfs(int u) { for(int v=1;v<=n;v++){ if(map[u][v]&&!used[v]){ used[v]=true;

2017-01-24 12:15:00 356

原创 HDU 1212 Big Number

#include #include using namespace std; int main() { string a;int b; while(cin>>a>>b) { int ans=0; for(int i=0;a[i];i++){ ans=ans*10+a[i]-'0'; ans%=b

2017-01-23 20:56:29 226

原创 HDU 1210 Eddy's 洗牌问题(找规律)

#include using namespace std; int main() { int n; while(~scanf("%d",&n)) { int i=2,step=0; while(i!=1) { if(i<=n) i*=2; else i=(i-n-1)*2+1;

2017-01-23 20:37:08 386

原创 UVA 10972 RevolC FaeLoN(边双联通+缩点)

#include #include #include using namespace std; const int maxn=1000+5; const int maxm=maxn*maxn; struct Edge{ int u,v; Edge(int u=0,int v=0):u(u),v(v){} }e[maxm]; int n,m,tot,stamp,dfn[maxn],l

2017-01-23 19:16:43 293

原创 UVA 11294 Wedding(2-sat)

#include #include #include #include #include using namespace std; const int maxn=100+5; struct TwoSAT{ int n; vector G[maxn*2]; bool mark[maxn*2]; int s[maxn*2],c

2017-01-23 15:47:18 360

原创 HDU 1754 I Hate It(线段树单点更新)

#include #include using namespace std; const int maxn=800000+5; int n,m,a[maxn/4]; struct Intervaltree{ int maxx[maxn]; void clear() {memset(maxx,0,sizeof(maxx));} void build(int o,int L

2017-01-18 16:46:08 245

原创 HDU 1166 敌兵布阵(线段树单点更新)

#include using namespace std; const int maxn=200000+5; int n,a[maxn/4]; struct Intervaltree{ int val[maxn]; void clear() {memset(val,0,sizeof(val));} void build(int o,int L,int R) {

2017-01-18 16:37:06 233

原创 UVA 1395 Slim Span(枚举)

#include #include #include #include using namespace std; const int maxn=100+5; const int inf=(1<<30); int f[maxn]; int n,m; bool map[maxn][maxn],used[maxn]; struct edge{ int u,v,w; edge(int u,

2017-01-18 15:03:23 370

原创 UVA 10816 Traverl in Desert(最短路+二分)

这题精度卡了三天。#include #include #include #include using namespace std; const int maxn=211; const int maxm=21111; const double inf=(1e100); const double eps=1e-8; int n,m,s,t; struct HeapNode{ doubl

2017-01-14 10:45:45 455

原创 UVA 10600 ACM Contest and Blackout(最小生成树and次小生成树)

拿的最小瓶颈路LCA模板做的,感觉好浪费。#include #include #include #include using namespace std; const int maxn=100+5; const int maxm=10000+5; const int logmax=20; const int inf=1000000000; int fa[maxn

2017-01-12 15:12:51 456

原创 UVA 10765 Doves and bombs(强联通)

#include #include #include #include using namespace std; const int maxn=10000+5; int low[maxn],pre[maxn]; int dfs_clock; int cut[maxn]; vector G[maxn]; int n,m; struct node{ int cut,idx; node(

2017-01-11 11:45:23 294

原创 UVA 11396 Claw Decomposition(二分图判断)

如果一个节点是一个爪的中心,那么他只能与其余三个辅助点相连,那么就可以发现这是一张二分图,X为爪的中心,Y为三个脚,建完图染下色就可以了。Claw Decomposition #include #include using namespace std; const int maxn=300+5; int head[maxn*maxn],to[maxn*maxn],Next[maxn*maxn];

2017-01-10 10:18:58 297

原创 HDU 4751 Divide Groups(二分图判断)

给出的图是一张有向图,代表i认识j,那么line[i][j]==false||line[j][i]==false代表i和j不是相互认识,那么他们肯定不可以在一个集合里,所以i和j之间连边,最后判断是不是二分图,如果是,那么可以分,否则不能分。#include #include using namespace std; const int maxn=100+5; int head[maxn*maxn

2017-01-10 10:06:20 272

原创 HDU 2444 The Accomodation of Students(二分图判断+最大匹配)

#include #include using namespace std; const int maxn=200+5; int head[maxn*maxn],to[maxn*maxn],Next[maxn*maxn]; bool used[maxn]; int match[maxn],color[maxn];; int n,m; int tot; void addedge(int u,int

2017-01-10 09:26:53 271

原创 UVA 12168 Cat vs. Dog(最大独立集)

这个看的出来是求最大独立集,但是一开始一直是猫和狗矛盾,用毛和狗在做最大匹配。 但是题目要求是最多满足多少人的要求,才发现,是人的最大独立集。#include #include using namespace std; const int maxn=500+5; bool line[maxn][maxn],used[maxn]; int match[maxn],c,d; struct perso

2017-01-09 21:20:04 267

原创 UVA 1327 King's Quest(强联通+二分图)

参考:http://www.cnblogs.com/zxndgv/archive/2011/08/06/2129333.html #include #include #include using namespace std; const int N=2000+5; const int M=205000; bool line[N][N],instack[N*2]; int n, tot, dep,

2017-01-09 20:09:38 352

原创 UVA 1405 The Great Wall Game(最佳二分图匹配)

一开始理所当然的认为横排和纵排应该是横坐标和纵坐标和的平均值,但是WA了好几次。检查了一下,好像也就这么一个可疑点,算算时间复杂度也不会T,就直接暴力了,然后就过了= =。 #include using namespace std; const int maxn=300+5; const int inf=(1<<30); int w[maxn][maxn],n; int lx[maxn],ly[

2017-01-09 16:26:12 438

原创 UVA 10615 Rooks(?)

这题是我碰到的二分图最难,到现在都还没明白怎么回事,先存着吧。#include #include #include #include using namespace std; const int maxn=100+5; int n,maxcolor; int color[maxn][maxn],match[maxn],inrow[maxn],incol[maxn]; char map[maxn][

2017-01-09 15:01:51 382

原创 UVA 1349 Optimal Bus Route Design(KM判环)

#include #include using namespace std; const int maxn=100+5; const int inf=(1<<30); int w[maxn][maxn],n; int lx[maxn],ly[maxn]; int Left[maxn]; bool s[maxn],t[maxn]; bool match(int i) { s[i]=true;

2017-01-08 20:06:04 336

原创 UVA 1201 Taxi Cab Scheme(最小路径覆盖)

#include #include #include using namespace std; const int maxn=500+5; int x1[maxn],y[maxn],x2[maxn],y2[maxn],t1[maxn],t2[maxn]; bool line[maxn][maxn],used[maxn]; int match[maxn],n; bool find(int i) {

2017-01-08 19:37:04 266

原创 UVA 12083 Guardian of Decency(最小独立集)

最小独立集=点数-最大匹配。#include #include using namespace std; const int maxn=500+5; bool line[maxn][maxn],used[maxn]; int match[maxn],n; string sex[maxn],music[maxn],sport[maxn]; int h[maxn]; bool find(int i)

2017-01-08 18:46:58 301

原创 UVA 11419 SAM I AM(二分图最小覆盖+答案输出)

这个板子直接可以用了。 #include #include #include #include using namespace std; const int maxn=1000+5; struct BPM{ int n,m; vector G[maxn]; int left[maxn];//left[i]为右边第i个点的匹配编号,-1表示不存在 bool T[ma

2017-01-08 17:37:42 332

原创 POJ 3487 The Stable Marriage Problem(稳定婚姻问题)

#include #include #include #include #include #include using namespace std; const int maxn=27+5; int pref[maxn][maxn],order[maxn][maxn],Next[maxn]; int future_husband[maxn],future_wife[maxn]; queue q;

2017-01-08 13:11:44 691

空空如也

空空如也

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

TA关注的人

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