제출 #321197

#제출 시각아이디문제언어결과실행 시간메모리
321197urd05친구 (IOI14_friend)C++14
100 / 100
56 ms8928 KiB
#include <bits/stdc++.h> using namespace std; int n; int co[100000]; int ho[100000]; int pro[100000]; typedef pair<int,int> P; vector<P> son[100000]; int dp[100000][2]; int temp[100000]; int ans(int v,int type) { if (dp[v][type]!=-1) { return dp[v][type]; } if (type==0) { int ret=0; int sum=0; for(int i=0;i<son[v].size();i++) { if (son[v][i].second==0) sum+=ans(son[v][i].first,1); else sum+=ans(son[v][i].first,0); } ret=sum; dp[v][type]=ret; return ret; } int ret=0; int sum=0; for(int i=0;i<son[v].size();i++) { if (son[v][i].second==0) sum+=ans(son[v][i].first,1); else sum+=ans(son[v][i].first,0); } ret=sum; for(int i=0;i<son[v].size();i++) { int nt=son[v][i].first; if (son[v][i].second==2) { ret=max(ret,sum+ans(nt,1)-ans(nt,0)); } if (son[v][i].second==0) { sum-=ans(nt,1)-ans(nt,0); } if (son[v][i].second==1) { sum+=ans(nt,1)-ans(nt,0); } ret=max(ret,sum); } ret=max(ret,sum+co[v]); dp[v][type]=ret; return ret; } int findSample(int nn,int conf[],int hos[],int prot[]) { memset(dp,-1,sizeof(dp)); n=nn; for(int i=0;i<n;i++) { co[i]=conf[i]; ho[i]=hos[i]; pro[i]=prot[i]; } for(int i=1;i<n;i++) { son[ho[i]].push_back(P(i,pro[i])); } return ans(0,1); }

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

friend.cpp: In function 'int ans(int, int)':
friend.cpp:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         for(int i=0;i<son[v].size();i++) {
      |                     ~^~~~~~~~~~~~~~
friend.cpp:32:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int i=0;i<son[v].size();i++) {
      |                 ~^~~~~~~~~~~~~~
friend.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int i=0;i<son[v].size();i++) {
      |                 ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...