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
- 우선순위 큐
- 다익스트라
- 재귀
- Team Fortress 2
- 자료구조
- XR Interaction Toolkit
- 백준
- 수학
- 트리
- 브루트포스
- 유니온 파인드
- 투 포인터
- 그래프
- 시뮬레이션
- 백트래킹
- 정렬
- BFS
- VR
- 스택
- c++
- 누적 합
- ue5
- 다이나믹 프로그래밍
- 문자열
Archives
- Today
- Total
1일1알
백준 1531번 투명 C++ 본문
100*100 배열에 입력받을때마다 수를 증가시켜서 최종적으로 m보다 크면 안보이는 것이다.
그리고 입력이 x,y좌표로 주어지는데 row, col로 그냥 써도 상관없을 것 같아서 변환하지 않고 사용하였다.
#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>
#include <iomanip>
using namespace std;
using ll = long long;
vector<vector<int>> board(101, vector<int>(101, 0));
void Solve(int row1, int row2, int col1, int col2) {
for (int i = row1; i <= row2; i++) {
for (int j = col1; j <= col2; j++) {
board[i][j]++;
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) {
int row1, row2, col1, col2;
cin >> row1 >> col1 >> row2 >> col2;
Solve(row1, row2, col1, col2);
}
int cnt = 0;
for (int i = 1; i <= 100; i++) {
for (int j = 1; j <= 100; j++) {
if (board[i][j] > m) cnt++;
}
}
cout << cnt;
};
'알고리즘' 카테고리의 다른 글
백준 1756번 피자 굽기 C++ (0) | 2022.05.03 |
---|---|
백준 1544번 사이클 단어 C++ (0) | 2022.05.02 |
백준 1515번 수 이어 쓰기 C++ (0) | 2022.04.29 |
백준 1417번 국회의원 선거 C++ (0) | 2022.04.28 |
백준 1421번 나무꾼 이다솜 C++ (0) | 2022.04.27 |