제출 #1017251

#제출 시각아이디문제언어결과실행 시간메모리
1017251n3rm1n친구 (IOI14_friend)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h>
#define endl '\n'
#include "friend.h"
using namespace std;
vector < int > g[1005];
int cnt[4];
int ans = 0, dp[1005], sum[1005];
void dfs(int beg)
{
   // cout << beg << " " << sum[beg] << endl;
    dp[beg] = sum[beg];
    int other = 0;
    int nb;
    for (int j = 0; j < g[beg].size(); ++ j)
    {
        nb = g[beg][j];
        dfs(nb);
        other += dp[nb];
    }
    dp[beg] = max(dp[beg], other);
    ans = max(dp[beg], ans);
   // cout << "* " << beg << " " << dp[beg] << endl;
}
int findSample(int n, int confidence[], int host[], int protocol[])
{
    for (int i = 1; i < n; ++ i)
        g[host[i]].push_back(i);
    for (int i = 1; i < n; ++ i)
    {
        cnt[protocol[i]] ++;
    }
   // cout << cnt[1] << endl;
    if(cnt[1] == n-1)
    {
       /// cout << "here " << endl;
        for (int i = 0; i < n; ++ i)
        {
            sum[i] = confidence[i];
            for (int j = 0; j < g[i].size(); ++ j)
                sum[i] += confidence[g[i][j]];

        }
        dfs(0);
        return ans;
    }
   // cout << "opa" << endl;
}

컴파일 시 표준 에러 (stderr) 메시지

friend.cpp: In function 'void dfs(int)':
friend.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for (int j = 0; j < g[beg].size(); ++ j)
      |                     ~~^~~~~~~~~~~~~~~
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:39:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             for (int j = 0; j < g[i].size(); ++ j)
      |                             ~~^~~~~~~~~~~~~
friend.cpp:47:1: warning: control reaches end of non-void function [-Wreturn-type]
   47 | }
      | ^
#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...