Submission #242397

#TimeUsernameProblemLanguageResultExecution timeMemory
242397joseacazFriend (IOI14_friend)C++17
11 / 100
717 ms1996 KiB
#include "friend.h"
#include <bits/stdc++.h>

#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define dbg(x) cerr << "[LINE: " << __LINE__ << "] = " << x << "\n"

const int MAXN = 1005;
int prot[3], on[MAXN];
ll aux, ans;
vi Graph[MAXN];

// Find out best sample
int findSample(int N, int confidence[], int host[], int protocol[])
{
    if(N > 1000)
        return 0;

    for(int i = 1; i < N; i++)
    {
        prot[protocol[i]]++;
        if(protocol[i] == 0)
        {
            Graph[host[i]].pb(i);
            Graph[i].pb(host[i]);
        }
        else if(protocol[i] == 1)
        {
            for(auto v : Graph[host[i]])
            {
                Graph[v].pb(i);
                Graph[i].pb(v);
            }
        }
        else if(protocol[i] == 2)
        {
            for(auto v : Graph[host[i]])
            {
                Graph[v].pb(i);
                Graph[i].pb(v);
            }
            Graph[host[i]].pb(i);
            Graph[i].pb(host[i]);
        }
    }
    for(int i = 0; i < N; i++)  
    {
        cerr << i << ": ";
        for(auto j : Graph[i])
            cerr << j << " ";
        cerr << "\n";
    }
    
    //S1
    if(N <= 10)
    {
        for(int i = 0; i < (1 << N); i++)
        {
            aux = 0;
            for(int j = 0; j < N; j++)
            {
                on[j] = 0;
                if(i & (1 << j))
                {
                    on[j] = 1;
                    cerr << j << " ";
                    aux += confidence[j];
                }
            }
            cerr << "\n";
            
            bool ind = 1;
            for(int node = 0; node < N; node++)
                if(on[node])
                    for(auto j : Graph[node])
                        if(on[j])
                            ind = 0;
            if(!ind)
                continue;
            dbg(aux);
            ans = max(ans, aux);
        }
    }
    //S2
    else if(prot[1] == N)
    {
        for(int i = 0; i < N; i++)
            ans += confidence[i];
    }
    //S3
    else if(prot[2] == N)
    {
        for(int i = 0; i < N; i++)
            ans = max(ans, (ll)confidence[i]);
    }
    //S4
    else if(prot[0] == N)
    {
        
    }
    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...