/*
بسم الله الرحمن الرحيم
Author:
(:Muhammad Aneeq:)
*/
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <cmath>
using namespace std;
#define int long long
inline void solve()
{
int h,w;
cin>>h>>w;
int a[h][w]={};
int x;
cin>>x;
while (x--)
{
int i,j,y,z;
cin>>i>>j>>y>>z;
i--;j--;
for (int k=max(0LL,i-((y+z-1)/z)+1);k<=min(h-1,i+((y+z-1)/z+1));k++)
{
for (int l=max(0LL,j-((y+z-1)/z)+1);l<=min(w-1,j+((y+z-1)/z+1));l++)
{
a[k][l]+=max(0LL,y-z*max(abs(k-i),abs(l-j)));
}
}
}
int pre[h+1][w+1]={};
for (int i=0;i<h;i++)
{
for (int j=0;j<w;j++)
{
pre[i+1][j+1]=pre[i+1][j]+pre[i][j+1]-pre[i][j]+a[i][j];
}
}
int q;
cin>>q;
while (q--)
{
int a,b,c,d;
cin>>a>>b>>c>>d;
int f=pre[c][d]-pre[c][b-1]-pre[a-1][d]+pre[a-1][b-1];
long double g=(c-a+1)*(d-b+1);
cout<<round(f/g)<<'\n';
}
}
signed main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
287 ms |
59128 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
251 ms |
58964 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
94 ms |
39448 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
98 ms |
40528 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
278 ms |
61496 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
418 ms |
26176 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
277 ms |
42016 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
354 ms |
22284 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1044 ms |
19804 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1057 ms |
19804 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1046 ms |
19804 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1033 ms |
19804 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1057 ms |
19800 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1060 ms |
19804 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |