# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
384867 | 2021-04-02T14:15:06 Z | AdiZer0 | Deblo (COCI18_deblo) | C++17 | 1000 ms | 8556 KB |
#include <bits/stdc++.h> #define pb push_back #define whole(x) x.begin(), x.end() #define sz(x) (int)x.size() using namespace std; typedef long long ll; typedef long double ld; const int N = (int)1e5 + 7; const int INF = (int)1e9 + 7; const ll linf = (ll)1e18 + 1; int c[N], d[N]; vector<int> g[N]; void bfs(int s) { queue<int> q; d[s] = c[s]; q.push(s); while (!q.empty()) { int v = q.front(); q.pop(); for (int to : g[v]) { if (d[to] == -1) { d[to] = (d[v] ^ c[to]); q.push(to); } } } } int main() { int n; scanf ("%d", &n); for (int i = 1; i <= n; ++i) scanf ("%d", c + i); for (int i = 1; i < n; ++i) { int u, v; scanf ("%d %d", &u, &v); g[u].pb(v), g[v].pb(u); } ll ans = 0; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) d[j] = -1; bfs(i); for (int j = i; j <= n; ++j) ans += d[j]; } printf ("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2668 KB | Output is correct |
2 | Correct | 3 ms | 2668 KB | Output is correct |
3 | Correct | 3 ms | 2688 KB | Output is correct |
4 | Correct | 18 ms | 2668 KB | Output is correct |
5 | Correct | 23 ms | 2668 KB | Output is correct |
6 | Execution timed out | 1092 ms | 8428 KB | Time limit exceeded |
7 | Execution timed out | 1087 ms | 8428 KB | Time limit exceeded |
8 | Execution timed out | 1093 ms | 8556 KB | Time limit exceeded |
9 | Execution timed out | 1086 ms | 8556 KB | Time limit exceeded |
10 | Execution timed out | 1094 ms | 8556 KB | Time limit exceeded |