# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
874095 | YongXin | Friend (IOI14_friend) | C++14 | 1098 ms | 29116 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int N,Confidence[100000];
vector<int>adj[100000];
int dp(bool cant[],int i){
if(i==N)return 0;
if(cant[i])return dp(cant,i+1);
bool choose[N];
for(int j=0;j<N;++j)choose[j]=cant[j];
for(int j=0;j<adj[i].size();++j)choose[adj[i][j]]=true;
return max(dp(choose,i+1)+Confidence[i],dp(cant,i+1));
}
int findSample(int n,int confidence[],int host[],int protocol[]){
ios_base::sync_with_stdio(false);cin.tie(NULL);
N=n+1;
for(int i=0;i<N;++i)Confidence[i]=confidence[i];
for(int i=1;i<N;++i){
if(protocol[i]!=1){
adj[i].push_back(host[i]);
adj[host[i]].push_back(i);
}
if(protocol[i]!=0)for(int j=0;j<adj[host[i]].size();++j){
adj[i].push_back(adj[host[i]][j]);
adj[adj[host[i]][j]].push_back(i);
}
}
bool cant[N];
memset(cant,0,N);
return dp(cant,0);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |