# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
527869 | 2022-02-18T14:25:51 Z | aris12345678 | Deblo (COCI18_deblo) | C++14 | 1000 ms | 7064 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mxN = 1e5+5; vector<int> adj[mxN]; int a[mxN]; ll res[mxN]; void bfs(int s) { queue<int> q; res[s] = a[s]; q.push(s); while(!q.empty()) { int u = q.front(); q.pop(); for(auto &v : adj[u]) { if(res[v] == -1) { res[v] = 1LL*res[u]^a[v]; q.push(v); } } } } int main() { int n; scanf("%d", &n); for(int i = 0; i < n; i++) scanf("%d", &a[i]); for(int i = 1; i < n; i++) { int u, v; scanf("%d %d", &u, &v); adj[u-1].push_back(v-1); adj[v-1].push_back(u-1); } ll ans = 0; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) res[j] = -1; bfs(i); for(int j = i; j < n; j++) ans += res[j]; } printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2636 KB | Output is correct |
2 | Correct | 1 ms | 2636 KB | Output is correct |
3 | Correct | 3 ms | 2636 KB | Output is correct |
4 | Correct | 16 ms | 2692 KB | Output is correct |
5 | Correct | 18 ms | 2636 KB | Output is correct |
6 | Execution timed out | 1085 ms | 6820 KB | Time limit exceeded |
7 | Execution timed out | 1091 ms | 6892 KB | Time limit exceeded |
8 | Execution timed out | 1087 ms | 6856 KB | Time limit exceeded |
9 | Execution timed out | 1093 ms | 6852 KB | Time limit exceeded |
10 | Execution timed out | 1096 ms | 7064 KB | Time limit exceeded |