답안 #16399

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
16399 2015-08-22T10:34:52 Z comet 악어의 지하 도시 (IOI11_crocodile) C++
100 / 100
709 ms 152636 KB
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstring>
using namespace std;
typedef pair<int,int> pp;
typedef vector<pp> vec;
vector<vector<pp> > path;
int d[100000][2],INF;
bool visit[100000];
int travel_plan(int N,int M,int R[][2],int L[],int K,int P[]){
	path.assign(N,vec());
	memset(d,0x3f,sizeof(d));
	INF=d[0][0];
	for(int i=0;i<M;i++){
		path[R[i][0]].push_back(pp(R[i][1],L[i]));
		path[R[i][1]].push_back(pp(R[i][0],L[i]));
	}
	priority_queue<pp> Q;
	for(int i=0;i<K;i++){
		Q.push(pp(0,P[i]));
		d[P[i]][1]=d[P[i]][0]=0;
	}
	int v,dist;
	while(!Q.empty()){
		do{
			v=Q.top().second;
			dist=-Q.top().first;
			Q.pop();
		}while(!Q.empty()&&visit[v]);
		visit[v]=1;
		for(int i=0;i<path[v].size();i++){
			int u=path[v][i].first;
			int c=path[v][i].second;
			if(d[u][0]>=dist+c){
				swap(d[u][0],d[u][1]);
				d[u][0]=dist+c;
				if(d[u][1]<INF)Q.push(pp(-d[u][1],u));
			}
			else if(d[u][1]>dist+c){
				d[u][1]=dist+c;
				Q.push(pp(-d[u][1],u));
			}
		}
	}
	return d[0][1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 119844 KB Output is correct
2 Correct 1 ms 119844 KB Output is correct
3 Correct 0 ms 119844 KB Output is correct
4 Correct 0 ms 119844 KB Output is correct
5 Correct 2 ms 119844 KB Output is correct
6 Correct 0 ms 119844 KB Output is correct
7 Correct 0 ms 119844 KB Output is correct
8 Correct 0 ms 119844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 119976 KB Output is correct
2 Correct 0 ms 119844 KB Output is correct
3 Correct 0 ms 119844 KB Output is correct
4 Correct 5 ms 119976 KB Output is correct
5 Correct 0 ms 120108 KB Output is correct
6 Correct 0 ms 119844 KB Output is correct
7 Correct 0 ms 119844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 537 ms 147376 KB Output is correct
2 Correct 52 ms 126808 KB Output is correct
3 Correct 147 ms 127996 KB Output is correct
4 Correct 709 ms 152636 KB Output is correct
5 Correct 67 ms 142736 KB Output is correct
6 Correct 27 ms 122792 KB Output is correct
7 Correct 370 ms 138892 KB Output is correct