随笔分类 -  各种比赛

摘要:zoj 3611同类型的题目poj 2688化简模型即可得这样的问题,一幅图给定起点 终点 ,求起点到终点最多经过几个点,如果两种方案经过的点数相同,选路径总长短的注意,这幅图最多只有12个点,所以立刻可以想到用状态压缩来做dp[i][j]表示以i为终点的路径 为j状态(经过了那些点)时的最短路径ps:在预处理最短路的时候不要将'$'算进去,就看成一个普通的可以走的格子就可以了因为可能会出现如下情况,'$'的费用会算了四次,所以还是先数一下有几个'$'然后再独立算吧View Code #include<cstdio>#include& 阅读全文
posted @ 2012-06-25 22:04 Because Of You 阅读(2072) 评论(1) 推荐(1)
摘要:我决定:以后每一场codeforces我都将进行总结,尽量在赛后把题目AK(*_*),水平有限,只能说尽量。难得有一场CF的比赛在白天开始,于是我准时的守候在电脑前准备打一场CF,哈哈a题b题很快过了,c题卡了一下,原因是在poj做过类似的一道题,http://www.cnblogs.com/wuyiqi/archive/2011/09/20/2182986.html但是这道题目只需要求有几个区间能被其他区间完全覆盖,并不需要求每个区间分别能被几个区间覆盖,这是本质差别对于这道题,只需要排个序(没必要用树状数组)x递增,y递减所以后面的x肯定大于等于前面的x,现在只需要比较y即可,如果y小于m 阅读全文
posted @ 2011-12-19 00:03 Because Of You 阅读(419) 评论(0) 推荐(0)
摘要:偶尔逛到这题,是2011年世界总决赛的题目,怀着一丝敬畏和期待开始看这道题目二维平面内一个多边形,可以任意旋转,使得可以将其扔进一个宽为w的槽,求w的最小值idea:开始的时候随便画了画草图,假设最后最优的情况是两个点分别在槽的两边,则一定可以绕其中的一个点旋转一个角度使得产生空隙(纸上画一画就知道了),此时的答案应该更小才是,进一步可以发现一定能够将一条边转到槽的便上,所以,有方案了。先求土包,枚举土包上的每条边,再枚举每个土包上的点,求出最大的距离,这些最大距离的最小值就是我们要的答案可惜没有1A....没有判断n为0的时候停止。。囧!View Code #include<stdio 阅读全文
posted @ 2011-12-14 22:03 Because Of You 阅读(479) 评论(0) 推荐(0)
摘要:!A的感觉真是好,继续加油!View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<math.h> 4 #include<algorithm> 5 using namespace std; 6 #define M 16 7 const double eps=1e-8; 8 int map[M][M]; 9 const int inf = 1000000;10 bool flag[M];11 int D[M],nodes[M],w[M];12 int n,m,rest[M];13 阅读全文
posted @ 2011-11-05 22:10 Because Of You 阅读(378) 评论(0) 推荐(0)
摘要:题意:有一幅图,现在要加一条边,加边之后要你删除一条边,使图不连通,费用为边的费用,要你求的是删除的边的最小值的最大值(每次都可以删除一条边,选最小的删除,这些最小中的最大就为答案)首先要进行缩点,把图缩为一棵树,因此,加入一条边后图就会存在一个环,环中的任何一条边删除后都不会导致图不连通之后找一条最小的边,可以说这条边肯定是在加边之后的连通块里的,因为如果不在连通块里,那就直接可以把这条最小的边删掉,而达不到求出答案的目的找到边后,分别从边的两点开始遍历,要遍历出一条路径来,并且边上的权值要尽可能的小,因为这样才能让不在环中的边尽可能的大,然后,答案就是每个节点的次小儿子的最小值,如果没有次 阅读全文
posted @ 2011-11-04 09:39 Because Of You 阅读(1295) 评论(0) 推荐(1)
摘要:使用了书上讲的迭代加深搜索,假设删除一个点,两个点,三个点。。。每次都先找最短路径再枚举最短路径上的点删除,dfs实现,A的很顺利,呵呵。。View Code 1 #include<stdio.h> 2 #include<string.h> 3 int n,m,k; 4 int tot; 5 bool goal; 6 int fa[60]; 7 bool flag[60]; 8 int d[50][100]; 9 int head[60];10 int Q[10000];11 struct node12 {13 int t,next;14 }edge[10005];15 阅读全文
posted @ 2011-11-01 21:03 Because Of You 阅读(486) 评论(4) 推荐(0)
摘要:开始的时候二分的地方写错了,一直找不出错,搜搜别人的题解,一对比就知道了每次输入的是一对点,只能在其中选一个点画圆,然后二分枚举半径,把不矛盾的点连一条边,建好图后,判断强连通是否有解即可,即会不会有某一对点属于同一个强连通分量中,如果都不会,则半径合法View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<vector> 4 #include<math.h> 5 #include<algorithm> 6 using namespace std; 7 const i 阅读全文
posted @ 2011-10-29 20:48 Because Of You 阅读(392) 评论(0) 推荐(0)
摘要:感觉建图复杂度过大啊,但还是AC了。。。View Code 1 #include<stdio.h> 2 #include<string.h> 3 char str[210][1010]; 4 int map[210][210]; 5 int min(int a,int b){return a<b?a:b;} 6 const int inf = 9999999; 7 int n,match[210]; 8 bool sx[210],sy[210]; 9 int lx[210],ly[210]; 10 bool path(int u) 11 { 12 sx[u]=tr 阅读全文
posted @ 2011-10-28 20:18 Because Of You 阅读(289) 评论(0) 推荐(0)
摘要:因为两个有重叠的开放时间段的景点不可能在同一天游览完,一天只能游览其中的一个,所以求最大的区间重叠次数就好了View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<algorithm> 4 #include<iostream> 5 using namespace std; 6 int vis[24*3600+5]; 7 int main() 8 { 9 int n,i,j,s,t;10 while(scanf("%d",&n),n)11 {12 int 阅读全文
posted @ 2011-10-28 13:57 Because Of You 阅读(252) 评论(0) 推荐(0)
摘要:View Code 1 #include<stdio.h> 2 #include<string.h> 3 int map[20][20]; 4 int dx[]={1,1,0,-1,-1,-1,0,1}; 5 int dy[]={0,1,1, 1, 0,-1,-1,-1}; 6 int len=15; 7 int n; 8 bool inside(int x,int y) 9 { 10 return (x>=1&&x<=len&&y>=1&&y<=len); 11 } 12 bool check(i 阅读全文
posted @ 2011-10-28 11:56 Because Of You 阅读(232) 评论(0) 推荐(0)
摘要:表示原来用RMQ和LCA做的方法烦了,现在直接在建最小生成树的过程中建双向边就好了, cost[i][j]表示i到j的最长树边View Code 1 #include<string.h> 2 #include<stdio.h> 3 #include<vector> 4 #include<math.h> 5 #include<queue> 6 using namespace std; 7 const int M =1010; 8 const double inf = 1e20; 9 double max(double a,double 阅读全文
posted @ 2011-10-25 22:02 Because Of You 阅读(299) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<algorithm>using namespace std;int m,n;int a[105],b[105];int diff,ans;int solve(int x,int y){ int temp; int d=0; temp=(x^y); if(temp&1) d++; while(temp) { if((temp>>1)&1) d++; temp>>=1; } return d;}int main(){ int T;... 阅读全文
posted @ 2011-10-18 19:29 Because Of You 阅读(289) 评论(0) 推荐(0)
摘要:一开始就瞄准了这一题,题目没看懂,想看其他题目,没想到瞬间就有十几个人A了,果断继续看,发现只要距离远的先输送细菌就好了View Code #include<stdio.h>#include<string.h>#include<algorithm>using namespace std;struct cell{ int d,t;}c[100010];int end[100010];int sum;int cmp(cell a,cell b){ if(a.t==b.t) return a.d>b.d; return a.t>b.t;}int mai 阅读全文
posted @ 2011-10-07 20:30 Because Of You 阅读(303) 评论(0) 推荐(0)
摘要:题目数据较小,直接枚举自己和敌人的所有全排列,暴力水之(讨论出做法后,队友写的)View Code #include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int n;int id1[10],id2[10];struct node{ char s[25];}p[10];int map[10][10];int cmp(node a,node b){ return strcmp(a.s,b.s)<0;}void init(){ for(int i=0;i<n; 阅读全文
posted @ 2011-10-07 20:23 Because Of You 阅读(252) 评论(0) 推荐(0)
摘要:一觉醒来,不觉已经是4点了,于是果断挑了一道水题。View Code #include<stdio.h>#include<string.h>#include <cctype>char str[5000];int main(){ int i,j,k; while(gets(str)) { char s[]="0000"; int len=strlen(str); int row=len/16; int left=len%16; int a=0; for(i=0;i<row;i++) ... 阅读全文
posted @ 2011-10-02 18:01 Because Of You 阅读(238) 评论(0) 推荐(0)
摘要:View Code #include<stdio.h>#include<string.h>int c[50010];char str[50010];int n,m;int lowbit(int x){ return x&(-x);}void update(int x,int d){ while(x<=n) { c[x]+=d; x+=lowbit(x); }}int sum(int x){ int ans=0; while(x>0) { ans+=c[x]; x-=lowbit(x); } ... 阅读全文
posted @ 2011-09-23 21:51 Because Of You 阅读(357) 评论(0) 推荐(0)
摘要:View Code #include<queue>#include<iostream>#include<vector>using namespace std;struct mycmp{ bool operator()(const int &a,const int &b) { return a>b; }};//这里表示从小到大排列,最小的数在队头,随时准备走出队列int main(){ int n,k,val; char str[5]; int count; while(scanf("%d%d",&n,& 阅读全文
posted @ 2011-09-23 15:25 Because Of You 阅读(861) 评论(1) 推荐(0)
摘要:现在还不怎么适应比赛的节奏啊,二分边长即可,余弦定理求角度即可,注意,要先判断所选取的边是否合法View Code #include<stdio.h>#include<string.h>#include<math.h>#include<stdlib.h>const double pi = acos(-1.0);const double expn=1e-8;double a[110];int n;double get_angel(double x,double y,double z){ return acos((x*x+y*y-z*z)/(2*x* 阅读全文
posted @ 2011-09-12 15:28 Because Of You 阅读(268) 评论(0) 推荐(0)
摘要:直接在矩阵上进行floyd在判断即可View Code #include<stdio.h>int map[110][110];int vis[110][110];int main(){ int t,n,i,j,k; int cases=1; scanf("%d",&t); while(t--) { scanf("%d",&n); int tot=n*(n-1); for(i=1;i<=n;i++) for(j=1;j<=n;j++) { scanf(... 阅读全文
posted @ 2011-09-11 21:39 Because Of You 阅读(163) 评论(0) 推荐(0)
摘要:View Code #include<stdio.h>#include<math.h>#include<string.h>struct PEAK{ double x,h;}p[1100];struct bit{ double x,v,m;}pat[1100];int main(){ int G=20; double h; int t,cases=1,i,j,n,m,w; scanf("%d",&t); while(t--) { double v0=0,temp; scanf("%d%d%d",&n,&a 阅读全文
posted @ 2011-09-11 21:19 Because Of You 阅读(312) 评论(0) 推荐(0)