답안 #3459

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3459 2013-08-31T05:55:46 Z Apple_Cplus Cactus? Not cactus? (kriii1_C) C++
0 / 1
68 ms 11152 KB
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
 
using namespace std;
 
#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pii pair<int,pi>
#define X first
#define Y second
#define pb push_back
#define ab(x) ((x)<0?(-(x)):(x))
#define xx(x) ((x)*(x))
#define mp make_pair
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vpi vector<pi>
#define vpll vector<pll>
#define ALL(x) (x).begin(),(x).end()
#define Max (1<<30)
#define LLMax (1ll<<60)
template<class T>string ToString(T t){stringstream s;s<<t;return s.str();}
template<class T>void ToOther(T&t,string a){stringstream s(a);s>>t;}
 
 
int n,m;
vi v[100005];
bool ck[100005];

int go(int x,int p){
	ck[x]=1;
	int cnt=0;
	for(int i=0;i<v[x].size();i++){
		int t=v[x][i];if(t==p)continue;
		if(ck[t]){cnt++;continue;}
	
		go(t,x);
	}
	if(cnt>=2){
		cout<<"Not cactus"<<endl;
		exit(0);
	}
}

int main(){
	scanf("%d%d",&n,&m);

	for(int i=0;i<m;i++){
		int s,e;scanf("%d%d",&s,&e);
		v[s].pb(e);v[e].pb(s);
	
	}

	go(1,-1);
	cout<<"Cactus"<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4112 KB Output is correct
2 Correct 0 ms 4112 KB Output is correct
3 Correct 4 ms 4244 KB Output is correct
4 Correct 0 ms 4112 KB Output is correct
5 Correct 0 ms 4112 KB Output is correct
6 Correct 0 ms 4244 KB Output is correct
7 Correct 0 ms 4244 KB Output is correct
8 Correct 0 ms 4244 KB Output is correct
9 Correct 4 ms 4244 KB Output is correct
10 Correct 36 ms 7016 KB Output is correct
11 Correct 24 ms 6864 KB Output is correct
12 Correct 36 ms 8212 KB Output is correct
13 Correct 40 ms 7520 KB Output is correct
14 Correct 40 ms 7320 KB Output is correct
15 Correct 56 ms 9132 KB Output is correct
16 Correct 24 ms 7448 KB Output is correct
17 Correct 36 ms 8280 KB Output is correct
18 Correct 56 ms 10364 KB Output is correct
19 Correct 68 ms 11152 KB Output is correct
20 Correct 28 ms 7764 KB Output is correct
21 Correct 56 ms 7500 KB Output is correct
22 Correct 52 ms 9552 KB Output is correct
23 Correct 0 ms 4112 KB Output is correct
24 Correct 0 ms 4112 KB Output is correct
25 Incorrect 4 ms 4608 KB Output isn't correct
26 Halted 0 ms 0 KB -