# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
86986 |
2018-11-29T04:28:08 Z |
joseacaz |
Deblo (COCI18_deblo) |
C++17 |
|
1000 ms |
15692 KB |
#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 |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2684 KB |
Output is correct |
3 |
Correct |
5 ms |
2744 KB |
Output is correct |
4 |
Correct |
17 ms |
2888 KB |
Output is correct |
5 |
Correct |
17 ms |
2960 KB |
Output is correct |
6 |
Execution timed out |
1075 ms |
14232 KB |
Time limit exceeded |
7 |
Execution timed out |
1069 ms |
15692 KB |
Time limit exceeded |
8 |
Execution timed out |
1085 ms |
15692 KB |
Time limit exceeded |
9 |
Execution timed out |
1083 ms |
15692 KB |
Time limit exceeded |
10 |
Execution timed out |
1080 ms |
15692 KB |
Time limit exceeded |