백준 14500 테트로미노
#pragma warning(disable:4996) #include#include#define MAX 502using namespace std; int map[MAX][MAX];bool visit[MAX][MAX];int n, m, tmp;int dx[4] = { 0,0,1,-1 };int dy[4] = { 1,-1,0,0 }; int dfs(int x, int y, int d) {if (d == 4) return map[x][y]; visit[x][y] = 1;int ret = 0;for (int i = 0; i < 4; i++) {int nx = x + dx[i];int ny = y + dy[i];if (nxm) continue;if (visit[nx][ny]) continue;tmp = dfs(n..
2017. 10. 21.
백준 14502 연구소
#pragma warning(disable:4996) #include#include#include#include #define MAX 8 using namespace std; int map[MAX][MAX];int n, m;bool visit[MAX][MAX];int max_value;int dx[4] = { 0, 0, 1, -1 };int dy[4] = { 1, -1, 0, 0 }; vector virus; void input() {scanf("%d %d", &n, &m);for(int i=0; i= m || map[nx][ny] != 0) continue;map[nx][ny] = 2;q.push(make_pair(nx, ny));}}} void dfs(int x, int y, int d) {map[x..
2017. 10. 21.
백준 14503 로봇 청소기
#include #define MAX 51using namespace std; int map[MAX][MAX];int m, n;int x, y, d;int dx[4] = { -1, 0, 1, 0 };int dy[4] = { 0, 1, 0, -1 }; void input() {scanf("%d %d", &n, &m);scanf("%d %d %d", &x, &y, &d); for (int i = 0; i < n; i++)for (int j = 0; j < m; j++)scanf("%d", &map[i][j]);} int turn(int now, int next) {if (next == 0){if (now == 0) return 3;else if (now == 1) return 0;else if (now ==..
2017. 10. 20.
백준 14499 주사위 굴리기
#include #include using namespace std; int n, m, x, y, k, nx, ny;int map[20][20], karray[1001], dice[5];int dx[4] = { 0, 0, -1, 1 }; // East, West, North, Southint dy[4] = { 1, -1, 0, 0 }; void dice_move(int d) {switch (d) {case 0: // Eastswap(dice[1], dice[2]);swap(dice[4], dice[5]);swap(dice[2], dice[5]);break;case 1: // Westswap(dice[4], dice[5]);swap(dice[1], dice[2]);swap(dice[1], dice[4]);..
2017. 10. 20.