Submission #914478

# Submission time Handle Problem Language Result Execution time Memory
914478 2024-01-22T08:48:34 Z abcvuitunggio Pyramid Base (IOI08_pyramid_base) C++17
10 / 100
5000 ms 95196 KB
#include <bits/stdc++.h>
using namespace std;
const int M=1000001,P=400001;
int m,n,b,p,x[P],y[P],u[P],v[P],c[P],s=1;
unsigned int st[M*4],sum[M*4];
vector <int> ve[M+1];
void update(int node, int l, int r, int u, int v, int val){
    if (l>v||r<u)
        return;
    if (l>=u&&r<=v){
        st[node]+=val;
        sum[node]+=val;
        return;
    }
    int mid=(l+r)>>1;
    update(node<<1,l,mid,u,v,val);
    update(node<<1|1,mid+1,r,u,v,val);
    st[node]=min(st[node<<1],st[node<<1|1])+sum[node];
}
bool check(int sz){
    for (int i=1;i<=m;i++)
        ve[i].clear();
    for (int i=1;i<=n*4;i++)
        st[i]=sum[i]=0;
    for (int i=1;i<=p;i++){
        int X=max(x[i]-sz+1,1);
        ve[X].push_back(i);
        ve[u[i]+1].push_back(-i);
    }
    for (int i=s;i<=m-sz+1;i++){
        for (int j:ve[i])
            update(1,1,n-sz+1,max(y[abs(j)]-sz+1,1),v[abs(j)],c[abs(j)]*(j<0?-1:1));
        if (st[1]<=b){
            s=i;
            return true;
        }
    }
    return false;
}
int main(){
    ios_base::sync_with_stdio(NULL);cin.tie(nullptr);
    cin >> m >> n >> b >> p;
    for (int i=1;i<=p;i++)
        cin >> x[i] >> y[i] >> u[i] >> v[i] >> c[i];
    int l=1,r=min(m,n),kq=0;
    while (l<=r){
        int mid=(l+r)>>1;
        if (check(mid)){
            kq=mid;
            l=mid+1;
        }
        else
            r=mid-1;
    }
    cout << kq;
}

Compilation message

pyramid_base.cpp: In function 'bool check(int)':
pyramid_base.cpp:33:18: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   33 |         if (st[1]<=b){
      |             ~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 35420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 35420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 35420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 37724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 40028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 146 ms 62296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 156 ms 62548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 37752 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 41556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 260 ms 66868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 299 ms 69248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 244 ms 67308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2432 ms 93096 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3874 ms 94368 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5019 ms 95196 KB Time limit exceeded
2 Halted 0 ms 0 KB -