본문 바로가기

백준 알고리즘/시뮬레이션43

백준 이차원 배열과 연산 C++ #include #include #include using namespace std; const int MAX = 101; int num[MAX][MAX]; int r, c, k; int indexi, indexj; bool cmp(pair a, pair b) { if (a.second < b.second) return true; else if (a.second == b.second) return a.first < b.first; else return false; } void rowchange() { int maxsize = 0; vector v; for (int i = 1; i k; indexi = 3, indexj = 3; for (int i = 1; i num[i][j]; } } while (tru.. 2019. 10. 17.
백준 낚시왕 C++ #include #include #include #include using namespace std; const int MAX = 101; vector shark[MAX][MAX]; int r, c, m; int hunter = 0; struct Move { int x, y; }; Move mv[4] = { {-1,0} , {1,0}, {0,1}, {0,-1} }; int main(void) { int answer = 0; cin >> r >> c >> m; for (int i = 0; i > r >> c >> s >> d >> z; shark[r][c].push_back(make_pair(s, make_pair(d-1, z))); } wh.. 2019. 10. 17.
백준 나무 재테크 C++ #include #include #include using namespace std; const int MAX = 11; int map[MAX][MAX]; int n, m, k; int nutrient[MAX][MAX]; vector tree[MAX][MAX]; struct Move { int x, y; }; Move mv[8] = { {-1,-1}, {-1,0}, {-1,1}, {0,-1}, {0,1}, {1,-1}, {1,0}, {1,1} }; void treegrow() { //string,summer for (int i = 1; i n >> m >> k; for (int i = 1; i map[i][j]; nutrient[i][j] = 5; } } for (int i = 0; i < m; i++).. 2019. 10. 16.
백준 큐빙 C++ #include using namespace std; const int MAX = 3; char cube[6][MAX][MAX]; int testcase, counts; char color[6] = { 'w','g','b','r','o','y' }; void clockwise(int i) { int copy[MAX][MAX]; for (int a = 0; a < 3; a++) { for (int b = 0; b < 3; b++) { copy[a][b] = cube[i][a][b]; } } for (int a = 0; a < 3; a++) { for (int b = 0; b < 3; b++) { cube[i][a][b] = copy[2 - b][a]; } } } void counterclockwise(in.. 2019. 10. 15.