Submission #867275

# Submission time Handle Problem Language Result Execution time Memory
867275 2023-10-28T04:51:18 Z UmairAhmadMirza Nuclearia (CEOI15_nuclearia) C++14
11 / 100
1000 ms 45392 KB
//In the name of Allah the most beneficent, the most merciful.
#include <bits/stdc++.h>

using namespace std;

// #pragma GCC optimize("Ofast,unroll-loops") 
// #pragma GCC target("avx,avx2,avx512,fma") 
#define int long long
#define ar array
#define ll long long
#define ld long double
#define sza(x) ((int)x.size())
#define all(a) (a).begin(), (a).end()

#define PI 3.1415926535897932384626433832795l 
const int N = 3e5;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ld EPS = 1e-9;

// -------------------------<RNG>------------------------- 
// RANDOM NUMBER GENERATOR
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());  
#define SHUF(v) shuffle(all(v), RNG); 
// Use mt19937_64 for 64 bit random numbers.
//--------------------------------------------------------
vector<int> grid[N];
int n,m;
int k;
int bomb[N][4];//k bombs
int calculate(int x,int y){
	int sm=0;
	for(int i=0;i<k;i++)
		sm+=max(0LL,bomb[i][2]-(bomb[i][3]*max(abs(x-bomb[i][0]),abs(y-bomb[i][1]))));
	return sm;
}
void solve() {
    cin>>n>>m;
    for(int i=0;i<=n;i++)
    	for(int j=0;j<=m;j++)
    		grid[i].push_back(0);
    cin>>k;
    for(int i=0;i<k;i++)
    	cin>>bomb[i][0]>>bomb[i][1]>>bomb[i][2]>>bomb[i][3];
    for(int i=1;i<=n;i++)
    	for(int j=1;j<=m;j++){
    		grid[i][j]=calculate(i,j);
    		grid[i][j]-=grid[i-1][j-1];
    		grid[i][j]+=grid[i-1][j]+grid[i][j-1];
    	}
    int q;
    cin>>q;
    while(q--){
    	int x1,y1,x2,y2;
    	cin>>x1>>y1>>x2>>y2;
    	x1--;
    	y1--;
    	int sm=grid[x2][y2];
    	sm-=grid[x1][y2]+grid[x2][y1];
    	sm+=grid[x1][y1];
    	int mem=(x2-x1)*(y2-y1);
    	int ans=sm/mem;
    	sm%=mem;
    	if(sm*2>=mem)
    		ans++;
    	cout<<ans<<endl;
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("billboard.in", "r", stdin);
	// freopen("billboard.out", "w", stdout);
    int tc = 1;
    // cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 33 ms 35920 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 33 ms 35824 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 210 ms 28608 KB Output is correct
2 Correct 257 ms 10832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 194 ms 29600 KB Output is correct
2 Correct 260 ms 10912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 35928 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 34 ms 35932 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 499 ms 32592 KB Output is correct
2 Correct 287 ms 11604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 45 ms 45392 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 33 ms 35920 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 33 ms 35752 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1033 ms 38992 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1020 ms 38992 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 38980 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1058 ms 38744 KB Time limit exceeded
2 Halted 0 ms 0 KB -