Submission #4073

# Submission time Handle Problem Language Result Execution time Memory
4073 2013-08-31T18:55:47 Z ainta Cactus? Not cactus? (kriii1_C) C++
1 / 1
64 ms 10084 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 4 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 0 ms 4560 KB Output is correct
9 Correct 0 ms 4560 KB Output is correct
10 Correct 44 ms 7332 KB Output is correct
11 Correct 28 ms 7180 KB Output is correct
12 Correct 28 ms 7736 KB Output is correct
13 Correct 52 ms 7360 KB Output is correct
14 Correct 44 ms 7184 KB Output is correct
15 Correct 40 ms 8520 KB Output is correct
16 Correct 36 ms 7224 KB Output is correct
17 Correct 36 ms 7736 KB Output is correct
18 Correct 56 ms 9476 KB Output is correct
19 Correct 64 ms 10084 KB Output is correct
20 Correct 24 ms 7480 KB Output is correct
21 Correct 60 ms 7568 KB Output is correct
22 Correct 56 ms 8852 KB Output is correct
23 Correct 0 ms 4428 KB Output is correct
24 Correct 0 ms 4428 KB Output is correct
25 Correct 0 ms 4800 KB Output is correct
26 Correct 52 ms 7200 KB Output is correct
27 Correct 20 ms 5484 KB Output is correct
28 Correct 48 ms 6804 KB Output is correct
29 Correct 48 ms 6804 KB Output is correct
30 Correct 48 ms 6936 KB Output is correct
31 Correct 52 ms 6804 KB Output is correct
32 Correct 56 ms 7200 KB Output is correct
33 Correct 52 ms 7200 KB Output is correct
34 Correct 52 ms 7200 KB Output is correct