Submission #854812

# Submission time Handle Problem Language Result Execution time Memory
854812 2023-09-29T03:08:10 Z vjudge1 Nuclearia (CEOI15_nuclearia) C++17
0 / 100
869 ms 887032 KB
#include<bits/stdc++.h>
#define pb push_back
#define pli pair<int,int>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxN=2e5;
const ll inf=1e18;
const ll mod=1e9+7;
ll h,w;
vector<vector<ll>> p1,p2,p3;
void add(ll x,ll y,ll a,ll b)
{
    ll r=(a-1)/b;
    if(x+r>w||x-r<1||y+r>h||y-r<1) return;
    // p1 p2 p3
    // p1 la prefix sum cho a
    // p2 la prefix sum cho b cheo 1
    // p3 la prefix sum cho b cheo 2
    p1[x-r][y-r]+=a-(r+1)*b;
    p1[x+r+1][y-r]-=a-(r+1)*b;
    p1[x-r][y+r+1]-=a-(r+1)*b;
    p1[x+r+1][y+r+1]+=a-(r+1)*b;

    p2[x-r][y-r]+=b;
    p2[x+r+2][y+r+2]-=b;

    p3[x-r][y+r+1]-=b;
    p3[x+r+2][y-r-1]+=b;

}
ll n;
using ld=long double;
ll get(ll x1,ll y1,ll x2,ll y2)
{
    return p1[x2][y2]-p1[x1-1][y2]-p1[x2][y1-1]+p1[x1-1][y1-1];
}
void solve()
{
    cin >> w >> h;
    p1.resize(w+10,vector<ll>(h+10));
    p2.resize(w+10,vector<ll>(h+10));
    p3.resize(w+10,vector<ll>(h+10));
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        ll x,y,a,b;
        cin >> x >> y >> a >> b;
        add(x,y,a,b);
    }
    for(int i=1;i<=w;i++)
    {
        for(int j=1;j<=h;j++)
        {
            p2[i][j]+=p2[i-1][j-1];
        }
    }
    for(int i=1;i<=w;i++)
    {
        for(int j=h;j>=1;j--)
        {
            p3[i][j]+=p3[i-1][j+1];
        }
    }
    for(int i=1;i<=w;i++)
    {
        for(int j=1;j<=h;j++)
        {
            p2[i][j]+=p3[i][j];
        }
    }
    for(int i=1;i<=w;i++)
    {
        for(int j=1;j<=h;j++)
        {
            p2[i][j]+=p2[i-1][j];
        }
    }
    for(int i=1;i<=w;i++)
    {
        for(int j=1;j<=h;j++)
        {
            p2[i][j]+=p2[i][j-1];
        }
    }
    for(int i=1;i<=w;i++)
    {
        for(int j=1;j<=h;j++) p1[i][j]+=p1[i-1][j];
    }
    for(int i=1;i<=w;i++) for(int j=1;j<=h;j++) p1[i][j]+=p1[i][j-1];
    for(int i=1;i<=w;i++) for(int j=1;j<=h;j++) p1[i][j]+=p2[i][j];
    for(int i=1;i<=w;i++)
    {
        for(int j=1;j<=h;j++)
        {
            p1[i][j]+=p1[i-1][j]+p1[i][j-1]-p1[i-1][j-1];
        }
    }
    ll q;
    cin >> q;
    for(int i=1;i<=q;i++)
    {
        ll x1,y1,x2,y2;
        cin >> x1 >> y1 >> x2 >> y2;
        cout << round((ld)get(x1,y1,x2,y2)/((x2-x1+1)*(y2-y1+1)))<<'\n';
    }
}
int main()
{
    fastio
    //freopen(TASKNAME".INP","r",stdin);
    //freopen(TASKNAME".OUT","w",stdout);
    solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 756 ms 880876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 687 ms 880908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 61016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 89476 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 823 ms 884672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 438 ms 355832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 204 ms 63932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 337 ms 203056 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 869 ms 886952 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 856 ms 887032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 323 ms 68668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 329 ms 68184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 266 ms 70868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 294 ms 68544 KB Output isn't correct
2 Halted 0 ms 0 KB -