Submission #867273

# Submission time Handle Problem Language Result Execution time Memory
867273 2023-10-28T04:50:49 Z Faisal_Saqib Nuclearia (CEOI15_nuclearia) C++17
30 / 100
1000 ms 119992 KB
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <fstream>
using namespace std;

#define vll vector<ll>
#define sll set<ll>
#define vstr vector<string>
#define ll long long
#define ld long double
#define supra main
#define pb push_back
#define add insert
#define rall(x) rbegin(x),rend(x)
#define all(x) (x).begin(),(x).end()
#define I ios_base::sync_with_stdio(false);
#define Hear cin.tie(NULL);
#define Shots cout.tie(NULL);
#define Ratatatata
ll powmod(ll a,ll b,ll modulo)
{
  if(b==0){
    return 1;
  }
  ll temp=powmod(a,b/2,modulo);
  if(b%2==0){
    return (temp*temp)%modulo;
  }
  else{
    return (a*((temp*temp)%modulo))%modulo;
  }
}
inline ll read() {
    char c = getchar();
    ll x = 0, s = 1;
    while (c < '0' || c > '9') {
        if (c == '-')
            s = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * s;
}
bool Prime(ll n){
    if (n <= 1)
        return false;
    for (ll i = 2; i <= sqrt(n); i++)
        if (n % i == 0)
            return false;
 
    return true;
}
void solve()
{
    ll m=read(),n=read();
    ll p=read();
    vector<vll> grid(n+2,vll(m+2));
    auto pre=grid;
    for(int i=0;i<p;i++)
    {
        ll y=read(),x=read(),a=read(),b=read();
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
            {
                grid[i][j]+=max(0ll,a-b*(max(abs(i-x),abs(j-y))));
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            pre[i][j]=(pre[i][j-1]+pre[i-1][j]+grid[i][j]-pre[i-1][j-1]);
        }
    }
    ll q=read();
    while(q--)
    {
        ll y1=read(),x1=read(),y2=read(),x2=read();
        ll sum=0,cell=(y2-y1+1)*(x2-x1+1);
        sum=pre[x2][y2]-pre[x1-1][y2]-pre[x2][y1-1]+pre[x1-1][y1-1];
        ld cur=((ld)sum/(ld)cell);
        cur+=0.5;
        cout<<(ll)cur<<endl;
    }
}
int supra(){
    I Hear Shots Ratatatata
    cout<<setprecision(1000);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ll tqwertyuiop=1;
    // cin>>tqwertyuiop;
    for(int tp=1;tp<=tqwertyuiop;tp++)
    {
        // cout<<"Case #"<<tp<<": ";
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 126 ms 117804 KB Output is correct
2 Correct 253 ms 2824 KB Output is correct
3 Correct 226 ms 2388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 120 ms 117764 KB Output is correct
2 Correct 233 ms 2616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 117 ms 39812 KB Output is correct
2 Correct 243 ms 2748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 130 ms 53288 KB Output is correct
2 Correct 248 ms 2792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 329 ms 119992 KB Output is correct
2 Correct 240 ms 3036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 372 ms 49644 KB Output is correct
2 Correct 271 ms 2912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 403 ms 42340 KB Output is correct
2 Correct 239 ms 2980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 368 ms 33948 KB Output is correct
2 Correct 231 ms 2756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1022 ms 117768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 117628 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 39772 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1040 ms 39768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1022 ms 41304 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1027 ms 39768 KB Time limit exceeded
2 Halted 0 ms 0 KB -