# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
592637 | 2022-07-09T11:48:56 Z | andrei_boaca | Nuclearia (CEOI15_nuclearia) | C++14 | 1000 ms | 496756 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; vector<vector<ll>> v,s; ll n,m,k,q; void add(array<int,4> p,ll val) { int x1=p[0],y1=p[1],x2=p[2],y2=p[3]; x1=max(x1,1); y1=max(y1,1); x2=min(x2*1LL,n); y2=min(y2*1LL,m); v[x1][y1]+=val; v[x2+1][y1]-=val; v[x1][y2+1]-=val; v[x2+1][y2+1]+=val; } ll getsum(ll x1,ll y1,ll x2,ll 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); } for(int z=1;z<=k;z++) { ll x,y,a,b; cin>>x>>y>>a>>b; ll nr=a; ll x1=x,y1=y,x2=x,y2=y; vector<array<int,4>> vals; ll cnt=0; while(nr>0) { 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--; add(vals.back(),a); add(vals.back(),-cnt*b); //cout<<v[1][1]<<' '; reverse(vals.begin(),vals.end()); for(int i=1;i<vals.size();i++) { add(vals[i],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]<<' '; } 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1111 ms | 496564 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1102 ms | 480388 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 40404 KB | Output is correct |
2 | Correct | 70 ms | 4344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 123 ms | 53416 KB | Output is correct |
2 | Correct | 59 ms | 4556 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1106 ms | 496756 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1095 ms | 204032 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 134 ms | 45724 KB | Output is correct |
2 | Correct | 63 ms | 4820 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1102 ms | 102504 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1110 ms | 461500 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1116 ms | 461468 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 798 ms | 49560 KB | Output is correct |
2 | Execution timed out | 1097 ms | 42992 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1079 ms | 43196 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1082 ms | 43380 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1080 ms | 40980 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |