제출 #815286

#제출 시각아이디문제언어결과실행 시간메모리
815286LiudasFriend (IOI14_friend)C++17
27 / 100
20 ms2660 KiB
#include <bits/stdc++.h>
#include "friend.h"
#define __MAXSIZE__ 100002
using namespace std;
void getmax(int head, int N, vector<vector<int>> &arr, int &m, set<int> been, int score, int conf[]){
    if(head == N){
        m = max(m, score);
        return;
    }
    set<int> nbeen = been;
    for(int i : arr[head]){
        nbeen.insert(i);
    }
    getmax(head + 1, N, arr, m, been, score, conf);
    if(been.find(head) == been.end())
    getmax(head + 1, N, arr, m, nbeen, score + conf[head], conf);
}
int findSample(int n,int confidence[],int host[],int protocol[]){
    if(n <= 10){
        int N = n;
        vector<vector<int>> arr(N);
        for(int i = 0; i < N; i ++){
            arr[i].push_back(i);
        }
        for(int i = 1; i < N; i ++){
            int h = host[i];
            if(protocol[i] == 0){
                arr[i].push_back(h);
                arr[h].push_back(i);
            }
            if(protocol[i] == 1){
                for(int j : arr[h]){
                    if(h == j)continue;
                    arr[i].push_back(j);
                    arr[j].push_back(i);
                }
            }
            if(protocol[i] == 2){
                for(int j : arr[h]){
                    arr[i].push_back(j);
                    arr[j].push_back(i);
                }
            }
        }
        int m = 0;
        set<int> brr;
        getmax(0, N, arr, m, brr, 0, confidence);
        return m;
    }
    else{
        return (count(protocol, protocol + n, 1) == n-1 ? accumulate(confidence, confidence + n, 0ll) : *max_element(confidence, confidence + n));
    }
}
#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...