이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |