제출 #586314

#제출 시각아이디문제언어결과실행 시간메모리
586314SeDunion친구 (IOI14_friend)C++17
8 / 100
1 ms340 KiB
#include "friend.h" #include<iostream> using namespace std; const int N = 1e6 + 123; int dsu[N]; int val[N]; int get(int x) { if (x == dsu[x]) return x; return dsu[x] = get(dsu[x]); } int findSample(int n,int confidence[],int host[],int protocol[]){ for (int i = 0 ; i < n ; ++ i) { dsu[i] = i; val[i] = confidence[i]; } for (int i = 1 ; i < n ; ++ i) { int j = host[i]; int x = get(i), y = get(j); if (x == y) continue; dsu[x] = y; val[y] = max(val[y], val[x]); } int ans = 0; for (int i = 0 ; i < n ; ++ i) { int j = get(i); ans += val[j]; val[j] = 0; } 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...