답안 #465521

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
465521 2021-08-16T09:33:44 Z MohamedFaresNebili 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
543 ms 66872 KB
#include <bits/stdc++.h>
#include "crocodile.h"

using namespace std;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	vector<pair<int, int>>adj[N]; vector<int> d(N, 0);
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>pq;
	for(int l=0;l<M;l++) {
		int a=R[l][0], b=R[l][1], w=L[l];
		adj[a].push_back({b, w});
		adj[b].push_back({a, w});
	}
	for(int l=0;l<K;l++) {
		int a=P[l]; d[a]=1; pq.push({0, a});
	}
	vector<bool>vis(N, false);
	while(!pq.empty()) {
		int a=pq.top().second, w=pq.top().first; pq.pop();
		if(d[a]==0) { d[a]=1; continue; }
		if(vis[a]) continue; vis[a]=true;
		if(a==0) return w;
		for(auto u:adj[a]) {
			int to=u.first, s=u.second;
			if(vis[to]) continue;
			pq.push({w+s, to});
		}
	}
	return -1;
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:22:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   22 |   if(vis[a]) continue; vis[a]=true;
      |   ^~
crocodile.cpp:22:24: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   22 |   if(vis[a]) continue; vis[a]=true;
      |                        ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 568 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 6 ms 972 KB Output is correct
13 Correct 6 ms 844 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 568 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 6 ms 972 KB Output is correct
13 Correct 6 ms 844 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 492 ms 62764 KB Output is correct
17 Correct 83 ms 13300 KB Output is correct
18 Correct 95 ms 14720 KB Output is correct
19 Correct 543 ms 66872 KB Output is correct
20 Correct 308 ms 46932 KB Output is correct
21 Correct 44 ms 5836 KB Output is correct
22 Correct 434 ms 44464 KB Output is correct