Submission #1017333

#TimeUsernameProblemLanguageResultExecution timeMemory
1017333serkanrashidFriend (IOI14_friend)C++14
11 / 100
1073 ms4696 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)
        {
            for(int nb : g[host[i]])
            {
                g[nb].push_back(i);
                g[i].push_back(nb);
            }
            g[host[i]].push_back(i);
            g[i].push_back(host[i]);
        }
    }

    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))==0) 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...