제출 #589986

#제출 시각아이디문제언어결과실행 시간메모리
589986Dan4Life친구 (IOI14_friend)C++17
19 / 100
42 ms65536 KiB
#include <bits/stdc++.h> #if !defined(LOL) #include "friend.h" #endif using namespace std; #define pb push_back #define sz(a) (int)a.size() #define all(a) a.begin(),a.end() const int maxn = (int)2e5+10; vector<int> adj[maxn]; int used[maxn]; void add_edge(int a, int b){ adj[a].pb(b); adj[b].pb(a); } void add_friends(int a, int b){ for(auto u : adj[a]) add_edge(u,b); } bool chk(int s){ for(auto u : adj[s]) if(used[u]) return false; return true; } int C[maxn], dp[maxn][3]; void dfs(int s, int p=-1){ dp[s][0]=dp[s][1]=0; dp[s][1]=C[s]; for(auto u : adj[s]){ if(u==p) continue; dfs(u,s); dp[s][1]+=dp[u][0]; dp[s][0]+=max(dp[u][0],dp[u][1]); } } int findSample(int n, int c[], int h[], int pro[]) { int ans = 0; for(int i = 0; i < n; i++) C[i]=c[i]; for(int i = 1; i < n; i++){ if(pro[i]!=1) add_edge(h[i],i); if(pro[i]) add_friends(h[i],i); } dfs(0,-1); return max(dp[0][0], dp[0][1]); } #if defined(LOL) int main(void) { #define __MAXSIZE__ 100002 int confidence[__MAXSIZE__]; int host[__MAXSIZE__]; int protocol[__MAXSIZE__]; int n,i; // Number of people assert(scanf("%d",&n)==1); // Confidence for(i=0;i<n;i++) assert(scanf("%d",&confidence[i])==1); // Host and Protocol for(i=1;i<n;i++) assert(scanf("%d %d",&host[i],&protocol[i])==2); // Answer printf("%d\n",findSample(n,confidence,host,protocol)); return 0; } #endif

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

friend.cpp: In function 'void dfs(int, int)':
friend.cpp:32:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   32 |         if(u==p) continue; dfs(u,s);
      |         ^~
friend.cpp:32:28: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   32 |         if(u==p) continue; dfs(u,s);
      |                            ^~~
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:40:9: warning: unused variable 'ans' [-Wunused-variable]
   40 |     int ans = 0;
      |         ^~~
#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...