# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
255117 | Vladikus004 | Deblo (COCI18_deblo) | C++14 | 118 ms | 32504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
const int N = 100000 + 3;
int n, a[N], dp[N][23][2];
vector <vector <int> > v;
ll ans = 0;
void dfs(int x, int pr = -1){
for (int i = 0; i < 23; i++)
dp[x][i][(a[x]>>i)&1]++;
for (auto u: v[x]){
if (u == pr) continue;
dfs(u, x);
for (int i = 0; i < 23; i++){
ans += (dp[x][i][1] * dp[u][i][0] + dp[x][i][0] * dp[u][i][1]) * (1<<i);
if ((a[x]>>i) & 1){
dp[x][i][0] += dp[u][i][1];
dp[x][i][1] += dp[u][i][0];
}else{
dp[x][i][0] += dp[u][i][0];
dp[x][i][1] += dp[u][i][1];
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |