답안 #67565

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67565 2018-08-15T02:11:32 Z Hoget157 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
993 ms 118764 KB
#include "crocodile.h"
#include <bits/stdc++.h>
#define ll long long
#define INF 1e+18
#define pb push_back
using namespace std;

struct edge{ ll to,cost; };
typedef pair<int,int> P;

ll n,m,d1[100010],d2[100010];
vector<edge> G[100010];

int travel_plan(int N, int M, int R[][2], int L[], int K, int Q[]){
	n = N,m = M;
	for(int i = 0;i < n;i++){
		d1[i] = INF;
		d2[i] = INF;
	}
	for(int i = 0;i < m;i++){
		G[R[i][0]].pb({R[i][1],L[i]});
		G[R[i][1]].pb({R[i][0],L[i]});
	}
	priority_queue<P,vector<P>,greater<P>> que;
	for(int i = 0;i < K;i++){
		d1[Q[i]] = 0;
		d2[Q[i]] = 0;
		que.push(P(0,Q[i]));
	}
	while(!que.empty()){
		P p = que.top();que.pop();
		ll v = p.second;
		if(d2[v] < p.first) continue;
		for(edge e : G[v]){
			ll cost = d2[v] + e.cost;
			if(d1[e.to] > cost) swap(d1[e.to],cost);
			if(d2[e.to] > cost){
				d2[e.to] = cost;
				que.push(P(d2[e.to],e.to));
			}
		}
	}
	return d2[0];
}


# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 3 ms 2800 KB Output is correct
3 Correct 5 ms 2868 KB Output is correct
4 Correct 5 ms 2928 KB Output is correct
5 Correct 5 ms 2960 KB Output is correct
6 Correct 6 ms 3168 KB Output is correct
7 Correct 5 ms 3168 KB Output is correct
8 Correct 5 ms 3168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 3 ms 2800 KB Output is correct
3 Correct 5 ms 2868 KB Output is correct
4 Correct 5 ms 2928 KB Output is correct
5 Correct 5 ms 2960 KB Output is correct
6 Correct 6 ms 3168 KB Output is correct
7 Correct 5 ms 3168 KB Output is correct
8 Correct 5 ms 3168 KB Output is correct
9 Correct 7 ms 3616 KB Output is correct
10 Correct 4 ms 3616 KB Output is correct
11 Correct 5 ms 3616 KB Output is correct
12 Correct 9 ms 4040 KB Output is correct
13 Correct 10 ms 4196 KB Output is correct
14 Correct 5 ms 4196 KB Output is correct
15 Correct 6 ms 4196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 3 ms 2800 KB Output is correct
3 Correct 5 ms 2868 KB Output is correct
4 Correct 5 ms 2928 KB Output is correct
5 Correct 5 ms 2960 KB Output is correct
6 Correct 6 ms 3168 KB Output is correct
7 Correct 5 ms 3168 KB Output is correct
8 Correct 5 ms 3168 KB Output is correct
9 Correct 7 ms 3616 KB Output is correct
10 Correct 4 ms 3616 KB Output is correct
11 Correct 5 ms 3616 KB Output is correct
12 Correct 9 ms 4040 KB Output is correct
13 Correct 10 ms 4196 KB Output is correct
14 Correct 5 ms 4196 KB Output is correct
15 Correct 6 ms 4196 KB Output is correct
16 Correct 788 ms 82616 KB Output is correct
17 Correct 97 ms 82616 KB Output is correct
18 Correct 157 ms 82616 KB Output is correct
19 Correct 993 ms 111008 KB Output is correct
20 Correct 425 ms 111008 KB Output is correct
21 Correct 51 ms 111008 KB Output is correct
22 Correct 389 ms 118764 KB Output is correct