#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <deque>
#include <utility>
#include <bitset>
#include <limits.h>
#include <time.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;
const int E_ = 5000005;
const int V_ = 500005;
const int LM = 200005;
int V, E, Q;
int group[V_];
int Res[V_];
int get_group (int u) {
return (u == group[u]) ? u : (group[u] = get_group(group[u]));
}
int edge[E_][2];
int start[LM], link[E_];
int start2[V_], link2[E_+E_], con2[E_+E_], cst2[E_+E_];
int que[V_], qf, qr;
bool visited[V_];
void mark (int s, int w) {
qf = qr = 0; que[++qr] = s;
while(qf < qr) {
int u = que[++qf];
visited[u] = true; Res[u] = w;
for(int e = start2[u]; e > 0; e = link2[e]) {
int v = con2[e], c = cst2[e];
if(c >= w && !visited[v]) visited[v] = true, Res[v] = w, que[++qr] = v;
}
}
}
int main() {
int i, j, k;
scanf("%d%d%d", &V, &E, &Q);
for(int i = 1; i <= E; i++) {
int u, v, c; scanf("%d%d%d", &u, &v, &c);
link[i] = start[c]; start[c] = i;
link2[i+i-1] = start2[u]; start2[u] = i+i-1; con2[i+i-1] = v; cst2[i+i-1] = c;
link2[i+i] = start2[v]; start2[v] = i+i; con2[i+i] = u; cst2[i+i] = c;
edge[i][0] = u; edge[i][1] = v;
}
for(int i = 1; i <= V; i++) group[i] = i;
for(int c = 200000; c >= 1; c--) {
for(int e = start[c]; e > 0; e = link[e]) {
int u = edge[e][0], v = edge[e][1];
int ug = get_group(u), vg = get_group(v), hg = get_group(1);
if(ug != vg) {
if(ug == hg) mark(v, c);
if(vg == hg) mark(u, c);
group[ug] = vg;
}
}
}
for(int i = 1; i <= Q; i++) {
int x; scanf("%d", &x);
printf("%d\n", Res[x]);
}
return 0;
}
Compilation message
sightseeing.cpp:43:23: error: 'int link [5000005]' redeclared as different kind of symbol
/usr/include/unistd.h:813:12: error: previous declaration of 'int link(const char*, const char*)'
sightseeing.cpp: In function 'int main()':
sightseeing.cpp:67:9: warning: pointer to a function used in arithmetic [-Wpointer-arith]
sightseeing.cpp:67:20: error: assignment of read-only location '*(link + ((long unsigned int)((long unsigned int)i)))'
sightseeing.cpp:67:20: error: cannot convert 'int' to 'int(const char*, const char*)throw ()' in assignment
sightseeing.cpp:76:42: warning: pointer to a function used in arithmetic [-Wpointer-arith]
sightseeing.cpp:76:42: error: invalid conversion from 'int (*)(const char*, const char*)throw ()' to 'int' [-fpermissive]
sightseeing.cpp:62:6: warning: unused variable 'i' [-Wunused-variable]
sightseeing.cpp:62:9: warning: unused variable 'j' [-Wunused-variable]
sightseeing.cpp:62:12: warning: unused variable 'k' [-Wunused-variable]
sightseeing.cpp:64:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
sightseeing.cpp:66:43: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
sightseeing.cpp:88:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]