| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1347263 | hridoy | Cats or Dogs (JOI18_catdog) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> adj[100005];
int state[100005];
int danger;
pair<bool,bool> dfs(int node, int parent) {
bool hasCat = (state[node] == 1);
bool hasDog = (state[node] == 2);
for (int next : adj[node]) {
if (next != parent) {
auto [childCat, childDog] = dfs(next, node);
hasCat |= childCat;
hasDog |= childDog;
}
}
return {hasCat, hasDog};
}
