Submission #813230

# Submission time Handle Problem Language Result Execution time Memory
813230 2023-08-07T14:25:58 Z JakobZorz Nuclearia (CEOI15_nuclearia) C++14
30 / 100
1000 ms 22568 KB
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <stack>
#include <limits.h>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <cstring>
#include <sstream>
 
#pragma GCC target("popcnt")
 
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD=1e9+7;
typedef pair<ll,ll>point;
//#define x first
//#define y second

vector<ll>map_arr;
int w,h;

void init_map(){
    map_arr.resize(w*h);
}

ll get2(int x,int y){
    if(x<0||y<0)
        return 0;
    return map_arr[y*w+x];
}

ll&get(int x,int y){
    return map_arr[y*w+x];
}
 
int main(){
    ios::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);
    
    cin>>w>>h;
    init_map();
    int n;
    cin>>n;
    while(n--){
        int x1,y1;
        ll center,step;
        cin>>x1>>y1>>center>>step;
        x1--;y1--;
        
        for(int x=0;x<w;x++)
            for(int y=0;y<h;y++){
                int dist=max(abs(x1-x),abs(y1-y));
                ll val=max(0LL,center-dist*step);
                get(x,y)+=val;
            }
    }
    
    for(int x=0;x<w;x++)
        for(int y=0;y<h;y++)
            get(x,y)+=get2(x-1,y)+get2(x,y-1)-get2(x-1,y-1);
    
    int q;
    cin>>q;
    while(q--){
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        x1--;y1--;
        
        ll sum=get2(x2-1,y2-1)+get2(x1-1,y1-1)-get2(x1-1,y2-1)-get2(x2-1,y1-1);
        
        ll area=(x2-x1)*(y2-y1);
        ll res=sum/area;
        if((sum%area)*2 >= area)
            res++;
        cout<<res<<"\n";
    }

    return 0;
}

/*
 
4 3
2
1 1 7 3
3 2 4 2
4
1 2 2 3
1 1 4 3
4 2 4 2
1 3 4 3
 
 */
# Verdict Execution time Memory Grader output
1 Correct 217 ms 19844 KB Output is correct
2 Correct 47 ms 2880 KB Output is correct
3 Correct 45 ms 2524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 233 ms 19796 KB Output is correct
2 Correct 60 ms 2972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 191 ms 19900 KB Output is correct
2 Correct 70 ms 2956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 849 ms 19796 KB Output is correct
2 Correct 48 ms 2920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 151 ms 22428 KB Output is correct
2 Correct 66 ms 5216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 251 ms 10836 KB Output is correct
2 Correct 69 ms 4592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 888 ms 22568 KB Output is correct
2 Correct 50 ms 4852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 229 ms 11004 KB Output is correct
2 Correct 57 ms 4388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 19796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 19796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 19796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 19796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 19796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1066 ms 19788 KB Time limit exceeded
2 Halted 0 ms 0 KB -