제출 #538648

#제출 시각아이디문제언어결과실행 시간메모리
538648FatihSolakNuclearia (CEOI15_nuclearia)C++17
14 / 100
1125 ms433336 KiB
#include <bits/stdc++.h>
#define N 200005
using namespace std;
struct nuclear{
    int x,y;
    long long a,b;
}nuclears[N];
void solve(){
    int h,w;
    cin >> w >> h;
    vector<vector<long long>> v(w+5,(vector<long long>(h+5))); 
    int n;
    cin >> n;
    for(int i = 1;i<=n;i++){
        cin >> nuclears[i].x >> nuclears[i].y >> nuclears[i].a >> nuclears[i].b;
        for(int x = 1;x<=h;x++){
            for(int y = 1;y<=w;y++){
                v[y][x] += max(0ll,nuclears[i].a - max(abs(y - nuclears[i].x),abs(x - nuclears[i].y))*nuclears[i].b);
            }
        }
    }
    vector<vector<long long>> pre(w+5,(vector<long long>(h+5)));
    for(int i = 1;i<=h;i++){
        for(int j = 1;j<=w;j++){
            pre[j][i] = pre[j][i-1] + pre[j-1][i] - pre[j-1][i-1] + v[j][i];
        }
    } 
    int q;
    cin >> q;
    while(q--){
        int x1,y1,x2,y2;
        cin >> x1 >> y1 >> x2 >> y2;
        long double sz = (x2 - x1 + 1) * (y2 - y1 + 1);
        cout << (long long)((pre[x2][y2] - pre[x2][y1-1] - pre[x1-1][y2] + pre[x1-1][y1-1] + sz/2)/sz) << '\n';
    }
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifdef Local
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    #ifdef Local
    cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...