# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
240936 | DavidDamian | Deblo (COCI18_deblo) | C++11 | 1096 ms | 14712 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
///Subtask 2
///DFS from all nodes
int n;
ll A[100005];
ll total=0;
vector<int> adjList[100005];
ll dfs(int u,int e,ll Xor)
{
ll sum=Xor;
for(int v: adjList[u]){
if(v==e) continue;
sum+=dfs(v,u,Xor^A[v]);
}
return sum;
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
cin>>A[i];
total+=A[i];
}
for(int i=1;i<=n-1;i++){
int a,b;
cin>>a>>b;
adjList[a].push_back(b);
adjList[b].push_back(a);
}
for(int i=1;i<=n;i++){
total+=dfs(i,0,A[i]);
}
total/=2;
cout<<total<<'\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |