이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "friend.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> amigos[100005];
bool vis[100005];
bool tomo[100005];
int c[100005];
int tomo_no_tomo(int x, int &n) {
if (x == n)
return 0;
bool puedo_tomar = true;
int r=0;
for(auto a:amigos[x]) {
if (tomo[a]) {
puedo_tomar = false;
break;
}
}
if (puedo_tomar) {
tomo[x] = true;
r = tomo_no_tomo(x+1, n) + c[x];
tomo[x] = false;
}
r = max(r, tomo_no_tomo(x+1, n));
return r;
}
int findSample(int n, int confidence[], int host[], int protocol[]) {
int max_con = confidence[0];
int sub2 = 0;
c[0] = confidence[0];
for(int i=1; i<n; i++){
c[i] = confidence[i];
max_con += confidence[i];
if (protocol[i] == 0) { /// I Am Your Friend
amigos[i].push_back(host[i]);
amigos[host[i]].push_back(i);
} else if (protocol[i] == 1) { /// My Friends are Your Friends
sub2++;
for(auto e:amigos[host[i]]) {
amigos[i].push_back(e);
amigos[e].push_back(i);
}
} else { /// We Are Your Friends
amigos[i].push_back(host[i]);
amigos[host[i]].push_back(i);
for(auto e:amigos[host[i]]) {
amigos[i].push_back(e);
amigos[e].push_back(i);
}
}
}
if (sub2 != n-1) {
max_con = tomo_no_tomo(0, n);
}
return max_con; /// return maximum confidence possible
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |