# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
86986 | joseacaz | Deblo (COCI18_deblo) | C++17 | 1085 ms | 15692 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define MAXN 100005
using namespace std;
typedef long long ll;
ll N, val[MAXN], u, v, vis[MAXN], ans;
vector < ll > Graph[MAXN];
void clear ()
{
for ( ll i = 1; i <= N; i++ )
vis[i] = 0;
}
void solve ( ll start, ll node, ll v )
{
if ( node >= start )
ans += v;
vis[node] = 1;
for ( auto i : Graph[node] )
if ( !vis[i] )
solve ( start, i, v ^ val[i] );
}
int main()
{
cin >> N;
for ( ll i = 1; i <= N; i++ )
cin >> val[i];
for ( ll i = 0; i < N - 1; i++ )
{
cin >> u >> v;
Graph[u].push_back ( v );
Graph[v].push_back ( u );
}
for ( ll i = 1; i <= N; i++ )
{
clear();
solve ( i, i, val[i] );
}
cout << ans << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |