Submission #1157641

#TimeUsernameProblemLanguageResultExecution timeMemory
1157641zhasynFactories (JOI14_factories)C++20
Compilation error
0 ms0 KiB
//#include "factories.h" #include <bits/stdc++.h> #define pb push_back #define pf push_front using namespace std; #define F first #define S second typedef long long ll; #define pii pair <int, int> #define pll pair <ll, ll> typedef long double ld; const ll N = 5 * 1e5 + 100, M = 4096 + 10, len = 21, inf = 1e18; const ll mod = 1e9 + 7; ll um(ll a, ll b){ return (1LL * a * b) % mod; } ll subr(ll a, ll b){ return ((1LL * a - b) % mod + mod) % mod; } int n; ll dis[N]; vector <pll> q[N]; void Init(int nx, int a[], int b[], int d[]) { n = nx; for(int i = 0; i < n - 1; i++){ q[a[i]].pb(make_pair(b[i], d[i])); q[b[i]].pb(make_pair(a[i], d[i])); } } long long Query(int s, int x[], int t, int y[]) { for(int i = 0; i < n; i++){ dis[i] = INT_MAX; } set <pll> st; for(int i = 0; i < s; i++){ dis[x[i]] = 0; st.insert(make_pair(0, x[i])); } while((ll)st.size() != 0){ ll v = st.begin()->S; st.erase(st.begin()); for(int i = 0; i < (int)q[v].size(); i++){ pll u = q[v][i]; if(dis[u.F] > dis[v] + u.S){ st.erase(make_pair(dis[u.F], u.F)); dis[u.F] = dis[v] + u.S; st.insert(make_pair(dis[u.F], u.F)); } } } ll ans = LLONG_MAX; for(int i = 0; i < t; i++){ ans = min(ans, dis[y[i]]); } return ans; } int main(){ int m; cin >> n >> m; int a[n], b[n], d[n]; for(int i = 0; i < n - 1; i++){ cin >> a[i] >> b[i] >> d[i]; } Init(n, a, b, d); for(int i = 0, s, t; i < m; i++){ cin >> s >> t; int x[s], y[t]; for(int j = 0; j < s; j++){ cin >> x[j]; } for(int j = 0; j < t; j++){ cin >> y[j]; } cout << Query(s, x, t, y) << endl; } return 0; } /* 7 1 0 1 4 1 2 4 2 3 5 2 4 6 4 5 5 1 6 3 2 2 0 6 3 4 */

Compilation message (stderr)

/usr/bin/ld: /tmp/ccbLn2m4.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccJxvAyG.o:factories.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status