제출 #208292

#제출 시각아이디문제언어결과실행 시간메모리
208292Sorting친구 (IOI14_friend)C++14
컴파일 에러
0 ms0 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; const int kN = 1007; vector<int> adj[kN]; pair<int, bool> dp[kN][2]; void solve(int u, bool can, int parent, int confidence[]){ if(dp[u][can].second) return dp[u][can].first; dp[u][can].second = true; int &ans = dp[u][can].first; ans = 0; if(can){ curr_ans = confidence[u]; for(int to: adj[u]){ if(to == parent) continue; curr_ans += solve(to, false, u, confidence); } ans = max(ans, curr_ans); } curr_ans = 0; for(int to: adj[u]){ if(to == par) continue; curr_ans += solve(to, true, u, confidence); } ans = max(ans, curr_ans); return ans; } int findSample(int n, int confidence[], int host[], int protocol[]){ for(int i = 1; i < n; ++i){ adj[host[i]].push_back(i); adj[i].push_back(i); } return solve(0, true, -1, confidence); }

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

friend.cpp: In function 'void solve(int, bool, int, int*)':
friend.cpp:13:21: error: return-statement with a value, in function returning 'void' [-fpermissive]
   return dp[u][can].first;
                     ^~~~~
friend.cpp:20:3: error: 'curr_ans' was not declared in this scope
   curr_ans = confidence[u];
   ^~~~~~~~
friend.cpp:20:3: note: suggested alternative: 'wctrans'
   curr_ans = confidence[u];
   ^~~~~~~~
   wctrans
friend.cpp:30:2: error: 'curr_ans' was not declared in this scope
  curr_ans = 0;
  ^~~~~~~~
friend.cpp:30:2: note: suggested alternative: 'wctrans'
  curr_ans = 0;
  ^~~~~~~~
  wctrans
friend.cpp:32:12: error: 'par' was not declared in this scope
   if(to == par)
            ^~~
friend.cpp:39:9: error: return-statement with a value, in function returning 'void' [-fpermissive]
  return ans;
         ^~~
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:48:38: error: void value not ignored as it ought to be
  return solve(0, true, -1, confidence);
                                      ^