题目意思,可以从A走到B当且仅当B到终点的最短路径小于A到终点的最短路径问一共存在几条这样的路径我用dijkstra各做了一遍,呵呵个中细节还需细细体味啊View Code #include<stdio.h>#include<queue>#include<string.h>using namespace std;const int INF = 9999999;struct NODE{ int v,w; int next;}list[10000000];int tot;int head[1010];int dis[1010];int vis[1010];int Read More
posted @ 2011-09-26 15:19 Because Of You Views(276) Comments(0) Diggs(0) Edit
一个人的旅行Time Limit : 1000/1000ms (Java/Other)Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 28Accepted Submission(s) : 7Font: Times New Roman | Verdana | GeorgiaFont Size: ← →Problem Description虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗~),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子,^0^),很多事,还能丰富自己的阅历,还可以看美丽 Read More
posted @ 2011-09-26 12:26 Because Of You Views(427) Comments(0) Diggs(0) Edit
题目任意给出四个点,求出到这四个点的距离之和最小的点到这四个点的距离若四边形为凸的,费马点为对角线交点,否则为凹的那点证明很简单,把要证明的那点与其他顶点连起来,再任取一点,证明这点到四个顶点的距离比原来那点长即可View Code #include<stdio.h>#include<math.h>#include<string.h>const double esp=1e-8;struct point{ double x,y;}a[10];struct line { double a,b,c;};double min(double a,double b){ Read More
posted @ 2011-09-24 20:35 Because Of You Views(490) Comments(0) Diggs(0) Edit
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); } ... Read More
posted @ 2011-09-23 21:51 Because Of You Views(351) Comments(0) Diggs(0) Edit
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,& Read More
posted @ 2011-09-23 15:25 Because Of You Views(855) Comments(1) Diggs(0) Edit
Fruit NinjaTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 374Accepted Submission(s): 197Problem DescriptionRecently, dobby is addicted in the Fruit Ninja. As you know, dobby is a free elf, so unlike other elves, he could do whatever he wants.But t Read More
posted @ 2011-09-23 12:00 Because Of You Views(445) Comments(0) Diggs(0) Edit
请看几段区间1 --------------2 -------------3 --------4 -----先按y排序,再按x排序;排好序后就跟stars那题一样了一次遍历排序后的数组,由于比当前遍历元素strong的区间只可能存在于已经遍历过的元素中;所以我们可以放心大胆的直接对树状数组求和然后向后更新树状数组中统治x的点上的值,因为那些位置都多了一个比 以他们为左端点的区间 强壮 的区间;然后注意一下相同区间的处理即可跑了1157ms的代码。其实感觉也蛮快的了*-*View Code #include<stdio.h>#include<string.h>#inclu Read More
posted @ 2011-09-20 23:49 Because Of You Views(432) Comments(0) Diggs(0) Edit
View Code #include<stdio.h>#include<math.h>#include<string.h>#include<algorithm>using namespace std;#define N 1001const double pi=acos(-1.0);struct point { int x,y;}node[N];int s[N];int top;int cmp(point a,point b){ if(a.y==b.y) return a.x<b.x; return a.y<b.y;}double ch Read More
posted @ 2011-09-17 21:29 Because Of You Views(212) Comments(0) Diggs(0) Edit
其实不管什么DP,本质思想都是不变的,围绕着最优子结构展开思路,最终记录下最优的结果,所以写好状态转移,处理好边界问题,还是关键手段。状态:dp[i][j]表示以i为根的子树孤立出 j 个点要去掉的最少的边,在树上的动态规划一般都是父结点和子节点的关系,所以在思考状态转移时时应该尽量把父结点的子节点考虑进去分别以不同的点为根进行深搜先要想到我们最后要得到的结果应该是dp[i][p]中的最小值而dp[i][j]是从dp[u][k]和dp[i][j-k]推过来的,u为i的子节点还有就是以i为根和以i的子节点为u根时,dp[u][k]+dp[i][j-k]多加了两次他们之间的边,所以要减去2即dp[ Read More
posted @ 2011-09-17 09:54 Because Of You Views(237) Comments(0) Diggs(0) Edit
View Code #include<stdio.h>#include<string.h>int map[105][105];int main(){ int n,m,a,b; int i,j,k; scanf("%d%d",&n,&m); memset(map,0,sizeof(map)); for(i=0;i<m;i++) { scanf("%d%d",&a,&b); map[a][b]=1; } for(k=1;k<=n;k++) for(i=1;i<=n;i++) for(j Read More
posted @ 2011-09-16 15:51 Because Of You Views(158) Comments(0) Diggs(0) Edit