Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## Re:真·AC代码

Posted by Bartholomew at 2017-11-08 19:05:58 on Problem 2449
In Reply To:真·AC代码 Posted by:RiseFalcon at 2016-04-07 12:25:20
```>
>
>
>
>      衡水门右拐滏阳河
>
>
>
> #include<cstdio>
> #include<cstring>
> #include<queue>
> #include<con>
> #include<iostream>
> #define MAX_NODE 2010
> #define MAX_LENS 200100
> char c;
> 	do{c=getchar();}while(c<'0'||c>'9');
> 	do{k=k*10+c-'0';c=getchar();}while(c>='0'&&c<='9');
> }
> struct Path{
> 	int to;
> 	int dis;
> 	int next;
> 	Path(){to=-1;dis=0x7ffffff;next=-1;}
> };
> struct Picture{
> 	int from,to,dis;
> }PIC[MAX_LENS];
> struct Node{
> 	long long int f;
> 	int g;
> 	int place;
> 	Node(long long int a=0,int b=0,int c=0):f(a),g(b),place(c){}
> 	bool operator < (const Node &a)const{
> 		return f<a.f;
> 	}
> };
> struct Heap{
> 	int size;
> 	Node table[MAX_LENS*10];
> 	Heap(){size=0;}
> 	void exchange(Node &a,Node &b){
> 		Node c=a;a=b;b=c;
> 	}
> 	bool empty(){return size==0;}
> 	void push(const Node &number){
> 		int place=size;
> 		int last;
> 		table[size]=number;
> 		size++;
> 		while(place!=0){
> 			last=(place-1)>>1;
> 			if(table[place]<table[last])exchange(table[last],table[place]);
> 			else break;
> 			place=last;
> 		}
> 	}
> 	Node pop(){
> 		Node ans=table[0];
> 		table[0]=table[--size];
> 		int t=0;
> 		int l=1,r=2;
> 		while(l<size)
> 		{
> 			if(r<size&&table[r]<table[l])l=r;
> 			if(table[l]<table[t]){exchange(table[t],table[l]);t=l;}
> 			else break;
> 			l=(t<<1|1);r=(t<<1)+2;
> 		}
> 		return ans;
> 	}
> };
> struct Pic{
> 	int lens;
> 	int points;
> 	int len_num;
> 	int cnt[MAX_NODE];
> 	int dis[MAX_NODE];
> 	Path table[MAX_LENS];
> 	Heap q;
> 	void clean(){
> 	}
> 		if(flag==1){
> 			for(int i=1;i<=len_num;++i){
> 				table[lens].to=PIC[i].to;
> 				table[lens].dis=PIC[i].dis;
> 			}
> 		}
> 		else{
> 			for(int i=1;i<=len_num;++i){
> 				table[lens].to=PIC[i].from;
> 				table[lens].dis=PIC[i].dis;
> 			}
> 		}
> 	}
> 	void dijsa(int from){
> 		dis[from]=0;
> 		q.push(Node(0,0,from));
> 		while(!q.empty()){
> 			Node ppt=q.pop();
> 			if(dis[ppt.place]!=ppt.f)continue;
> 				if(dis[table[i].to]>dis[ppt.place]+table[i].dis){
> 					dis[table[i].to]=dis[ppt.place]+table[i].dis;
> 					q.push(Node(dis[table[i].to],0,table[i].to));
> 				}
> 			}
> 		}
> 	}
> 	void A_Star(int from,int to,int Times){
> 		if(from==to)++Times;
> 		while(!q.empty())q.pop();
> 		q.push(Node(dis[from],0,from));
> 		while(!q.empty()){
> 			Node pos=q.pop();
> 			if(pos.place==to){
> 				--Times;
> 				if(Times==0){
> 					std::cout<<pos.g;
> 					return ;
> 				}
> 			}
> 				q.push(Node( dis[table[i].to]+table[i].dis+pos.g, table[i].dis+pos.g ,table[i].to));
> 			}
> 		}
> 		puts("-1");
> 		return;
> 	}
> 	int doing(){
> //		freopen("dota.in","r",stdin);
> //		freopen("dota.out","w",stdout);
> 		int a,b,c,from,to,Times;
> 		for(int i=1;i<=len_num;++i){
> 			PIC[i].from=a;
> 			PIC[i].to=b;
> 			PIC[i].dis=c;
> 		}
> 		A_Star(from,to,Times);
> 		return 0;
> 	}
> }a;
> int main(){;}
```

Followed by: