제출 #958330

#제출 시각아이디문제언어결과실행 시간메모리
958330IsaLBosses (BOI16_bosses)C++17
컴파일 에러
0 ms0 KiB
// #include "traffic.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define pii pair<int, int> #define pll pair<ll, ll> const int NN = 1000069; const ll mod = 1e9 + 7; int tc, ans; ll sub[NN], tot, dp[NN], a[NN]; vector<int> al[NN]; void dfs(int x, int p) { sub[x] = a[x]; for(auto z : al[x]) { if(z == p) continue; dfs(z, x); sub[x] += sub[z]; } } void dfs2(int x, int p) { for(auto z : al[x]) { if(z == p) continue; dfs2(z, x); dp[x] = max(dp[x], sub[z]); } dp[x] = max(dp[x], tot - sub[x]); } int LocateCentre(int N, int P[], int S[], int D[]) { int i, j; ans = 0; for(i = 0; i < N; i++) tot += (ll)P[i], a[i] = (ll)P[i]; for(i = 0; i < N-1; i++) { al[S[i]].push_back(D[i]); al[D[i]].push_back(S[i]); } dfs(0, -1); dfs2(0, 0); for(i = 1; i < N; i++) if(dp[ans] > dp[i]) ans = i; return ans; } // int main() // { // ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); // int i, j; // int n; // cin >> n; // int P[n], S[n], D[n]; // for(i = 0; i < n; i++) cin >> P[i]; // for(i = 0; i < n-1; i++) cin >> S[i] >> D[i]; // cout << LocateCentre(n, P, S, D); // for(i = 0; i < n; i++) // { // cout << i << " : " << sub[i] << " " << dp[i] << '\n'; // } // }

컴파일 시 표준 에러 (stderr) 메시지

bosses.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
bosses.cpp:43:12: warning: unused variable 'j' [-Wunused-variable]
   43 |     int i, j;
      |            ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status