Submission #256525

# Submission time Handle Problem Language Result Execution time Memory
256525 2020-08-02T19:29:51 Z PedroBigMan Friend (IOI14_friend) C++14
19 / 100
39 ms 3932 KB
#include "friend.h"
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <cstring>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro Is The Master "<<i<<endl
#define INF 500000000LL
#define EPS 0.00000001
#define pi 3.14159
ll mod=99824LL;

template<class A=ll> 
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}

ll f(ll bin,vector<vector<ll> > adj, ll N,vector<ll> c)
{
    vector<bool> in; 
    REP(i,0,N) {in.pb((bin&(1LL<<i))>0);}
    REP(i,0,N)
    {
        REP(j,i+1,N)
        {
            if(in[i]&&in[j]&&(find(whole(adj[i]),j)!=adj[i].end())) {return 0;}
        }
    }
    ll ans=0LL; REP(i,0,N) {if(in[i]) {ans+=c[i];}}
    return ans;
}

// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[])
{
    ll N = (ll) n; vector<ll> c,h,p; REP(i,0,N) {c.pb((ll) confidence[i]); h.pb((ll) host[i]); p.pb((ll) protocol[i]);}
    if(N<=10LL)
    {
        vector<ll> xx; vector<vector<ll> > adj; REP(i,0,N) {adj.pb(xx);}
        REP(i,1,N)
        {
            if(p[i]==0) {adj[i].pb(h[i]); adj[h[i]].pb(i);}
            else if(p[i]==1) 
            {
                REP(j,0,adj[h[i]].size()) {ll nei = adj[h[i]][j]; adj[i].pb(nei); adj[nei].pb(i);}
            }
            else
            {
                REP(j,0,adj[h[i]].size()) {ll nei = adj[h[i]][j]; adj[i].pb(nei); adj[nei].pb(i);}
                adj[i].pb(h[i]); adj[h[i]].pb(i);
            }
        }
        ll ans=0LL;
        REP(i,0,(1LL<<N)) {ans=max(ans,f(i,adj,N,c));}  
        return ans;
    }
    /*else if(p[1]==1)
    {
        ll sum=0LL; REP(i,0,N) {sum+=c[i];}
        return sum;
    } */
    else 
    {
        return (*max_element(whole(c))); 
    }
    return 0LL;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Incorrect 1 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Incorrect 1 ms 384 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Incorrect 39 ms 3932 KB Output isn't correct
13 Halted 0 ms 0 KB -