Created
August 29, 2015 16:49
-
-
Save StarOrpheus/c047b993ffd9e9d4aded to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
#include <cstdlib> | |
#include <vector> | |
#include <algorithm> | |
#include <set> | |
#include <stack> | |
#include <cstring> | |
#include <map> | |
#include <iomanip> | |
#include <queue> | |
using namespace std; | |
#define mkp(a, b) make_pair(a, b) | |
#define F first | |
#define S second | |
#define MAX(a, b) ((a) > (b) ? (a) : (b)) | |
int n, m; | |
vector<vector<int > > g; | |
char state[5000]; | |
void f(int v, int parent=0) | |
{ | |
state[v] = 1; | |
for(int i = 0; i < g[v].size(); i++) | |
if(parent == 0 || g[v][i] != parent) | |
{ | |
if(state[g[v][i]] == 0) | |
f(g[v][i], v); | |
else if(state[g[v][i]] == 1) | |
} | |
state[v] = 2; | |
} | |
int main() { | |
// ios_base::sync_with_stdio(0); | |
// freopen("tree.in", "r", stdin); | |
// freopen("tree.out", "w", stdout); | |
scanf("%d %d", &n, &m); | |
memset(state, 0, sizeof state); | |
g.resize(n+1); | |
for(int i = 0; i < m; i++) | |
{ | |
int a, b; | |
g[a].push_back(b); | |
g[b].push_back(a); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment