#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 time |
Memory |
Grader output |
1 |
Execution timed out |
1125 ms |
394728 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1124 ms |
430948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1089 ms |
40092 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
384 ms |
50212 KB |
Output is correct |
2 |
Correct |
80 ms |
2896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
741 ms |
433336 KB |
Output is correct |
2 |
Correct |
93 ms |
4944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1067 ms |
175012 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
517 ms |
42420 KB |
Output is correct |
2 |
Correct |
78 ms |
3020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1002 ms |
88948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1108 ms |
215500 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1109 ms |
215476 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
20180 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1098 ms |
20052 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
21332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1099 ms |
20180 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |