Submission #5120

# Submission time Handle Problem Language Result Execution time Memory
5120 2014-02-10T04:06:45 Z ainta Cactus? Not cactus? (kriii1_C) C++
0 / 1
76 ms 12840 KB
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int par[100010], num[100100], C;
bool chk[100010], ck;
vector<int>E[100010];
int n;
void DFS(int a, int p){
	par[a] = p;
	num[a] = ++C;
	int i, x;
	for (i = 0; i < E[a].size(); i++){
		if (E[a][i] == p)continue;
		if (par[E[a][i]]){
			if (num[E[a][i]] > num[a])continue;
			x = a;
			while (x != E[a][i]){
				ck |= chk[x];
				chk[x] = true;
				if (ck)return;
				x = par[x];
			}
			ck |= chk[x];
			chk[x] = true;
			if (ck)return;
		}
		else DFS(E[a][i], a);
		if (ck)return;
	}
}
int main(){
	int i, a, b, m;
	scanf("%d%d", &n, &m);
	while (m--){
		scanf("%d%d", &a, &b);
		E[a].push_back(b);
		E[b].push_back(a);
	}
	DFS(1, 1);
	printf(ck ? "Not Cactus\n" : "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 0 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 40 ms 7332 KB Output is correct
11 Correct 24 ms 7180 KB Output is correct
12 Correct 36 ms 9316 KB Output is correct
13 Correct 52 ms 8308 KB Output is correct
14 Correct 48 ms 8088 KB Output is correct
15 Correct 56 ms 10372 KB Output is correct
16 Correct 40 ms 8296 KB Output is correct
17 Correct 32 ms 9452 KB Output is correct
18 Correct 60 ms 11880 KB Output is correct
19 Correct 76 ms 12840 KB Output is correct
20 Correct 36 ms 8672 KB Output is correct
21 Correct 64 ms 8068 KB Output is correct
22 Correct 40 ms 10884 KB Output is correct
23 Incorrect 0 ms 4428 KB Output isn't correct
24 Halted 0 ms 0 KB -