Submission #96631

# Submission time Handle Problem Language Result Execution time Memory
96631 2019-02-10T14:13:32 Z fadi57 Deblo (COCI18_deblo) C++14
0 / 90
156 ms 20728 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]);
    } 
   
    
}
 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[1]){
 //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[1]){
            ^
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4988 KB Output isn't correct
2 Incorrect 6 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 5240 KB Output isn't correct
6 Runtime error 123 ms 19676 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 116 ms 19704 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 119 ms 20472 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 120 ms 20556 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 156 ms 20728 KB Execution killed with signal 11 (could be triggered by violating memory limits)