답안 #592646

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
592646 2022-07-09T12:01:58 Z andrei_boaca Nuclearia (CEOI15_nuclearia) C++14
21 / 100
1000 ms 873428 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
typedef long long ll;
typedef long double ld;
vector<vector<ll>> v,s;
vector<array<int,4>> vals;
int n,m,k,q;
int nradds=0;
void add(int x1,int y1,int x2,int y2,ll val)
{
    nradds++;
    x1=max(x1,1);
    y1=max(y1,1);
    x2=min(x2,n);
    y2=min(y2,m);
    v[x1][y1]+=val;
    v[x2+1][y1]-=val;
    v[x1][y2+1]-=val;
    v[x2+1][y2+1]+=val;
}
ll getsum(int x1,int y1,int x2,int y2)
{
    return s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m>>k;
    v.resize(n+5);
    s.resize(n+5);
    for(int i=0;i<=n+4;i++)
    {
        v[i].resize(m+5);
        s[i].resize(m+5);
    }
    assert(k*max(n,m)<=1e8);
    for(int z=1;z<=k;z++)
    {
        int x,y,a,b;
        cin>>x>>y>>a>>b;
        int nr=a;
        int x1=x,y1=y,x2=x,y2=y;
        vals.clear();
        int cnt=0;
        while(nr>0&&!(x1<=0&&y1<=0&&x2>n&&y2>m))
        {
            vals.push_back({x1,y1,x2,y2});
            nr-=b;
            cnt++;
            x1--;
            x2++;
            y1--;
            y2++;
            if(x1<=0&&y1<=0&&x2>n&&y2>m)
                break;
        }
        cnt--;
        //cout<<v[1][1]<<' ';
        reverse(vals.begin(),vals.end());
        add(vals[0][0],vals[0][1],vals[0][2],vals[0][3],a);
        add(vals[0][0],vals[0][1],vals[0][2],vals[0][3],-cnt*b);
        for(int i=1;i<vals.size();i++)
        {
            add(vals[i][0],vals[i][1],vals[i][2],vals[i][3],b);
            //cout<<v[1][1]<<' ';
        }
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            v[i][j]+=v[i-1][j]+v[i][j-1]-v[i-1][j-1];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            s[i][j]=v[i][j]+s[i-1][j]+s[i][j-1]-s[i-1][j-1];
            //cout<<s[i][j]<<' ';
        }
    //assert(nradds<=k*max(n,m));
    cin>>q;
    while(q--)
    {
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        ll suma=getsum(x1,y1,x2,y2);
        ll cells=(y2-y1+1)*(x2-x1+1);
        ll rez=round(ld(suma)/ld(cells));
        cout<<rez<<'\n';
    }
    return 0;
}

Compilation message

nuclearia.cpp: In function 'int main()':
nuclearia.cpp:64:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 4> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |         for(int i=1;i<vals.size();i++)
      |                     ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1094 ms 496688 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1094 ms 496604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 40404 KB Output is correct
2 Correct 61 ms 2708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 51588 KB Output is correct
2 Correct 63 ms 2736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 920 ms 496644 KB Output is correct
2 Correct 83 ms 5340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1103 ms 189052 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 122 ms 42444 KB Output is correct
2 Correct 64 ms 2864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 897 ms 100136 KB Output is correct
2 Correct 80 ms 4288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 635 ms 873388 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 652 ms 873428 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 53 ms 81296 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 51 ms 80604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1074 ms 42616 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 57 ms 81228 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -