# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
461235 | 2021-08-09T15:11:44 Z | vanic | Nuclearia (CEOI15_nuclearia) | C++14 | 0 ms | 0 KB |
#include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <cstring> using namespace std; typedef long long ll; vector < vector < ll > > l; vector < ll > vi; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int h, w; cin >> w >> h; vi.resize(h, 0); l.resize(w, vi); int n; cin >> n; ll a, b, c, d; for(int i=0; i<n; i++){ cin >> a >> b >> c >> d; a--; b--; for(int j=0; j<w; j++){ for(int k=0; k<h; k++){ l[j][k]+=max(0ll, c-d*max(abs(j-a), abs(k-b))); } } } int q; cin >> q; ll sum; for(int i=0; i<q; i++){ cin >> a >> b >> c >> d; a--; b--; c--; d--; sum=0; for(int j=a; j<=c; j++){ for(int k=b; k<=d; k++){ sum+=l[j][k]; } } cout << (ll)round((double)sum/((c-a+1)*(d-b+1))) << '\n'; } return 0; }