제출 #131412

#제출 시각아이디문제언어결과실행 시간메모리
131412Mahdi_Jfri친구 (IOI14_friend)C++14
0 / 100
3 ms380 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) { dp[v][1] = a[v]; for(auto u : adj[v]) { plant(u); dp[v][0] += dp[u][1]; dp[v][1] += dp[u][0]; } 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; if(pt[i] == 0) adj[host[i]].pb(i); else adj2[host[i]].pb(i); is[i] = (pt[i] == 2); } pt[0] = 1; for(int i = 0; i < n; i++) if(!i || pt[i]) plant(i); return dp[0][1]; }

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

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:31: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...