제출 #1071866

#제출 시각아이디문제언어결과실행 시간메모리
1071866cpdreamer친구 (IOI14_friend)C++14
19 / 100
1 ms604 KiB
#include "friend.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <utility> #define V vector #define F first #define S second #define P pair #define pb push_back #define all(v) v.begin(),v.end() typedef long long ll; using namespace __gnu_pbds; using namespace std; V<int>adj[(int)2000]; ll dp[1001][2]; int conf[1001]; void dfs(int n,int p){ if(adj[n].size()==1 && n!=0){ dp[n][0]=0; dp[n][1]=conf[n]; return; } for(auto u:adj[n]){ if(u==p)continue; dfs(u,n); } dp[n][0]=0; dp[n][1]=conf[n]; for(auto u:adj[n]){ dp[n][1]+=dp[u][0]; dp[n][0]+=max(dp[u][0],dp[u][1]); } } int findSample(int n,int confidence[],int host[],int protocol[]){ for(int i=1;i<n;i++) { if (protocol[i] == 0) { adj[host[i]].pb(i); adj[i].pb(host[i]); } } for(int i=0;i<n;i++) conf[i]=confidence[i]; dfs(0,-1); return (int)max(dp[0][1],dp[0][0]); }
#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...