제출 #582401

#제출 시각아이디문제언어결과실행 시간메모리
582401wdjpng친구 (IOI14_friend)C++17
19 / 100
4 ms2820 KiB
#include "friend.h" #include <bits/stdc++.h> #define int long long #define rep(i,n) for(int i = 0; i < n; i++) #define all(a) a.begin(), a.end() using namespace std; int N =1e5+1; vector<vector<int>>mem(2,vector<int>(N,-1)); vector<vector<int>>E; vector<int>conf(N); int dfs(int v, int p, int allow) { if(mem[allow][v]!=-1) return mem[allow][v]; int s = 0; for (int w : E[v]) if(w!=p) s+=dfs(w,v,true); int s2=conf[v]; for (int w : E[v]) if(w!=p) s2+=dfs(w,v,false); if(allow) return mem[allow][v]=max(s2,s); return mem[allow][v]=s; } // Find out best sample signed findSample(signed n,signed oorgconf[],signed host[],signed protocol[]){ vector<int>without(n,0); E.assign(n, vector<int>()); rep(i,n) conf[i]=oorgconf[i]; int best = conf[0]; for(int st = 1; st < n; st++) { if(protocol[st]==0) { // I am friend E[host[st]].push_back(st); } } return dfs(0,-1,true); }

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

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:34:6: warning: unused variable 'best' [-Wunused-variable]
   34 |  int best = conf[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...