Submission #993709

# Submission time Handle Problem Language Result Execution time Memory
993709 2024-06-06T10:31:15 Z codefox Pyramid Base (IOI08_pyramid_base) C++14
35 / 100
5000 ms 86560 KB
#include<bits/stdc++.h>

using namespace std;

#define pii pair<int,int>
#define arr array<int, 5>

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

int N = 1<<20;

vector<short> bmin(2*N, 0);
vector<short> badd(2*N, 0);

void update(int curr, int l, int r, int a, int b, int add, int dd)
{
    if (r<=a || l>=b) 
    {
        bmin[curr] += add;
        badd[curr] += add;
        return;
    }
    if (a<=l && r<=b)
    {
        add+=dd;
        bmin[curr] += add;
        badd[curr] += add;
        return;
    }
    int m = (l+r)/2;
    add+=badd[curr];
    badd[curr] = 0;
    update(curr*2, l, m, a, b, add, dd);
    update(curr*2+1, m, r, a, b, add, dd);
    bmin[curr] = min(bmin[curr*2], bmin[curr*2+1]);
}

int finde(int pos)
{
    int curr = 1;
    short add = 0;
    for (int i = 19; i >= 0; i--)
    {
        add += badd[curr];
        curr*=2;
        if (pos < (1<<i)) continue;
        pos -= 1<<i;
        if(bmin[curr]+add==0) return 0;
        curr++;
    }
    return 1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int x, y;
    cin >> x >> y;
    int b, n;
    cin >> b >> n;

    vector<arr> ele(n);
    for (int i= 0; i < n; i++)
    {
        int x1, y1, x2, y2, c;
        cin >> x1 >> y1 >> x2 >> y2 >> c;
        x1--; y1--; x2--; y2--;
        c=1;
        ele[i] = {x1, y1, x2, y2, c};
    }

    int sum = 0;
    for (int i = 19; i >= 0; i--)
    {
        sum += 1<<i;
        vector<vector<arr>> begin(1e6);
        vector<vector<arr>> ende(1e6);
        bmin.assign(2*N, 0);
        badd.assign(2*N, 0);
        for (int j = 0; j < n; j++)
        {
            begin[max(0, ele[j][0]-sum+1)].push_back({max(0, ele[j][1]-sum+1), ele[j][3], ele[j][4]});
            ende[ele[j][2]].push_back({max(0, ele[j][1]-sum+1), ele[j][3], ele[j][4]});
        }
        int mn = 2*1e9+1;
        for (int j = 0; j < x-sum+1; j++)
        {
            for (arr ele2:begin[j])  update(1, 0, N, ele2[0], ele2[1]+1, 0, ele2[2]);
            mn = min(mn, finde(y-sum+1));
            for (arr ele2:ende[j]) 
            {
                update(1, 0, N, ele2[0], ele2[1]+1, 0, -ele2[2]);
            }
        }
        if (mn > b) sum -= 1<<i;
    }
    cout << sum;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 165 ms 55736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 154 ms 55756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 160 ms 55676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 160 ms 55672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 212 ms 55736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 297 ms 55648 KB Output is correct
2 Correct 527 ms 55748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 538 ms 55632 KB Output is correct
2 Correct 287 ms 55728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 235 ms 56224 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 210 ms 57364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 318 ms 57856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 342 ms 58280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 471 ms 60972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5006 ms 74520 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5036 ms 79332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5015 ms 86560 KB Time limit exceeded
2 Halted 0 ms 0 KB -