#include "friend.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
typedef long long llong;
const int MAXN = 100000 + 10;
const int INF = 1e9;
int n;
int mask[MAXN];
int findSample(int N, int confidence[], int host[], int protocol[])
{
n = N;
for (int i = 0 ; i < n ; ++i)
{
if (protocol[i] == 0)
{
mask[i] = (1 << host[i]);
}
if (protocol[i] == 1)
{
mask[i] = mask[host[i]];
}
if (protocol[i] == 2)
{
mask[i] = mask[host[i]];
mask[i] |= (1 << host[i]);
}
for (int j = 0 ; j < n ; ++j)
{
if (mask[i] & (1 << j))
{
assert(i != j);
mask[j] |= (1 << i);
}
}
}
int ans = 0;
for (int set = 0 ; set < (1 << n) ; ++set)
{
int curr = 0;
bool good = true;
for (int i = 0 ; i < n ; ++i)
{
if (set & (1 << i))
{
curr += confidence[i];
if (mask[i] & set)
{
good = false;
break;
}
}
}
if (good)
{
ans = std::max(ans, curr);
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |