/*
بسم الله الرحمن الرحيم
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--;
a[i][j]+=y;
for (int k=0;k<y/z+(y%z!=0);k++)
{
for (int l=0;l<y/z+(y%z!=0);l++)
{
if (k==0&&l==0)
continue;
if (i-k>=0)
{
if (j-l>=0)
a[i-k][j-l]+=y-z*max(k,l);
if (j+l<w&&l!=0)
a[i-k][j+l]+=y-z*max(k,l);
}
if (i+k<h&&k!=0)
{
if (j-l>=0)
a[i+k][j-l]+=y-z*max(k,l);
if (j+l<w&&l!=0)
a[i+k][j+l]+=y-z*max(k,l);
}
}
}
}
long long 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<<(long long)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 |
Execution timed out |
1037 ms |
19800 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1054 ms |
19804 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1028 ms |
19800 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1024 ms |
20216 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1014 ms |
19800 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1057 ms |
8028 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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1024 ms |
8024 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1020 ms |
19800 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1028 ms |
19800 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1010 ms |
20056 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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1064 ms |
19804 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1044 ms |
19800 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |