# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3798 | cki86201 | Cactus? Not cactus? (kriii1_C) | C++98 | 76 ms | 12172 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<stdio.h>
#include<vector>
using namespace std;
vector<int> edge[100000];
vector<int> now;
bool check[100000]={0};
bool check_cycle[100000]={0};
bool ans=false;
int distime[100000]={0},deltime[100000]={0},time=0;
void dfs(int a,int par){
check[a]=true;
distime[a]=time++;
now.push_back(a);
int i,j;
for(i=0;i<edge[a].size();i++){
if(check[edge[a][i]] && edge[a][i]!=par && distime[edge[a][i]]<distime[a]){
for(j=now.size()-1;j>=0;j--){
if(check_cycle[now[j]]){
ans=true;
return;
}
check_cycle[now[j]]=true;
if(now[j]==edge[a][i]) break;
}
}
else if(!check[edge[a][i]]){
dfs(edge[a][i],a);
if(ans) return;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |