# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
719105 | mseebacher | Friend (IOI14_friend) | C++17 | 1 ms | 348 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 "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)
# | 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... |