Submission #170458

#TimeUsernameProblemLanguageResultExecution timeMemory
170458mdn2002Deblo (COCI18_deblo)C++14
45 / 90
912 ms65540 KiB
#include<bits/stdc++.h> using namespace std; const long long mod=998244353; int n,a[100005]; long long sm,sum; vector<int>gr[100005]; map<pair<int,int>,int>m; void dfs(int x,int p,int org) { sm^=a[x]; if(m[{org,x}]==0) { sum+=sm; m[{org,x}]=1; m[{x,org}]=1; } for(int i=0;i<gr[x].size();i++) { int u=gr[x][i]; if(u==p)continue; dfs(u,x,org); } sm^=a[x]; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //freopen("lemonade.in","r",stdin); //freopen("lemonade.out","w",stdout); cin>>n; for(int i=1;i<=n;i++)cin>>a[i]; for(int i=0;i<n-1;i++) { int x,y; cin>>x>>y; gr[x].push_back(y); gr[y].push_back(x); } for(int i=1;i<=n;i++)dfs(i,0,i); cout<<sum; }

Compilation message (stderr)

deblo.cpp: In function 'void dfs(int, int, int)':
deblo.cpp:17:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<gr[x].size();i++)
                 ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...