# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
330516 | BeanZ | Cats or Dogs (JOI18_catdog) | C++14 | 3098 ms | 7256 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.
// I_Love_LPL
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define endl '\n'
const int N = 1e5 + 5;
const int lg = 60;
const int mod = 998244353;
const long long oo = 1e18;
const int lim = 1e6 + 5;
long double eps = 1e-3;
vector<ll> node[N];
ll dpc[N], dpd[N], color[N];
void initialize(ll n, vector<ll> A, vector<ll> B){
for (int i = 1; i < n; i++){
node[A[i - 1]].push_back(B[i - 1]);
node[B[i - 1]].push_back(A[i - 1]);
}
}
void dfs(ll u, ll p){
dpc[u] = 0;
dpd[u] = 0;
if (color[u] == 1) dpd[u] = 1e9;
if (color[u] == 2) dpc[u] = 1e9;
for (auto j : node[u]){
if (j == p) continue;
dfs(j, u);
if (color[u] == 1) dpc[u] += min(dpc[j], dpd[j] + 1);
else if (color[u] == 2) dpd[u] += min(dpd[j], dpc[j] + 1);
else dpc[u] += min(dpc[j], dpd[j] + 1), dpd[u] += min(dpd[j], dpc[j] + 1);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |