Submission #867275

#TimeUsernameProblemLanguageResultExecution timeMemory
867275UmairAhmadMirzaNuclearia (CEOI15_nuclearia)C++14
11 / 100
1058 ms45392 KiB
//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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...