제출 #140352

#제출 시각아이디문제언어결과실행 시간메모리
140352muradeyn악어의 지하 도시 (IOI11_crocodile)C++14
89 / 100
398 ms40928 KiB
#include "crocodile.h"
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;

const int maxx = 1000;

int x , y;
int ext[maxx];
long long ans[maxx];

vector< pair<int,int> >v[maxx];

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) {
	for (int i = 0;i<n;i++)ans[i] = INT_MAX;
	for (int i = 0;i<k;i++)ext[p[i]] = 1 , ans[p[i]] = 0;
	for (int i = 0;i<m;i++) {
		x = r[i][0]; y = r[i][1];
		if (!ext[x])v[y].push_back({x , l[i]});
		if (!ext[y])v[x].push_back({y , l[i]});
	}
	bool f = true;
	while (f) {
		f = false;
		vector<int>thru[maxx];
		for (int i = 0;i<n;i++) {
			if (ans[i] == INT_MAX)continue;
			for (auto to : v[i]) thru[to.F].push_back(to.S + ans[i]);
		}
		for (int i = 0;i<n;i++) {
			if (thru[i].size() < 2)continue;
			sort(thru[i].begin(),thru[i].end());
			if (thru[i][1] < ans[i]) {
				f = true;
				ans[i] = thru[i][1];
			}
		}
	}
	return ans[0];
}


#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...