a694: 吞食天地二https://zerojudge.tw/ShowProblem?problemid=a694


Allen(AC)



#include <iostream>
    using namespace std;

int main() {

    int arr[500][500];
    int n, m, x1[10000], y1[10000], x2[10000], y2[10000];
    int sum = 0;

    cin >> n >> m;

    for (int i= 0; i < n;i++){
        for (int j= 0; j < n;j++){
            cin >> arr[i][j];
        }
    }


    for (int i= 0; i < m;i++){
        cin >> x1[i];
        cin >> y1[i];
        cin >> x2[i];
        cin >> y2[i];
    }


    int eatTimes = 0;
    while (eatTimes<m){
        sum = 0;
        for (int i= x1[eatTimes]-1; i <= x2[eatTimes]-1;i++){
            for(int j= y1[eatTimes]-1; j <= y2[eatTimes]-1;j++){
                sum += arr[i][j];
            }
        }
        eatTimes++;
        cout<<sum<<endl;
    }

}

results matching ""

    No results matching ""