Submission #735745

#TimeUsernameProblemLanguageResultExecution timeMemory
735745myrcella친구 (IOI14_friend)C++17
27 / 100
1 ms468 KiB
//by szh #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pii pair<int,int> #define pll pair<long long,long long> #define pb push_back #define debug(x) cerr<<#x<<"="<<x<<endl #define pq priority_queue #define inf 0x3f #define rep(i,a,b) for (int i=a;i<(b);i++) #define MP make_pair #define SZ(x) (int(x.size())) #define ll long long #define mod 1000000007 #define ALL(x) x.begin(),x.end() void inc(int &a,int b) {a=(a+b)%mod;} void dec(int &a,int b) {a=(a-b+mod)%mod;} int lowbit(int x) {return x&(-x);} ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;} #include "friend.h" const int maxn = 1e3+10; vector <int> edge[maxn]; int dp[maxn][2]; int c[maxn]; int f[maxn]; int getf(int x) { if (f[x]==x) return x; else return f[x] = getf(f[x]); } void dfs(int u) { int sum0 = 0, sum1 = 0; for (int v:edge[u]) { dfs(v); sum0 += dp[v][0]; sum1 += max(dp[v][0],dp[v][1]); } dp[u][0] = sum1; dp[u][1] = c[u] + sum0; } // Find out best sample int findSample(int n,int confidence[],int host[],int protocol[]){ rep(i,0,n) c[i] = confidence[i],f[i] = i; rep(i,1,n) { if (protocol[i]==0) edge[host[i]].pb(i); else c[getf(host[i])] += c[i],f[i] = getf(host[i]); } 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...