답안 #42305

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
42305 2018-02-25T20:38:55 Z wzy 악어의 지하 도시 (IOI11_crocodile) C++11
100 / 100
761 ms 101216 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define pii pair<int,int>
#define eps (int) 1e9

long long d[100005][2];
vector<pii> adj[100005];
bool cc[100005] , vis[100005];



int travel_plan(int n, int m, int R[][2], int l[], int k, int p[]){
	for(int i = 0 ; i <m  ;i++){
		adj[R[i][0]].pb(pii(l[i],R[i][1]));
		adj[R[i][1]].pb(pii(l[i],R[i][0]));
	}
	for(int i = 0 ; i <n;i++){
		d[i][0] = eps;
		d[i][1] = eps;
	}
	priority_queue<pii , vector<pii> , greater<pii> > pq;
	for(int i = 0 ; i < k ;i++){
		int x;
		x = p[i];
		cc[x] = true;
		d[x][0] = 0;
		d[x][1] = 0;
		pq.push(pii(0,x));
	}
	while(!pq.empty()){
		pii u = pq.top();
		pq.pop();
		if(vis[u.S]) continue;
		vis[u.S] = true;
		for(int j = 0 ; j  < (int)adj[u.S].size();j++){
			pii v = adj[u.S][j];
			if(d[u.S][1] + v.F < d[v.S][0]){
				swap(d[v.S][0] , d[v.S][1]);
				d[v.S][0] = d[u.S][1] + v.F;
				pq.push(pii(d[v.S][1],v.S));
			}
			else if(d[u.S][1] + v.F < d[v.S][1]){
				d[v.S][1] = d[u.S][1] + v.F;
				pq.push(pii(d[v.S][1] , v.S));
			}
		}
	}
	return d[0][1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2680 KB Output is correct
2 Correct 3 ms 2788 KB Output is correct
3 Correct 3 ms 2904 KB Output is correct
4 Correct 4 ms 2964 KB Output is correct
5 Correct 4 ms 3012 KB Output is correct
6 Correct 4 ms 3080 KB Output is correct
7 Correct 4 ms 3092 KB Output is correct
8 Correct 4 ms 3108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3440 KB Output is correct
2 Correct 3 ms 3440 KB Output is correct
3 Correct 4 ms 3440 KB Output is correct
4 Correct 7 ms 3708 KB Output is correct
5 Correct 6 ms 3824 KB Output is correct
6 Correct 3 ms 3824 KB Output is correct
7 Correct 4 ms 3824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 571 ms 59444 KB Output is correct
2 Correct 123 ms 59444 KB Output is correct
3 Correct 144 ms 59444 KB Output is correct
4 Correct 761 ms 87868 KB Output is correct
5 Correct 372 ms 89744 KB Output is correct
6 Correct 57 ms 89744 KB Output is correct
7 Correct 407 ms 101216 KB Output is correct