#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define uniq(x) x.erase(unique(all(x)), x.end())
int W, H, N, Q;
vector< vector<long long> > A;
vector< vector<long long> > T;
int main() {
cin >> W >> H >> N;
A.resize(W);
rep(x, W) A[x].resize(H);
rep(i, N) {
int x, y, a, b;
cin >> x >> y >> a >> b;
x--, y--;
rep(xx, W) rep(yy, H) {
int dist = max(abs(xx-x), abs(y-yy));
A[xx][yy] += max(0LL, a-1LL*b*dist);
}
}
/*
rep(y, H) {
rep(x, W) cout << A[x][y] << " ";
cout << "\n";
}
*/
T = vector< vector<long long> >(A);
rep(y, H) rep(x, W-1) T[x+1][y] += T[x][y];
rep(y, H-1) rep(x, W) T[x][y+1] += T[x][y];
cin >> Q;
rep(i, Q) {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
x1--, y1--, x2--, y2--;
long long s = T[x2][y2];
if (x1 > 0) s -= T[x1-1][y2];
if (y1 > 0) s -= T[x2][y1-1];
if (x1 > 0 && y1 > 0) s += T[x1-1][y1-1];
long long q = 1LL*(x2-x1+1)*(y2-y1+1);
//cout<<s<<"/"<<q<<"\n";
cout << ((2LL*s/q)+1)/2 << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
275496 KB |
Execution timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
275496 KB |
Execution timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
399 ms |
41472 KB |
Output is correct |
2 |
Runtime error |
179 ms |
2016 KB |
Execution timed out (wall clock limit exceeded) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
326 ms |
41216 KB |
Output is correct |
2 |
Runtime error |
179 ms |
2016 KB |
Execution timed out (wall clock limit exceeded) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
636 ms |
275496 KB |
Execution timed out (wall clock limit exceeded) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
111464 KB |
Execution timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
526 ms |
41116 KB |
Execution timed out (wall clock limit exceeded) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
893 ms |
56740 KB |
Execution timed out (wall clock limit exceeded) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
138756 KB |
Execution timed out |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
138756 KB |
Execution timed out |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
21744 KB |
Execution timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
21712 KB |
Execution timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
22016 KB |
Execution timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
21744 KB |
Execution timed out |
2 |
Halted |
0 ms |
0 KB |
- |