제출 #62904

#제출 시각아이디문제언어결과실행 시간메모리
62904zadrga친구 (IOI14_friend)C++14
8 / 100
7 ms3080 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define fi first #define se second #define INF ((int) 1e9) #define MOD (1000 * 1000 * 1000 + 7) #define maxn 100111 typedef long long ll; typedef long double ld; typedef pair<int, int> pii; vector<int> adj[maxn]; int col[maxn]; void DFS(int x, int c){ col[x] = c; for(int v : adj[x]){ if(!col[v]) DFS(v, 3 - c); } } int findSample(int n, int confidence[], int host[], int protocol[]){ for(int i = 1; i < n - 1; i++){ int a = host[i]; int b = i; if(protocol[i] == 0){ adj[a].pb(b); adj[b].pb(a); } if(protocol[i] == 1){ for(int v : adj[a]){ adj[v].pb(b); adj[b].pb(v); } } } for(int i = 0; i < n; i++){ if(!col[i]) DFS(i, 1); } int ans[3] = {0, 0, 0}; for(int i = 0; i < n; i++) ans[col[i]] += confidence[i]; return max(ans[1], ans[2]); }
#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...