| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 51229 | robert | 관광 (NOI14_sightseeing) | C++14 | 3531 ms | 110988 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> ii;
vector<vector<ii > > g;
ii UFDS[500100];
vector<int> d;
void dfs(int n, int p, int minv){
	d[n] = minv;
	for(int x=0; x<g[n].size(); x++){
		if(g[n][x].first!=p){
			dfs(g[n][x].first, n, min(minv, g[n][x].second));
		}
	}
}
int p(int n){
	if(n==UFDS[n].first)
		return n;
	return UFDS[n].first = p(UFDS[n].first);
}
int merge(int a, int b){
	a = p(a);
	b = p(b);
	if(UFDS[a].second<UFDS[b].second){
		UFDS[a].first = b;
	} else if(UFDS[a].second>UFDS[b].second){
		UFDS[b].first = a;
	} else {
		UFDS[a].first = b;
		UFDS[b].second++;
	}
}
int main(){
	iostream::sync_with_stdio(false);
	cin.tie(0);
	int N, M, Q; scanf("%d %d %d", &N, &M, &Q);
	g.assign(N+1, vector<ii >());
	int a, b, c;
	priority_queue<pair<int, ii> > q;
	for(int m=0; m<M; m++){
		scanf("%d %d %d", &a, &b, &c);
		q.push({c, {a, b}});
	}
	for(int n=0; n<=N; n++)
		UFDS[n] = {n, 1};
	while(!q.empty()){
		pair<int, ii> t = q.top(); q.pop();
//		cout << t.first << endl;
		if(p(t.second.first)!=p(t.second.second)){
//			cout << "a" << endl;
			merge(t.second.first, t.second.second);
//			cout << t.second.first << " " << t.second.second << endl;
			g[t.second.first].push_back({t.second.second, t.first});
			g[t.second.second].push_back({t.second.first, t.first});
		}
//		cout << t.first << endl;
	}
	d.assign(N+1, 0);
	dfs(1, -1, 1e9);
	for(int q=0; q<Q; q++){
		int a;
		scanf("%d", &a);
		printf("%d\n", d[a]);
	}
	return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
