제출 #937117

#제출 시각아이디문제언어결과실행 시간메모리
937117amirhoseinfar1385Harbingers (CEOI09_harbingers)C++17
0 / 100
4 ms6748 KiB
#include<bits/stdc++.h> using namespace std; const long long maxn=100000+10; long long inf=1e18; struct func{ long long fas,shib; long long inersect(func f){ long long sor=fas-f.fas,makh=f.shib-shib; if(makh==0){ if(sor>0){ return -inf; } return inf; } if(makh<0){ makh*=-1; sor*=-1; } if(sor<0){ return sor/makh; } return (sor+makh-1)/makh; } }; struct yal{ long long u,v,w; long long getad(long long fu){ return (u^v^fu); } }alle[maxn]; long long n,timea=0,high[maxn],para[maxn],dp[maxn]; pair<long long,long long>stf[maxn],all[maxn]; vector<long long>adj[maxn]; void dfs(long long u,long long par=0,long long len=0){ timea++; para[u]=par; high[u]=len; stf[u].first=timea; for(auto x:adj[u]){ long long v=alle[x].getad(u); if(v!=par){ dfs(v,u,len+alle[x].w); } } stf[u].second=timea; } void vorod(){ cin>>n; for(long long i=0;i<n-1;i++){ cin>>alle[i].u>>alle[i].v>>alle[i].w; adj[alle[i].u].push_back(i); adj[alle[i].v].push_back(i); } for(long long i=2;i<=n;i++){ cin>>all[i].first>>all[i].second; } } void pre(){ dfs(1); } void upd(long long u){ dp[u]=high[u]*all[u].second; long long fu=para[u]; while(fu!=0){ dp[u]=min(dp[u],dp[fu]+all[u].second*high[u]-all[u].second*high[fu]); fu=para[fu]; } dp[u]+=all[u].first; } void solve(long long u=1){ upd(u); for(auto x:adj[u]){ long long v=alle[x].getad(u); if(v!=para[u]){ solve(v); } } } void khor(){ for(long long i=2;i<=n;i++){ cout<<dp[i]<<" "; } cout<<"\n"; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); freopen("inp.txt","r",stdin); vorod(); pre(); solve(); khor(); }

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

harbingers.cpp: In function 'int main()':
harbingers.cpp:96:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   96 |  freopen("inp.txt","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...