Submission #96633

# Submission time Handle Problem Language Result Execution time Memory
96633 2019-02-10T14:19:29 Z fadi57 Deblo (COCI18_deblo) C++14
0 / 90
155 ms 19036 KB
#include <bits/stdc++.h>
using namespace std;
 
#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
 
typedef long long     ll;
 
//-*-*-*-*-*-*-*-*-
  vector<ll>c[99999];ll sum=0;
  vector<ll>v[99999];ll w[999999];
void dfs(ll i,ll par){
 v[i].push_back(w[i]);
   
    for(auto &o:c[i]){
if(o==par){continue;}
dfs(o,i);

    }
    if(par==0){sum+=w[i]; return;}
for(auto &o:v[i]){
 v[par].push_back(o^w[par]);sum+=(o^w[par]);
    } sum+=w[i];
   
    
}
 map<ll,ll>l;ll ans=-999;
 
int main()
{
   ll n;cin>>n;
for(int i=1;i<=n;i++){
 cin>>w[i];
   
}
 for(int i=0;i<n-1;i++){
    ll x,y;
 cin>>x>>y; c[x].push_back(y); c[y].push_back(x);
    
 }
 dfs(1,0);
 for(auto &o:v[2]){
 //cout<<o;
    }cout<<sum;
 
   }

Compilation message

deblo.cpp: In function 'int main()':
deblo.cpp:42:12: warning: unused variable 'o' [-Wunused-variable]
  for(auto &o:v[2]){
            ^
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 4984 KB Output isn't correct
2 Incorrect 5 ms 4984 KB Output isn't correct
3 Incorrect 6 ms 4984 KB Output isn't correct
4 Incorrect 9 ms 6904 KB Output isn't correct
5 Incorrect 7 ms 5112 KB Output isn't correct
6 Runtime error 138 ms 17784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 121 ms 17916 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 155 ms 18664 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 116 ms 18552 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 134 ms 19036 KB Execution killed with signal 11 (could be triggered by violating memory limits)