제출 #242478

#제출 시각아이디문제언어결과실행 시간메모리
242478joseacaz친구 (IOI14_friend)C++17
100 / 100
42 ms5880 KiB
#include "friend.h"
#include <bits/stdc++.h>

#define pb push_back
#define all(x) x.begin(), x.end()

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;

const int MAXN = 1e5 + 5;
int c[MAXN], p[MAXN], q[MAXN];
vi Graph[MAXN];

// Find out best sample
int findSample(int N, int _conf[], int host[], int protocol[])
{
    for(int i = 0; i < N; i++)
    {
        c[i] = _conf[i];
        p[i] = c[i];
        q[i] = 0;
    }

    for(int i = N - 1; i > 0; i--)
    {
        if(protocol[i] == 0)
        {
            p[host[i]] += q[i];
            q[host[i]] += max(p[i], q[i]);
        }
        else if(protocol[i] == 1)
        {
            p[host[i]] = max(p[host[i]] + p[i], max(p[host[i]] + q[i], q[host[i]] + p[i]));
            q[host[i]] += q[i];
        }
        else if(protocol[i] == 2)
        {
            p[host[i]] = max(p[host[i]] + q[i], q[host[i]] + p[i]);
            q[host[i]] += q[i];
        }
    }
    return max(p[0], q[0]);
}
#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...