답안 #238367

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
238367 2020-06-10T22:30:34 Z oscarsierra12 친구 (IOI14_friend) C++14
0 / 100
8 ms 5120 KB
#include "friend.h"
#include <bits/stdc++.h>

#define pb    push_back

using namespace std ;

// Find out best sample

const int N = 100010 ;

int confi[N] ;
int dp [N][2];
vector <int> G[N][2] ;

int go ( int u, int flag ) {
    auto &rf = dp[u][flag];
    if ( rf!=-1 ) return rf ;
    if ( flag ) {
        ///take
        int x = confi[u] ;
        for ( auto v:G[u][0] ) x += go( v, 0 ) ;
        for ( auto v:G[u][1] ) x += go( v, 1 ) ;
        rf = x ;
        ///dont take
        x = 0 ;
        for ( auto v:G[u][0] ) x += go(v,1 ) ;
        for ( auto v:G[u][1] ) x += go(v, 1) ;
        rf = max ( rf, x ) ;
    }
    else {
        int x = 0 ;
        for ( auto v:G[u][1] ) x += go ( v, 0 ) ;
        for ( auto v:G[u][0] ) x += go ( v, 1 ) ;
        rf = x ;
    }
    return rf ;
}

int findSample(int n,int confidence[],int host[],int protocol[]){
    for ( int i = 0 ; i < n ; ++i ) confi[i] = confidence[i] ;
    for ( int i = 1 ; i < n ; ++i ) G[host[i]][protocol[i]].push_back ( i ) ;
    return go(0,1) ;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 5120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 5120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -