# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
968792 | 2024-04-24T05:08:03 Z | vjudge1 | Pyramid Base (IOI08_pyramid_base) | C++17 | 1062 ms | 262144 KB |
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize(2) #include<bits/extc++.h> using namespace __gnu_pbds; #define N 1<<19 int S[4*N],B[4*N],n,m,p,b,A[N],B2[N],C[N],D[N],W[N],something[N]; void reset(int i,int l,int r){ S[i]=B[i]=0; if(l==r) return; reset(i*2,l,l+r>>1); reset(i*2+1,l+r+2>>1,r); } void add(int i,int l,int r,int pos,int x){ if(l==r) return void(S[i]=B[i]+=x); if(pos>l+r>>1) add(i*2+1,l+r+2>>1,r,pos,x); else add(i*2,l,l+r>>1,pos,x); S[i]=S[i*2]+S[i*2+1]; B[i]=min(B[i*2],S[i*2]+B[i*2+1]); } gp_hash_table<int,int>pref[2*N]; bool check(int k){ for(int i=0;i<p;i++){ int a=max(1,A[i]-k+1); int b=max(1,B2[i]-k+1); int c=min(C[i],n-k+1)+1; int d=min(D[i],m-k+1)+1; pref[a][b]+=W[i]; pref[a][d]-=W[i]; pref[c][b]-=W[i]; pref[c][d]+=W[i]; something[a]=something[c]=1; } something[1]=1; reset(1,1,m-k+1); if(pref[1].empty()) return 1; for(int i=1;i<n-k+2;i++){ if(something[i]) for(auto [x,w]:pref[i]) if(x<=m-k+1) add(1,1,m-k+1,x,w); if(B[1]<=b) return 1; } for(int i=1;i<n-k+2;i++) if(something[i]) pref[i].clear(), something[i]=0; return 0; } signed main(){ long long XXX=chrono::steady_clock::now().time_since_epoch().count(); cin.tie(0)->sync_with_stdio(0); cin>>n>>m>>b>>p; b=min(b,p*7000); for(int i=0;i<p;i++) cin>>A[i]>>B2[i]>>C[i]>>D[i]>>W[i]; if(!b) for(int i=0;i<p;i++) W[i]=1; int l=0,r=min(n,m); while(l<r){ int mid=l+r+1>>1; if(check(mid)) l=mid; else r=mid-1; cerr<<"DONE1\n"; } cout<<l<<'\n'; long long YYY=chrono::steady_clock::now().time_since_epoch().count(); cerr<<"Took: "<<(YYY-XXX)/1e9<<'s'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 139 ms | 221944 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 129 ms | 222032 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 142 ms | 222124 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 147 ms | 222540 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 164 ms | 224812 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 168 ms | 232272 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 225 ms | 242452 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 150 ms | 223060 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 347 ms | 229804 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 519 ms | 239828 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1062 ms | 253400 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 707 ms | 243228 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 512 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 649 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 382 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |