제출 #432998

#제출 시각아이디문제언어결과실행 시간메모리
432998REALITYNB친구 (IOI14_friend)C++17
19 / 100
2 ms460 KiB
#include <bits/stdc++.h> #define pii pair<int,int> #define F first #define S second #define mp make_pair #include "friend.h" using namespace std; const int N = 3e5+1 ; int findSample(int n , int* v, int* p , int* protocol ){ vector<int> adj[n] ; vector<vector<int>> mem(n,vector<int>(2,-1)); for(int i=1;i<n;i++) adj[p[i]].push_back(i) ; function<int(int,int,int)> dfs = [&](int a , int s,int p){ if(mem[a][s]!=-1) return mem[a][s] ; int sum=(s?v[a]:0); for(int x: adj[a]){ if(x==p) continue ; sum+=max(dfs(x,0,a),dfs(x,s^1,a)) ; } mem[a][s]=sum ; return sum ; }; return max(dfs(0,0,0),dfs(0,1,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...