제출 #1015449

#제출 시각아이디문제언어결과실행 시간메모리
1015449parsadox2친구 (IOI14_friend)C++17
0 / 100
1 ms4700 KiB
#include "friend.h" #include <bits/stdc++.h> #define F first #define S second using namespace std; const int N = 1e5 + 10; int n , ar[N] , col[N] , cnt , sum; bool marked[N]; vector <pair<int , int>> adj[N]; void Dfs(int v) { cnt++; sum += col[v]; marked[v] = true; for(auto u : adj[v]) { col[u.F] = (col[v] ^ u.S); Dfs(u.F); } } int findSample(int nn,int confidence[],int host[],int protocol[]){ n = nn; for(int i = 0 ; i < n ; i++) ar[i] = confidence[i]; for(int i = 1 ; i < n ; i++) { if(protocol[i] == 0) { adj[host[i]].push_back({i , 1}); marked[i] = true; marked[host[i]] = true; } else if(marked[host[i]]) { adj[host[i]].push_back({i , 0}); marked[i] = true; } } for(int i = 0 ; i < n ; i++) marked[i] = false; int ans = 0; for(int i = 0 ; i < n ; i++) if(!marked[i]) { cnt = sum = 0; Dfs(i); ans += max(sum , cnt - sum); } 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...