Submission #1284498

#TimeUsernameProblemLanguageResultExecution timeMemory
1284498aren_danceDeblo (COCI18_deblo)C++20
18 / 90
92 ms7552 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int mod=1e9+7; const int N=1e6+1; vector<int> g[N]; ll dp[N]; ll answ; ll a[N]; ll pref[N]; ll cnt[N][2]; int n; int main(){ cin>>n; for(int j=0;j<30;++j){ cnt[j][0]++; } for(int i=1;i<=n;++i){ cin>>a[i]; pref[i]=(pref[i-1]^a[i]); for(int j=0;j<30;++j){ if((pref[i]&(1<<j))){ cnt[j][1]++; } else{ cnt[j][0]++; } } for(int j=0;j<30;++j){ if(((1<<j)&pref[i])){ ll e=(1<<j); e*=cnt[j][0]; answ+=e; } else{ ll e=(1<<j); e*=cnt[j][1]; answ+=e; } } } for(int i=1;i<n;++i){ int u,v; cin>>u>>v; g[u].push_back(v); g[v].push_back(u); } cout<<answ; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...