摘要:
http://poj.org/problem?id=3159思路:用O(V+ElogV)的Dijkstra算法求1到n的最短路。即用优先队列优化Dijkstra算法。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=300005; 6 const int maxm=150002; 7 struct node 8 { 9 int u,v,w;10 int next;11 } edge[maxm];12 struct pot13 {14 int v,w;15 p... 阅读全文
posted @ 2013-11-22 19:30
N_ll
阅读(246)
评论(0)
推荐(0)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1025题意:富人路与穷人路都分别有从1到n的n个点,现在要在富人点与穷人点之间修路,但是要求路不能交叉,问最多能修多少条。思路:穷人路是按顺序给的,故求富人路的最长上升子序列即可。由于数据范围太大,应该用O(nlogn)的算法求LIS。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int N=500005; 6 int r[N],d[N]; 7 int main() 8 { 9 int n,cnt = 0,x,y... 阅读全文
posted @ 2013-11-22 16:24
N_ll
阅读(219)
评论(0)
推荐(0)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1429 1 #include 2 #include 3 #include 4 using namespace std; 5 struct node 6 { 7 int x,y; 8 int state; 9 int step; 10 } s,t; 11 int Time,n,m; 12 int s_x,s_y,e_x,e_y; 13 char a[32][32]; 14 int vis[32][32][1026];//标记状态 15 int dir[4][2] ... 阅读全文
posted @ 2013-11-22 09:41
N_ll
阅读(180)
评论(0)
推荐(0)

浙公网安备 33010602011771号