#include "closing.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#define pb push_back
#define F first
#define pii pair<int,int>
#define all(a) a.begin(),a.end()
#define S second
#define sz(a) (int)a.size()
#define rep(i , a , b) for(int i = (a) ; i <= (b) ; i++)
#define per(i , a , b) for(int i = (a) ; i >= (b) ; i--)
#define ld double
#define ll long long
using namespace std ;
const ll maxn = 1e6 + 10 ,s = 1000 , inf = 1e18 + 10 , mod = 998244353;
int par[maxn] , r[maxn] , ma[maxn] , mark[maxn] , mb[maxn] ; ll dp[maxn][2*maxn] ;
ll dis[maxn] , a[maxn] , b[maxn] ;
vector <pii> G[maxn] ;
void dfs(int v){
for(auto[u,w] : G[v]){
if(u == par[v])continue ;
par[u] = v;
dfs(u) ;;
}
}
void dist(int v, int p = -1){
for(auto [u,w] : G[v]){
if(u == p)continue ;
dis[u ]= dis[v] + w ;
dist(u , v);
}
}
void dfs2(int v, int p =-1 ){
mark[v] =1 ;
for(auto[u,w] : G[v]){
if(mark[u] == 1)continue ;
r[u] = r[v];
dfs2(u ,v );
}
}
int max_score(int n, int x, int y, long long K,std::vector<int> U, std::vector<int> V, std::vector<int> W){
rep(i , 0 ,n)G[i].clear() ;
rep(i , 0 , n-2){
G[V[i]].pb({U[i],W[i]});
G[U[i]].pb({V[i] , W[i]}) ;
}
dis[x] =0 ;
dist(x);
rep(i ,0, n-1){
a[i] = dis[i] ;
}
dis[y] = 0;
dist(y) ;
vector <ll> vec ;
rep(i ,0 ,n-1){
b[i] = dis[i] ;
vec.pb(min(a[i] , b[i])) ;
}
sort(all(vec));
int ans =0 ;
rep(i , 0, sz(vec)-1){
if(K >= vec[i]){
K-=vec[i] ;
ans ++ ;
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
/tmp/ccvxjhQ7.o: in function `dfs(int)':
closing.cpp:(.text+0x489): relocation truncated to fit: R_X86_64_PC32 against symbol `par' defined in .bss section in /tmp/ccvxjhQ7.o
closing.cpp:(.text+0x742): relocation truncated to fit: R_X86_64_PC32 against symbol `par' defined in .bss section in /tmp/ccvxjhQ7.o
closing.cpp:(.text+0x7e9): relocation truncated to fit: R_X86_64_PC32 against symbol `par' defined in .bss section in /tmp/ccvxjhQ7.o
closing.cpp:(.text+0x851): relocation truncated to fit: R_X86_64_PC32 against symbol `par' defined in .bss section in /tmp/ccvxjhQ7.o
closing.cpp:(.text+0x8b9): relocation truncated to fit: R_X86_64_PC32 against symbol `par' defined in .bss section in /tmp/ccvxjhQ7.o
closing.cpp:(.text+0x921): relocation truncated to fit: R_X86_64_PC32 against symbol `par' defined in .bss section in /tmp/ccvxjhQ7.o
closing.cpp:(.text+0x989): relocation truncated to fit: R_X86_64_PC32 against symbol `par' defined in .bss section in /tmp/ccvxjhQ7.o
closing.cpp:(.text+0x9f1): relocation truncated to fit: R_X86_64_PC32 against symbol `par' defined in .bss section in /tmp/ccvxjhQ7.o
closing.cpp:(.text+0xa67): relocation truncated to fit: R_X86_64_PC32 against symbol `par' defined in .bss section in /tmp/ccvxjhQ7.o
closing.cpp:(.text+0xab9): relocation truncated to fit: R_X86_64_PC32 against symbol `par' defined in .bss section in /tmp/ccvxjhQ7.o
closing.cpp:(.text+0xb0b): additional relocation overflows omitted from the output
/usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(ios_init.o): in function `std::ios_base::Init::Init()':
(.text._ZNSt8ios_base4InitC2Ev+0x1c): failed to convert GOTPCREL relocation against '_ZNSt8ios_base4Init11_S_refcountE'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x1c6): failed to convert GOTPCREL relocation against '_ZSt4cout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x260): failed to convert GOTPCREL relocation against '_ZSt3cin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x2e2): failed to convert GOTPCREL relocation against '_ZSt4cerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x353): failed to convert GOTPCREL relocation against '_ZSt4clog'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x541): failed to convert GOTPCREL relocation against '_ZSt5wcout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x5e5): failed to convert GOTPCREL relocation against '_ZSt4wcin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x670): failed to convert GOTPCREL relocation against '_ZSt5wcerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x6e9): failed to convert GOTPCREL relocation against '_ZSt5wclog'; relink with --no-relax
/usr/bin/ld: final link failed
collect2: error: ld returned 1 exit status