답안 #706898

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
706898 2023-03-08T05:56:04 Z penguin133 악어의 지하 도시 (IOI11_crocodile) C++17
89 / 100
488 ms 73108 KB
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
 
//#define int long long
#define pi pair<long long, long long>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	vector <pi> adj[N + 5];
	long long dist[N+5][2];
	for(int i=0;i<=N;i++)dist[i][0] = dist[i][1] = 1e10;
	for(int i=0;i<M;i++){
		adj[R[i][0]].push_back({R[i][1], L[i]});
		adj[R[i][1]].push_back({R[i][0], L[i]});
	}
	priority_queue <pi, vector<pi>, greater<pi> > pq;
	for(int i=0;i<K;i++){
		dist[P[i]][0] = dist[P[i]][1] = 0;
		pq.push({0, P[i]});
	}
	while(!pq.empty()){
		long long x = pq.top().fi, y = pq.top().se;
		pq.pop();
		if(dist[y][1] != x)continue;
		for(auto [i, j] : adj[y]){
			if(dist[i][0] > x + j){
				dist[i][1] = dist[i][0];
				dist[i][0] = x + j;
				if(dist[i][1] != 1e10)pq.push({dist[i][1], i});
			}
			else if(dist[i][1] > x + j){
				dist[i][1] = x + j;
				pq.push({dist[i][1], i});
			}
		}
	}
	return dist[0][1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 308 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 308 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 700 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 4 ms 980 KB Output is correct
13 Correct 3 ms 980 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 308 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 700 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 4 ms 980 KB Output is correct
13 Correct 3 ms 980 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 390 ms 65548 KB Output is correct
17 Correct 63 ms 14412 KB Output is correct
18 Correct 82 ms 16736 KB Output is correct
19 Correct 488 ms 73108 KB Output is correct
20 Correct 260 ms 52868 KB Output is correct
21 Correct 31 ms 6732 KB Output is correct
22 Incorrect 266 ms 48412 KB Output isn't correct
23 Halted 0 ms 0 KB -