Submission #384867

#TimeUsernameProblemLanguageResultExecution timeMemory
384867AdiZer0Deblo (COCI18_deblo)C++17
45 / 90
1094 ms8556 KiB
#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 (stderr)

deblo.cpp: In function 'int main()':
deblo.cpp:36:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   36 |     int n; scanf ("%d", &n);
      |            ~~~~~~^~~~~~~~~~
deblo.cpp:37:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   37 |     for (int i = 1; i <= n; ++i) scanf ("%d", c + i);
      |                                  ~~~~~~^~~~~~~~~~~~~
deblo.cpp:39:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   39 |         int u, v; scanf ("%d %d", &u, &v);
      |                   ~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...