알고리즘

[알고리즘] 백준 10163 - 색종이 (C++)

blueberrysoda 2024. 11. 13. 23:57
#include<iostream>
#include<vector>
using namespace std;

int Arr[1001][1001];

int main(){
    int N, X, Y, W, H;

    cin >> N;
    
    for(int i=1; i<=N; i++){
        cin >> X >> Y >> W >> H;
        for (int j=X; j<X+W; j++){
            for(int k=Y; k<Y+H; k++){
                Arr[j][k] = i;
            }
        }
    }

    for(int i=1; i<=N; i++){
        int sum = 0;
        for(int j=0; j<1001; j++){
            for(int k=0; k<1001; k++){
                if(Arr[j][k] == i){
                    sum++;
                }
            }
        }
        cout << sum << "\n";
    }
    return 0;
}

[문제 링크] : https://www.acmicpc.net/problem/10163