Submission #18593

# Submission time Handle Problem Language Result Execution time Memory
18593 2016-02-10T09:40:04 Z eaststar Cactus? Not cactus? (kriii1_C) C++14
0 / 1
40 ms 6836 KB
#include <stdio.h>
struct al{
    int e,nx;
}a[200010];
int st[100010],chk[100010],p[100010],cycle[100010],t;
void make_al(int s,int e){a[++t].nx=st[s],a[t].e=e,st[s]=t;}
void get_cycle(int s,int x){
    ++cycle[x];
    for(;;){
        ++cycle[s];
        s=p[s];
        if(s==x)return;
    }
}
void DFS(int s){
    int i;
    chk[s]=1;
    for(i=st[s];i;i=a[i].nx)if(chk[a[i].e]){
        if(p[s]==a[i].e)continue;
        get_cycle(s,a[i].e);
    }
    for(i=st[s];i;i=a[i].nx)if(!chk[a[i].e]){
        p[a[i].e]=s;
        DFS(a[i].e);
    }
}
int main(){
    int i,n,m,s,e;
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;++i){
        scanf("%d%d",&s,&e);
        make_al(s,e),make_al(e,s);
    }
    DFS(1);
    for(i=1;i<=n;++i)if(cycle[i]>1){
        printf("Not ");
        break;
    }
    puts("Cactus");
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4208 KB Output is correct
2 Correct 0 ms 4208 KB Output is correct
3 Correct 0 ms 4208 KB Output is correct
4 Correct 0 ms 4208 KB Output is correct
5 Correct 0 ms 4208 KB Output is correct
6 Correct 0 ms 4208 KB Output is correct
7 Correct 2 ms 4208 KB Output is correct
8 Correct 0 ms 4208 KB Output is correct
9 Correct 0 ms 4208 KB Output is correct
10 Correct 21 ms 4208 KB Output is correct
11 Correct 26 ms 4208 KB Output is correct
12 Correct 31 ms 5668 KB Output is correct
13 Correct 22 ms 5028 KB Output is correct
14 Correct 28 ms 4980 KB Output is correct
15 Correct 38 ms 5052 KB Output is correct
16 Correct 16 ms 5288 KB Output is correct
17 Correct 28 ms 5800 KB Output is correct
18 Correct 34 ms 5852 KB Output is correct
19 Correct 40 ms 6836 KB Output is correct
20 Correct 30 ms 5048 KB Output is correct
21 Correct 30 ms 4968 KB Output is correct
22 Correct 40 ms 6352 KB Output is correct
23 Incorrect 0 ms 4208 KB Output isn't correct
24 Halted 0 ms 0 KB -