Submission #965582

# Submission time Handle Problem Language Result Execution time Memory
965582 2024-04-19T00:42:47 Z idiotcomputer Pyramid Base (IOI08_pyramid_base) C++11
0 / 100
583 ms 38228 KB
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define f first
#define s second 

const int mxP = 4e5;
const int mxN = 1e6;
int n,m;

int segtree[4*mxN+1];
int laz[4*mxN+1];
int curr;

void build(int l = 0, int r = n-1, int idx = 0){
    if (r+1<curr){
        segtree[idx] = m+1;
        laz[idx] = m+1;
        return;
    }
    segtree[idx] = 0;
    laz[idx] = 0;
    if (l == r) return;
    int m = (l+r)/2;
    build(l,m,2*idx+1);
    build(m+1,r,2*idx+2);
}

void upd(int tl, int tr, int v, int l = 0, int r = n-1, int idx = 0){
    if (l > tr || r < tl || r+1<curr) return;
    if (l >= tl && r <= tr){
        laz[idx] = v;
        return;
    }
    laz[2*idx+1] = laz[idx];
    laz[2*idx+2] = laz[idx];
    laz[idx] = 0;
    int m = (l+r)/2;
    upd(tl,tr,v,l,m,2*idx+1);
    upd(tl,tr,v,m+1,r,2*idx+2);
    segtree[idx] = min(max(segtree[2*idx+1],laz[2*idx+1]),max(segtree[2*idx+2],laz[2*idx+2]));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int b,p;
    cin >> m >> n >> b >> p;
    
    
    int r[p];
    pii y[p];
    vector<pii> vals(p);
    int x1,y1,x2,y2,c1;
    for (int i =0; i < p; i++){
        cin >> x1 >> y1 >> x2 >> y2 >> c1;
        x1 -= 1;
        y1 -= 1;
        x2 -= 1;
        y2 -= 1;
        r[i] = x2;
        y[i] = {y1,y2};
        vals[i] = {x1,i};
    }
    if (b > 0){
        cout << "-1\n";
        return 0;
    }
    sort(vals.begin(),vals.end());
    
    int start = 0;
    int end = min(n,m)+1;
    bool w;
    int best;
    while (end - start > 1){
        curr = (start+end)/2;
        build();
        w = false;
    //    cout << curr << ": ";
        for (int i = 0; i < p; i++){
           // cout << vals[i].s << " - " << vals[i].f << " " << r[vals[i].s] << " " << y[vals[i].s].f << ',' << y[vals[i].s].s << "  ";
            best = max(laz[0],segtree[0]);
            if (vals[i].f-best >= curr){
                w = true;
                break;
            }
            upd(y[vals[i].s].f,min(n-1,y[vals[i].s].s+curr-1),r[vals[i].s]+1);
        }
        //cout << '\n';
        best = max(laz[0],segtree[0]);
        if (m-best >= curr) w = true;
        if (w) start = curr;
        else end = curr;
    }
    cout << start << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 19036 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 19036 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1240 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1812 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 303 ms 28500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 421 ms 33332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 583 ms 38228 KB Output isn't correct
2 Halted 0 ms 0 KB -