#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
765 ms |
137228 KB |
Output is correct |
2 |
Correct |
95 ms |
4636 KB |
Output is correct |
3 |
Correct |
80 ms |
3768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
768 ms |
137244 KB |
Output is correct |
2 |
Correct |
96 ms |
4544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
303 ms |
20060 KB |
Output is correct |
2 |
Correct |
90 ms |
4316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
272 ms |
20916 KB |
Output is correct |
2 |
Correct |
89 ms |
4548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1091 ms |
137288 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
55108 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1095 ms |
20036 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
27708 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1098 ms |
137224 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1103 ms |
137200 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1090 ms |
20020 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
19916 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1088 ms |
20484 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1088 ms |
20044 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |