Submission #5123

# Submission time Handle Problem Language Result Execution time Memory
5123 2014-02-10T04:14:55 Z ainta Cactus? Not cactus? (kriii1_C) C++
1 / 1
68 ms 10092 KB
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>E[100001];
int n,m,p[100001],C[100001];
bool v[100001];
void DFS(int a){
    v[a]=true;
    int i,j;
    for(i=0;i<E[a].size();i++){
        if(v[E[a][i]] && E[a][i]!=p[a]){
            j=a;
            C[j]++;
            while(j!=E[a][i]){
                C[p[j]]++;
                j=p[j];
            }
        }
    }
    for(i=0;i<E[a].size();i++){
        if(!v[E[a][i]]){
            p[E[a][i]]=a;
            DFS(E[a][i]);
        }
    }
}
int main()
{
    int a,b,i;
    scanf("%d%d",&n,&m);
    while(m--){
        scanf("%d%d",&a,&b);
        E[a].push_back(b);
        E[b].push_back(a);
    }
    DFS(1);
    for(i=1;i<=n;i++)if(C[i]>=2)break;
    if(i==n+1)printf("Cactus\n");
    else printf("Not cactus\n");
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4428 KB Output is correct
2 Correct 0 ms 4428 KB Output is correct
3 Correct 0 ms 4560 KB Output is correct
4 Correct 0 ms 4428 KB Output is correct
5 Correct 0 ms 4428 KB Output is correct
6 Correct 4 ms 4560 KB Output is correct
7 Correct 4 ms 4560 KB Output is correct
8 Correct 4 ms 4560 KB Output is correct
9 Correct 4 ms 4560 KB Output is correct
10 Correct 40 ms 7332 KB Output is correct
11 Correct 32 ms 7180 KB Output is correct
12 Correct 36 ms 7732 KB Output is correct
13 Correct 40 ms 7360 KB Output is correct
14 Correct 40 ms 7188 KB Output is correct
15 Correct 52 ms 8524 KB Output is correct
16 Correct 36 ms 7228 KB Output is correct
17 Correct 32 ms 7740 KB Output is correct
18 Correct 48 ms 9472 KB Output is correct
19 Correct 68 ms 10092 KB Output is correct
20 Correct 40 ms 7480 KB Output is correct
21 Correct 60 ms 7572 KB Output is correct
22 Correct 48 ms 8844 KB Output is correct
23 Correct 0 ms 4428 KB Output is correct
24 Correct 0 ms 4428 KB Output is correct
25 Correct 4 ms 4804 KB Output is correct
26 Correct 60 ms 7200 KB Output is correct
27 Correct 28 ms 5484 KB Output is correct
28 Correct 48 ms 6804 KB Output is correct
29 Correct 40 ms 6804 KB Output is correct
30 Correct 48 ms 6936 KB Output is correct
31 Correct 48 ms 6804 KB Output is correct
32 Correct 64 ms 7200 KB Output is correct
33 Correct 52 ms 7200 KB Output is correct
34 Correct 48 ms 7200 KB Output is correct