제출 #615021

#제출 시각아이디문제언어결과실행 시간메모리
615021cheissmart친구 (IOI14_friend)C++14
19 / 100
2 ms468 KiB
#include "friend.h" #include <bits/stdc++.h> #define F first #define S second #define V vector #define PB push_back #define EB emplace_back #define MP make_pair #define SZ(v) int((v).size()) #define ALL(v) (v).begin(), (v).end() using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; const int INF = 1e9 + 7, N = 1003; vi G[N]; int dp[N][2]; int findSample(int n, int a[], int host[], int op[]) { for(int i = 1; i < n; i++) { if(op[i]) return 0; // not tree if(op[i] == 0) { G[host[i]].PB(i); G[i].PB(host[i]); } else if(op[i] == 1) { for(int j:G[host[i]]) { G[j].PB(i); G[i].PB(j); } } else { for(int j:G[host[i]]) { G[j].PB(i); G[i].PB(j); } G[host[i]].PB(i); G[i].PB(host[i]); } } function<void(int)> dfs = [&] (int u) { dp[u][1] += a[u]; for(int v:G[u]) if(v > u) { dfs(v); dp[u][1] += dp[v][0]; dp[u][0] += max(dp[v][0], dp[v][1]); } }; dfs(0); return max(dp[0][0], dp[0][1]); }
#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...