답안 #786062

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
786062 2023-07-18T01:23:42 Z KN200711 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
413 ms 100968 KB
#include "crocodile.h"
# include <bits/stdc++.h>
# define ll long long
# define fi first
# define se second
using namespace std;

bool vis[100001], ct[100001];
ll nw[100001];
vector<pair<int, ll> > edge[100001];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
	for(int i=0;i<N;i++) {
		vis[i] = 0;
		ct[i] = 0;
		edge[i].clear();
	}
	for(int i=0;i<M;i++) {
		edge[R[i][0]].push_back(make_pair(R[i][1], L[i]));
		edge[R[i][1]].push_back(make_pair(R[i][0], L[i]));
	}
	for(int i=0;i<K;i++) vis[P[i]] = 1;
	
	priority_queue< pair<ll, int> > PQ;
	for(int i=0;i<K;i++) {
		for(int c=0;c<edge[P[i]].size();c++) {
			PQ.push(make_pair(-edge[P[i]][c].se, edge[P[i]][c].fi));
		}
	}
	
	while(!PQ.empty()) {
		ll a = -PQ.top().fi;
		int b = PQ.top().se;
		PQ.pop();
		
		if(vis[0]) break;
		if(vis[b]) continue;
		if(ct[b]) {
			nw[b] = a;
			vis[b] = 1;
			for(int k=0;k<edge[b].size();k++) {
				if(!vis[edge[b][k].fi]) PQ.push(make_pair(-a-edge[b][k].se, edge[b][k].fi));
			}
		} else ct[b] = 1;
	}
	
	return nw[0];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:26:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for(int c=0;c<edge[P[i]].size();c++) {
      |               ~^~~~~~~~~~~~~~~~~~
crocodile.cpp:41:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |    for(int k=0;k<edge[b].size();k++) {
      |                ~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2716 KB Output is correct
5 Correct 3 ms 2772 KB Output is correct
6 Correct 2 ms 2660 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2716 KB Output is correct
5 Correct 3 ms 2772 KB Output is correct
6 Correct 2 ms 2660 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2676 KB Output is correct
9 Correct 3 ms 3156 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2900 KB Output is correct
12 Correct 5 ms 3708 KB Output is correct
13 Correct 4 ms 3796 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 3 ms 2796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2716 KB Output is correct
5 Correct 3 ms 2772 KB Output is correct
6 Correct 2 ms 2660 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2676 KB Output is correct
9 Correct 3 ms 3156 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2900 KB Output is correct
12 Correct 5 ms 3708 KB Output is correct
13 Correct 4 ms 3796 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 3 ms 2796 KB Output is correct
16 Correct 413 ms 97212 KB Output is correct
17 Correct 58 ms 16960 KB Output is correct
18 Correct 70 ms 19440 KB Output is correct
19 Correct 391 ms 100968 KB Output is correct
20 Correct 263 ms 84600 KB Output is correct
21 Correct 31 ms 9548 KB Output is correct
22 Correct 355 ms 64456 KB Output is correct