# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
240936 |
2020-06-21T15:07:04 Z |
DavidDamian |
Deblo (COCI18_deblo) |
C++11 |
|
1000 ms |
14712 KB |
#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 |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
6 ms |
2688 KB |
Output is correct |
4 |
Correct |
16 ms |
2816 KB |
Output is correct |
5 |
Correct |
18 ms |
2816 KB |
Output is correct |
6 |
Execution timed out |
1066 ms |
14712 KB |
Time limit exceeded |
7 |
Execution timed out |
1096 ms |
14712 KB |
Time limit exceeded |
8 |
Execution timed out |
1088 ms |
9720 KB |
Time limit exceeded |
9 |
Execution timed out |
1095 ms |
9080 KB |
Time limit exceeded |
10 |
Execution timed out |
1092 ms |
8568 KB |
Time limit exceeded |