Submission #719105

#TimeUsernameProblemLanguageResultExecution timeMemory
719105mseebacherFriend (IOI14_friend)C++17
0 / 100
1 ms348 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; #define MAX_N (int) 1e3+10 vector<int> friends[MAX_N]; vector<bool> vis(MAX_N,0); queue<pair<int,bool>> q; long long black = 0; long long red = 0; int *dummy; void bfs(int x){ q.push({x,0}); while(!q.empty()){ int u = q.front().first; bool b = q.front().second; q.pop(); if(vis[u]) continue; if(b) black += dummy[u]; else red += dummy[u]; vis[u] = 1; for(auto s: friends[u]){ if(!vis[s]){ q.push({s,!b}); } } } } // Find out best sample int findSample(int n,int confidence[],int host[],int protocol[]){ dummy = confidence; long long ans = 0; for(int i = 1;i<n;i++){ friends[i].push_back(host[i]); friends[host[i]].push_back(i); } bfs(0); return max(red,black); }

Compilation message (stderr)

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:36:12: warning: unused variable 'ans' [-Wunused-variable]
   36 |  long long ans = 0;
      |            ^~~
#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...