Submission #197884

#TimeUsernameProblemLanguageResultExecution timeMemory
197884MasterdanFriend (IOI14_friend)C++14
16 / 100
13 ms888 KiB
#include "friend.h" #include <bits/stdc++.h> // Find out best sample #define all(a) a.begin (),a.end () #define MIN -1 #define MAX 1e9+7 #define F first #define S second #define mk make_pair() #define pb push_back #define mem(a, c) memset(a, 0, sizeof( a)) using namespace std; typedef vector <int> vi; typedef pair<int, int> ii; #include <cstdio> #include <cassert> #define __MAXSIZE__ 100002 using namespace std; /* // Confidence int confidence[__MAXSIZE__]; // Host int host[__MAXSIZE__]; // Protocol int protocol[__MAXSIZE__];*/ int aux[101000]; int vis[101000]; vector <vector <int> >G; int dfs(int x, int maxi){ vis[x]=1; maxi=max(maxi, aux[x]); for(int i=0;i<G[x].size ();i++){ int u=G[x][i]; if(vis[u]==0)maxi=max(maxi, dfs(u,maxi)); }return maxi; } int findSample(int n,int confi[],int host[],int prot[]){ for(int i=0;i<n;i++)aux[i]=confi[i]; G=vector <vector<int> > (n+2); int sw=0; int s=0; for(int i=0;i<n;i++){ s+=confi[i]; } for(int i=1;i<n;i++){ if(prot[i]!=1)sw=1; } if(!sw){ return s; } else{ for(int i=1;i<n;i++){ G[host[i]].pb(i); } mem(vis, 0); int s=0; for(int i=0;i<n;i++){ if(vis[i]==0)s+=dfs(i, -1); } return s; } } /* // Main int main(void) { int n,i; // Number of people assert(scanf("%d",&n)==1); // Confidence for(i=0;i<n;i++) assert(scanf("%d",&confidence[i])==1); // Host and Protocol for(i=1;i<n;i++) assert(scanf("%d %d",&host[i],&protocol[i])==2); // Answer printf("%d\n",findSample(n,confidence,host,protocol)); return 0; } */

Compilation message (stderr)

friend.cpp: In function 'int dfs(int, int)':
friend.cpp:35:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<G[x].size ();i++){
                 ~^~~~~~~~~~~~~
#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...