제출 #131422

#제출 시각아이디문제언어결과실행 시간메모리
131422Mahdi_Jfri친구 (IOI14_friend)C++14
27 / 100
3 ms632 KiB
#include "friend.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back const int maxn = 1e3 + 20; vector<int> adj[maxn] , adj2[maxn]; int dp[maxn][2] , a[maxn]; bool is[maxn]; void plant(int v) { vector<int> x , y; dp[v][1] = a[v]; for(auto u : adj[v]) { plant(u); if(is[u]) y.pb(u); else x.pb(u); dp[v][1] += dp[u][is[u]]; } // az x hichi barnemidarim int sum1 = 0; for(auto u : y) sum1 += dp[u][1]; dp[v][0] = max(dp[v][0] , sum1); // w avalin ke barmidarim for(auto w : x) { int sum = 0; for(auto u : x) sum += dp[u][u >= w]; for(auto u : y) sum += dp[u][u < w]; dp[v][0] = max(dp[v][0] , sum); } dp[v][1] = max(dp[v][1] , dp[v][0]); } int findSample(int n,int A[],int host[],int pt[]) { bool has[3] = {0 , 0 , 0}; for(int i = 1; i < n; i++) { has[pt[i]] = 1; adj[host[i]].pb(i); is[i] = (pt[i] == 1); } for(int i = 0; i < n; i++) a[i] = A[i]; plant(0); return dp[0][1]; }

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

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:53:7: warning: variable 'has' set but not used [-Wunused-but-set-variable]
  bool has[3] = {0 , 0 , 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...