제출 #1017276

#제출 시각아이디문제언어결과실행 시간메모리
1017276serkanrashid친구 (IOI14_friend)C++14
0 / 100
1028 ms3952 KiB
#include "friend.h"
#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

const int maxn = 1024;

vector<int>g[maxn];

int findSample(int n, int confidence[], int host[], int protocol[])
{
    for(int i = 1; i < n; i++)
    {
        if(protocol[i]==0)
        {
            g[host[i]].push_back(i);
            g[i].push_back(host[i]);
        }
        if(protocol[i]==1)
        {
            for(int nb : g[host[i]])
            {
                g[nb].push_back(i);
                g[i].push_back(nb);
            }
        }
        if(protocol[i]==2)
        {
            g[host[i]].push_back(i);
            g[i].push_back(host[i]);
            for(int nb : g[host[i]])
            {
                g[nb].push_back(i);
                g[i].push_back(nb);
            }
        }
    }

    int ans = 0;

    for(int mask = 1; mask < (1<<n); mask++)
    {
        int ch = 0;
        for(int j = 0; j < n; j++) if(mask&(1<<j)) ch += confidence[j];
        bool f = true;
        for(int j = 0; j < n; j++)
        {
            if(!(mask&(1<<j))) continue;
            for(int nb : g[j]) if(mask&(1<<nb)) f = false;
        }
        if(f) ans = max(ans,ch);
    }
    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...