Created
August 7, 2015 00:41
-
-
Save indrasaputra/b9f1a56955567b31b66b 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 <cstdio> | |
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <cstring> | |
#include <cmath> | |
#include <utility> | |
#include <bitset> | |
#include <stack> | |
#include <queue> | |
#define fi first | |
#define sc second | |
using namespace std; | |
typedef pair<int,int> ii; | |
int maps[105][105]; | |
int r,c; | |
int fillMap = 1; | |
bool isVisited[105][105]; | |
queue<pair<int,int> > myQ; | |
int main() | |
{ | |
r = c = 10; | |
for(int i=0; i<r; i++) | |
{ | |
for(int j=0; j<c; j++) | |
{ | |
maps[i][j] = fillMap++; | |
} | |
} | |
myQ.push(ii(0,0)); | |
int co = 1; | |
while(!myQ.empty()) | |
{ | |
ii currentCoor = myQ.front(); | |
myQ.pop(); | |
int x = currentCoor.fi; | |
int y = currentCoor.sc; | |
if(x>=0 && x<r && y>=0 && y<c && !isVisited[x][y]) | |
{ | |
isVisited[x][y] = true; | |
myQ.push(ii(x+1,y)); | |
myQ.push(ii(x-1,y)); | |
myQ.push(ii(x,y+1)); | |
myQ.push(ii(x,y-1)); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment