제출 #491977

#제출 시각아이디문제언어결과실행 시간메모리
491977davi_bart친구 (IOI14_friend)C++14
16 / 100
3 ms2692 KiB
#include "friend.h" #pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long // #define int ll #define fi first #define se second #define ld long double #define pb push_back mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // Find out best sample vector<int> v[100010]; vector<bool> vis(100010, 0); int x[2]; void dfs(int pos, bool k) { if (vis[pos]) return; vis[pos] = 1; x[k]++; for (auto i : v[pos]) { dfs(i, !k); } } int findSample(int N, int confidence[], int host[], int protocol[]) { int a[3] = {0, 0, 0}; for (int i = 1; i < N; i++) { a[protocol[i]]++; } if (a[1] == N - 1) { int tot = 0; for (int i = 0; i < N; i++) tot += confidence[i]; return tot; } if (a[2] == N - 1) { int tot = 0; for (int i = 0; i < N; i++) tot = max(confidence[i], tot); return tot; } for (int i = 1; i < N; i++) { if (protocol[i] == 0 || protocol[i] == 2) { v[host[i]].pb(i); v[i].pb(host[i]); } if (protocol[i] == 1 || protocol[i] == 2) { for (int x : v[host[i]]) { v[x].pb(i); v[i].pb(x); } } } int ans = 0; for (int i = 0; i < N; i++) { if (!vis[i]) { x[0] = x[1] = 0; dfs(i, 0); ans += max(x[0], x[1]); } } return ans; }
#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...