Created
June 28, 2016 11:46
-
-
Save kepta/3baa288410dfbd482fd6de83cdca99d4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <stdio.h> | |
// #include <stack> | |
// | |
// using namespace std; | |
// | |
// void pushNeighbours(int x, int t, int *grid, stack<int> s) { | |
// for (int i =0 ; i < t ; i++) { | |
// if (grid[x][i] == 1) { | |
// s.push(i); | |
// } | |
// } | |
// } | |
void dfs(int startX, int t, int grid[t][t]) { | |
for(int i = 0 ; i < t ; i++ ) { | |
for(int j = 0 ; j < t ; j++) { | |
if ( grid[i][j] == 1) { | |
printf("%d ", grid[i][j]); | |
} else { | |
printf("%d ", 0); | |
} | |
} | |
printf("\n"); | |
} | |
// std::stack<int> s; | |
// s.push(startX); | |
// while(s.empty() == false) { | |
// int top = s.top(); | |
// // check for stuff | |
// if (marking[top] != 1) { | |
// // pushNeighbours(top, t, grid, s); | |
// } | |
// } | |
} | |
// void goo(int t) { | |
// return 5; | |
// } | |
int main() { | |
int t; | |
scanf("%d", &t); | |
int grid[t][t]; | |
int marking[t]; | |
int startX = -1; | |
int startY = -1; | |
for(int i = 0; i < t ; i++) { | |
int x, y; | |
scanf("%d %d",&x, &y); | |
grid[x][y] = 1; | |
grid[y][x] = 1; | |
if (startX == -1) { | |
startX = x; | |
startY = y; | |
} | |
} | |
dfs(startX, t, grid); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment