Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 문자열
- 수학
- 브루트포스
- 정렬
- 그래프
- Unreal Engine 5
- 스택
- 백트래킹
- 우선순위 큐
- 다이나믹 프로그래밍
- 유니온 파인드
- 재귀
- DFS
- 유니티
- BFS
- XR Interaction Toolkit
- Team Fortress 2
- 구현
- c++
- 자료구조
- 트리
- 다익스트라
- 그리디 알고리즘
- 시뮬레이션
- 투 포인터
- 누적 합
- 백준
- 알고리즘
- ue5
- VR
Archives
- Today
- Total
1일1알
백준 10836번 여왕벌 C++ 본문
왼쪽 아래에서부터 가장자리를 타고 오른쪽 위까지 자라는 정도가 감소하지 않는다고 했기 때문에 직접 자라는 정도를 입력받는 0열을 제외한 열들은 자기 위의 값과 같은 값을 가지게 된다. 자라는 정도가 감소하지 않기 때문에 자기 위에서 자라는 정도가 가장 크기 때문이다. 0행과 0열의 값만 구해주고, 나머지 원소들은 자기 위의 값을 출력하면 된다.
그리고 자라는 정도가 0일 경우에는 아무 행동도 하지 않아도 된다.
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
int m, n;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> m >> n;
vector<vector<int>> board(m, vector<int>(m, 1));
vector<int> grow(2 * m - 1, 0);
for (int i = 0; i < n; i++) {
int zero, one, two;
cin >> zero >> one >> two;
int idx2 = zero + one;
int idx3 = idx2 + two;
for (int j = zero; j < idx3; j++) {
if (j < idx2) {
grow[j] += 1;
}
else if (j < idx3) {
grow[j] += 2;
}
}
}
for (int i = 0; i < 2 * m - 1; i++) {
if (i < m) {
board[m - i - 1][0] += grow[i];
}
else {
board[0][i - m + 1] += grow[i];
}
}
for (int i = 0; i < m; i++) {
for (int j = 0; j < m; j++) {
if (i == 0 || j == 0) cout << board[i][j];
else cout << board[0][j];
cout << " ";
}
cout << "\n";
}
};
'알고리즘' 카테고리의 다른 글
백준 10253번 헨리 C++ (0) | 2022.02.04 |
---|---|
백준 8972번 미친 아두이노 C++ (0) | 2022.02.03 |
백준 17259번 선물이 넘쳐흘러 C++ (0) | 2022.02.02 |
백준 2818번 숙제하기 싫을 때 C++ (0) | 2022.02.01 |
백준 1680번 쓰레기 수거 C++ (0) | 2022.02.01 |