Submission #421012

#TimeUsernameProblemLanguageResultExecution timeMemory
421012faresbasbsFriend (IOI14_friend)C++14
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> #include "friend.h" using namespace std; vector<int> graph[1001]; int val[1001]; bool seen[1001]; int dfs(int curr , int tag){ val[curr] = tag; int ret = 0; if(tag == 1){ ret = 1; } for(auto i : graph[curr]){ if(val[i]){ assert(val[i] != val[curr]); continue; } ret += dfs(i,1-tag); } return ret; } int findSample(int n , int confidence[] , int host[] , int protocol[]){ for(int i = 1 ; i < n ; i += 1){ if(protocol[i] == 1){ graph[host[i]].push_back(i); graph[i].push_back(host[i]); }else{ for(auto j : graph[host[i]]){ graph[i].push_back(j); graph[j].push_back(i); } } } int num = dfs(1,1); return max(num,n-num); }
#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...