제출 #405101

#제출 시각아이디문제언어결과실행 시간메모리
405101PyqeArboras (RMI20_arboras)C++11
11 / 100
5065 ms8672 KiB
#include <bits/stdc++.h> using namespace std; const long long dv=1e9+7; long long n,a[100069],dh[100069],fh[100069],z; vector<long long> al[100069]; void bd(long long x) { long long i,sz=al[x].size(),l,mx[2]={dh[x],dh[x]}; fh[x]=dh[x]; for(i=0;i<sz;i++) { l=al[x][i]; dh[l]=dh[x]+a[l]; bd(l); fh[x]=max(fh[x],fh[l]); mx[1]=max(mx[1],min(mx[0],fh[l])); mx[0]=max(mx[0],fh[l]); } z=(z+mx[0]+mx[1]-dh[x]*2)%dv; } int main() { long long t,rr,i,k,l; scanf("%lld",&n); for(i=2;i<=n;i++) { scanf("%lld",&k); k++; al[k].push_back(i); } for(i=2;i<=n;i++) { scanf("%lld",a+i); } scanf("%lld",&t); for(rr=0;rr<=t;rr++) { if(rr) { scanf("%lld%lld",&k,&l); k++; a[k]+=l; } z=0; bd(1); printf("%lld\n",z); } }

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

arboras.cpp: In function 'int main()':
arboras.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |  scanf("%lld",&n);
      |  ~~~~~^~~~~~~~~~~
arboras.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   scanf("%lld",&k);
      |   ~~~~~^~~~~~~~~~~
arboras.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |   scanf("%lld",a+i);
      |   ~~~~~^~~~~~~~~~~~
arboras.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |  scanf("%lld",&t);
      |  ~~~~~^~~~~~~~~~~
arboras.cpp:46:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |    scanf("%lld%lld",&k,&l);
      |    ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...