Submission #874095

#TimeUsernameProblemLanguageResultExecution timeMemory
874095YongXinFriend (IOI14_friend)C++14
11 / 100
1098 ms29116 KiB
#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)

friend.cpp: In function 'int dp(bool*, int)':
friend.cpp:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int j=0;j<adj[i].size();++j)choose[adj[i][j]]=true;
      |                 ~^~~~~~~~~~~~~~
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:22:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         if(protocol[i]!=0)for(int j=0;j<adj[host[i]].size();++j){
      |                                       ~^~~~~~~~~~~~~~~~~~~~
#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...