답안 #964134

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
964134 2024-04-16T10:57:23 Z pragmatist 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
600 ms 63308 KB
#include "crocodile.h"
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = (int)1e5+7;
const long long INF = (long long)1e18+7;
 
vector<pair<int, int> > g[N];
int n, m;
long long d1[N], d2[N];
bool used[N];
 
int travel_plan(int _N, int _M, int _R[][2], int _L[], int _K, int _P[]) {
	n = _N;
	m = _M;
	for(int i = 0; i < m; ++i) {
		int u = _R[i][0], v = _R[i][1], w = _L[i];
		u++;
		v++;
		g[u].push_back({v, w});
		g[v].push_back({u, w});
	}
	for(int i = 1; i <= n; ++i) {
		d1[i] = d2[i] = INF;
	}

	set<pair<long long, int> > q;
	for(int i = 0; i < _K; ++i) {
		int v = _P[i]+1;
		d1[v]=d2[v]=0;
		q.insert({0, v});
	}
	while(!q.empty()) {
		int v = q.begin()->second;
	    q.erase(q.begin());
		used[v] = 1;
		for(auto [to, w] : g[v]) {
          	if(used[to]) {
              continue;
            }
			if(d2[v]+w<d1[to]) {
			    q.erase({d2[to], to});
				d2[to]=d1[to];
				d1[to]=d2[v]+w;
				q.insert({d2[to], to});				
			} else {    
				if(d2[v]+w<d2[to]) {
				    q.erase({d2[to], to});
					d2[to]=d2[v]+w;
					q.insert({d2[to], to});				
				}
			}
		}
	}
	return d2[1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 1 ms 6596 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 1 ms 6596 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 3 ms 6744 KB Output is correct
10 Correct 2 ms 6600 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 5 ms 6972 KB Output is correct
13 Correct 3 ms 7004 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 1 ms 6596 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 3 ms 6744 KB Output is correct
10 Correct 2 ms 6600 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 5 ms 6972 KB Output is correct
13 Correct 3 ms 7004 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 390 ms 58288 KB Output is correct
17 Correct 60 ms 16672 KB Output is correct
18 Correct 113 ms 18532 KB Output is correct
19 Correct 600 ms 63308 KB Output is correct
20 Correct 236 ms 51872 KB Output is correct
21 Correct 37 ms 12376 KB Output is correct
22 Correct 278 ms 49432 KB Output is correct