답안 #815306

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
815306 2023-08-08T14:05:53 Z Liudas 친구 (IOI14_friend) C++17
8 / 100
3 ms 3284 KB
#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);
}
void dfs(int head, int par, vector<vector<int>> &arr, vector<int> &val){
    int v = 0;
    for(int i : arr[head]){
        if(i != par){
            dfs(i, head, arr, val);
            v += val[i];
        }
    }
    val[head] = max(val[head], v);
}
int findSample(int n,int confidence[],int host[],int protocol[]){
    int N = n;
    vector<vector<int>> arr(N);
    for(int k = 0; k < N-1; k ++){
        int i = k + 1;
        int h = host[k];
        if(protocol[k] == 0){
            arr[i].push_back(h);
            arr[h].push_back(i);
        }
        if(protocol[k] == 1){
            for(int j : arr[h]){
                arr[i].push_back(j);
                arr[j].push_back(i);
            }
        }
        if(protocol[k] == 2){
            arr[i].push_back(h);
            arr[h].push_back(i);
            for(int j : arr[h]){
                arr[i].push_back(j);
                arr[j].push_back(i);
            }
        }
    }
    if(n <= 10){
        int m = 0;
        set<int> brr;
        getmax(0, N, arr, m, brr, 0, confidence);
        return m;
    }
    else{
        if(count(protocol, protocol + n, 1) == n-1){
            return accumulate(confidence, confidence + n, 0ll);
        }
        if(count(protocol, protocol + n, 2) == n-1){
            return *max_element(confidence, confidence + n);
        }
        vector<int> val(N);
        for(int i = 0; i < N; i ++){
            val[i] = confidence[i];
        }
        dfs(0, -1, arr, val);
        return val[0];
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 2 ms 1876 KB Output is correct
5 Correct 3 ms 3028 KB Output is correct
6 Correct 2 ms 852 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 3 ms 3284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -