답안 #1022711

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1022711 2024-07-14T03:26:02 Z socpite 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
572 ms 67728 KB
#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;

const int maxn = 1e5+5;
const int INF = 1e9+5;

vector<pair<int, int>> g[maxn];
int d[maxn][2];
int vis[maxn];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	for(int i = 0; i < N; i++){
		g[i].clear();
		d[i][0] = d[i][1] = INF;
		vis[i] = 0;
	}
	for(int i = 0; i < M; i++){
		g[R[i][0]].push_back({R[i][1], L[i]});
		g[R[i][1]].push_back({R[i][0], L[i]});
	}
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
	for(int i = 0; i < K; i++){
		d[P[i]][0] = d[P[i]][1] = 0;
		pq.push({0, P[i]});
	}
	while(!pq.empty()){
		auto x = pq.top();
		pq.pop();
		if(vis[x.second])continue;
		vis[x.second] = 1;
		for(auto v: g[x.second]){
			int tmp = x.first + v.second;
			if(tmp < d[v.first][0]){
				d[v.first][1] = d[v.first][0];
				d[v.first][0] = tmp;
			}
			else d[v.first][1] = min(tmp, d[v.first][1]);
			pq.push({d[v.first][1], v.first});
		}
	}
	return d[0][1];
}


# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2904 KB Output is correct
2 Correct 2 ms 2648 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 2 ms 2652 KB Output is correct
5 Correct 2 ms 2908 KB Output is correct
6 Correct 3 ms 2908 KB Output is correct
7 Correct 2 ms 2652 KB Output is correct
8 Correct 2 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2904 KB Output is correct
2 Correct 2 ms 2648 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 2 ms 2652 KB Output is correct
5 Correct 2 ms 2908 KB Output is correct
6 Correct 3 ms 2908 KB Output is correct
7 Correct 2 ms 2652 KB Output is correct
8 Correct 2 ms 2652 KB Output is correct
9 Correct 4 ms 2908 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 2 ms 2908 KB Output is correct
12 Correct 5 ms 3328 KB Output is correct
13 Correct 4 ms 3420 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 2 ms 2836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2904 KB Output is correct
2 Correct 2 ms 2648 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 2 ms 2652 KB Output is correct
5 Correct 2 ms 2908 KB Output is correct
6 Correct 3 ms 2908 KB Output is correct
7 Correct 2 ms 2652 KB Output is correct
8 Correct 2 ms 2652 KB Output is correct
9 Correct 4 ms 2908 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 2 ms 2908 KB Output is correct
12 Correct 5 ms 3328 KB Output is correct
13 Correct 4 ms 3420 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 2 ms 2836 KB Output is correct
16 Correct 526 ms 64728 KB Output is correct
17 Correct 81 ms 15312 KB Output is correct
18 Correct 95 ms 16864 KB Output is correct
19 Correct 572 ms 67728 KB Output is correct
20 Correct 364 ms 53700 KB Output is correct
21 Correct 35 ms 8276 KB Output is correct
22 Correct 387 ms 46760 KB Output is correct