# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4273 | jays | Cactus? Not cactus? (kriii1_C) | C++98 | 68 ms | 13728 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.
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
int N, M;
vector<int> adj[100001];
int depth[100001];
bool isCactus = true;
int dfs(int to, int from, int d) {
int numBack = 0;
int ret = depth[to] = d;
for (int i = 0 ; i < adj[to].size(); ++i) {
int next = adj[to][i];
if (next == from) continue;
if (depth[next] != -1 && depth[next] < depth[to]) {
numBack++;
ret = depth[next];
}
if (depth[next] != -1) continue;
int res = dfs(next, to, d + 1);
// printf("res: %d, depth[to]: %d\n", res, depth[to]);
if (res <= depth[to]) {
numBack++;
ret = min(ret, res);
}
}
if (numBack > 1) isCactus = false;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |