전체 글
-
테트로미노백준알고리즘 2019. 7. 21. 03:29
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[][] a = new int[n][m]; for (int i=0; i= 0) { int temp = a[i][j] + a[i+1][j] + a[i+1][j-1] + a[i+2][j-1]; if (ans = 0) { int temp2 = temp + a[i..
-
안전영역백준알고리즘 2019. 7. 20. 03:29
#include #include #include #include using namespace std; int N; int a[100][100]; bool d[100][100]; int dx[] = { 0,0,1,-1 }; int dy[] = { 1,-1,0,0 }; int MAX; void bfs(int x, int y, int h) { queue q; q.push(make_pair(x, y)); d[x][y] = true; while (!q.empty()) { x = q.front().first; y = q.front().second; q.pop(); for (int i = 0; i < 4; i++) { int nx = x + dx[i]; int ny = y + dy[i]; if (nx < N && n..
-
인구 이동백준알고리즘 2019. 7. 17. 23:42
#include #include #include #include #include #include using namespace std; int N, L, R; int a[50][50]; int d[50][50]; bool f[50][50]; int dx[] = { 0,0,1,-1 }; int dy[] = { 1,-1,0,0 }; int alp = 0; int mon(int a, int b) { int x = a - b; int y = b - a; if (x < 0) return y; else return x; } void bfs(int x, int y, int recent ) { vector v; queue q; q.push(make_pair(x, y)); v.push_back(make_pair(x, y)..
-
영역 구하기백준알고리즘 2019. 7. 17. 21:55
#include #include #include #include #include #include using namespace std; int n, m, k; int a[101][101]; bool d[101][101]; vector rect[101]; int dx[] = {0,0,1,-1}; int dy[] = {1,-1,0,0}; void bfs(int xx, int yy, vector& v){ queue q; q.push(make_pair(yy, xx)); d[yy][xx] = true; a[yy][xx] = 1; int result = 1; while(!q.empty()){ int x = q.front().second; int y = q.front().first; q.pop(); for(int i ..
-
보물섬백준알고리즘 2019. 7. 17. 21:54
#include #include #include #include #include #include using namespace std; int n,m; int a[51][51]; bool d[51][51]; int c[51][51]; int dx[] = {0,0,1,-1}; int dy[] = {1,-1,0,0}; void initial(){ for(int i = 0; i = 0 && ny >s; if(s == 'L'){ a[i][j] = 1; land.push_back(make_pair(i,j)); } } } vector v; for(int i = 0; i < land.size(); i++){ int x = land[i].first; int y = land[i].second; bfs(x,y,v); ini..
-
시험 감독백준알고리즘 2019. 7. 17. 21:53
#include #include using namespace std; int n; int a[1000000]; int b, c; long long check(long long a, long long c) { long long result = 0; if (a != 0) { if (a % c == 0) { result += (a / c); } else result += (a / c) + 1; return result; } else return 0; } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } scanf("%d %d", &b, &c); long long result = n; for (int i = 0; i..
-
유기농 배추백준알고리즘 2019. 7. 17. 02:25
#include #include #include #include #include using namespace std; int tc; int a[51][51]; bool d[51][51]; int m,n, k; int dx[] = {0,0,1,-1}; int dy[] = {1,-1,0,0}; void bfs(int x, int y){ queue q; q.push(make_pair(x,y)); d[x][y] = true; while(!q.empty()){ x = q.front().first; y = q.front().second; q.pop(); for(int i = 0; i = 0 && nx < n && ny ..