시뮬레이션
-
[BOJ 17825]주사위 윷놀이백준알고리즘 2020. 1. 26. 02:58
https://www.acmicpc.net/problem/17825 17825번: 주사위 윷놀이 주사위 윷놀이는 다음과 같은 게임판에서 하는 게임이다. 가장 처음에는 시작에 말 4개가 있다. 말은 게임판에 적힌 화살표의 방향대로만 이동할 수 있다. 파란색 칸에서 말이 이동을 시작하는 경우에는 파란색 화살표의 방향으로 이동해야 하며 파란색 칸을 지나가는 경우에는 빨간 화살표의 방향대로 이동해야 한다. 게임은 1부터 5까지 한 면에 하나씩 적혀있는 5면 주사위를 굴려서 나온 수만큼 이동하는 방식으로 진행한다. 이동하려고 하는 칸에 말이 이미 있는 경우에 www.acmicpc.net 빡구현문제, 구현 역시 필요한 덕목이다. 실전문제보다 조건이 좀더 까다롭고, 설명이 부족해서 굉장히 귀찮았다. 다른 어떤 구현보..
-
미네랄백준알고리즘 2019. 10. 9. 19:11
https://www.acmicpc.net/problem/2933 2933번: 미네랄 문제 창영과 상근은 한 동굴을 놓고 소유권을 주장하고 있다. 두 사람은 막대기를 서로에게 던지는 방법을 이용해 누구의 소유인지를 결정하기로 했다. 싸움은 동굴에서 벌어진다. 동굴에는 미네랄이 저장되어 있으며, 던진 막대기가 미네랄을 파괴할 수도 있다. 동굴은 R행 C열로 나타낼 수 있으며, R×C칸으로 이루어져 있다. 각 칸은 비어있거나 미네랄을 포함하고 있으며, 네 방향 중 하나로 인접한 미네랄이 포함된 두 칸은 같은 클러스터이다. 창영은 동굴의 왼쪽에 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29..
-
나무 재테크백준알고리즘 2019. 9. 10. 18:14
#include #include using namespace std; struct tree{ int x, y; int age; }; int n, m, k; int dx[] = { 0,0,1,-1,1,1,-1,-1 }; int dy[] = { 1,-1,0,0,1,-1,1,-1 }; int map[20][20];//양분! int ori[20][20]; vector tr; vector death; void spring() { vector temping[1001]; for (int i = 0; i < tr.size(); i++) { temping[tr[i].age].push_back(tr[i]); } tr.clear(); for (int i = 0; i < 1000; i++) { if (temping[i].si..
-
로봇 청소기백준알고리즘 2019. 9. 1. 23:17
로봇 청소기 삼성 기출문제, 시뮬레이션문젠데 지난번에는 BFS써서 풀었었던 기억이있다. BFS말고, 그냥 문제에 주어진로직대로 풀어보는 방식을 사용해서 문제를 재구성했다. #include// using namespace std; struct robot {//0북1동 2남, 3서 int x = 0, y = 0, dir = 0, cnt = 1; robot(int x, int y, int dir) { this->x = x; this->y = y; this->dir = dir; } }; int dx[] = { -1,0,1,0 }; int dy[] = { 0,1,0,-1 }; robot rb = robot(0,0,0); int r, c, X, Y, D; int map[51][51]; bool dist[51][51..
-
낚시왕백준알고리즘 2019. 8. 1. 05:43
#include #include using namespace std; struct shark { int r; int c; int s;//속도 int d;//방향 1 위 2 아래 3 오른쪽, 4 왼쪽임 int z;//크기 bool life = true; shark(int q, int w, int speed, int t, int y) { r = q; c = w; s = speed; d = t; z = y; } }; int ans; vector v[101]; int r, c,m; void check(int al) { for (int i = 0; i < v[al].size(); i++) { if (v[al][i].z == 0) continue; int max = v[al][i].z; vector index; i..
-
5656. [모의 SW 역량테스트] 벽돌 깨기SWexpertAcademy 2019. 7. 27. 01:44
#include #include #include #include using namespace std; int n,h, w; int map[15][12]; int mapc[15][12]; int tc; int result = 1000000; struct brick { int x; int y; int value; brick(int a, int b, int c) { x = a; y = b; value = c; } }; void sorting() { for (int i = 0; i = 0; j--) { if (map[j][i] == 0) { for (int k = j - 1; k >= 0; k--) { if (map[k][i] != 0) { map[..
-
5644. [모의 SW 역량테스트] 무선 충전SWexpertAcademy 2019. 7. 24. 21:39
#include #include #include #include #include using namespace std; struct bat{ int x; int y; int scale; int charge; int numb; }; int map[8][21][21]; bool d[8][21][21]; int m, a; int tc; int c[5] = { 1, 5, 21, 85, 341}; int dx[] = {1,-1,0,0}; int dy[] = {0,0,1,-1}; int dx1[] = {0,-1,0,1,0}; int dy1[] = {0,0,1,0,-1}; int max(int a, int b){ int max = a; if(max < b) max = b; return max; } bool checki..