답안 #748247

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
748247 2023-05-25T22:35:18 Z kkkkkkkk 친구 (IOI14_friend) C++14
19 / 100
1 ms 340 KB
#include <bits/stdc++.h>
 
using namespace std;
 
int *C;
int dp[1005][2];
vector<int> G[1005];
 
void f(int teme) {
    if (G[teme].size()==0) {
        dp[teme][0]=C[teme];
        dp[teme][1]=0;
    }
    dp[teme][0]=C[teme];
    for (int i=0;i<G[teme].size();i++){
        int child=G[teme][i];
        f(child);
        dp[teme][0]+=dp[child][1];
        dp[teme][1]+=max(dp[child][0],dp[child][1]);
    }
}
 
int findSample(int n,int confidence[],int host[],int protocol[]) {
    C=confidence;
    for (int i=1;i<n;i++)
        G[host[i]].push_back(i);
    f(0);
    return max(dp[0][0],dp[0][1]);
}

Compilation message

friend.cpp: In function 'void f(int)':
friend.cpp:15:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for (int i=0;i<G[teme].size();i++){
      |                  ~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Incorrect 1 ms 340 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 0 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -