Submission #926751

# Submission time Handle Problem Language Result Execution time Memory
926751 2024-02-13T16:15:29 Z math_rabbit_1028 Pyramid Base (IOI08_pyramid_base) C++14
5 / 100
1219 ms 128640 KB
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

int M, N, P;
array<int, 5> arr[404040];
ll B;

struct segtree {
    int cnt[1<<21], mx[1<<21], l[1<<21], r[1<<21], sz[1<<21];
    void init(int v, int st, int ed) {
        if (st == ed) {
            cnt[v] = 0;
            mx[v] = l[v] = r[v] = 1;
            sz[v] = 1;
            return;
        }
        int mid = (st+ed)/2;
        init(2*v, st, mid);
        init(2*v+1, mid+1, ed);
        cnt[v] = 0;
        mx[v] = l[v] = r[v] = ed-st+1;
        sz[v] = ed-st+1;
    }
    void update(int v, int st, int ed, int lt, int rt, int val) {
        if (lt > ed || st > rt) return;
        if (lt <= st && ed <= rt) {
            cnt[v] += val;
            if (cnt[v] > 0) mx[v] = l[v] = r[v] = 0;
            else mx[v] = l[v] = r[v] = 1;
            return;
        }
        int mid = (st+ed)/2;
        update(2*v, st, mid, lt, rt, val);
        update(2*v+1, mid+1, ed, lt, rt, val);
        if (cnt[v] > 0) mx[v] = l[v] = r[v] = 0;
        else {
            if (mx[2*v] == sz[2*v]) l[v] = l[2*v+1] + sz[2*v];
            else l[v] = l[2*v];
            if (mx[2*v+1] == sz[2*v+1]) r[v] = r[2*v] + sz[2*v+1];
            else r[v] = r[2*v+1];
            mx[v] = max(mx[2*v], mx[2*v+1]);
            mx[v] = max(mx[v], r[2*v]+l[2*v+1]);
        }
        // cout << st << " " << ed << " " << mx[v] << " " << l[v] << " " << r[v] << "\n";
    }
} seg;

vector<array<int, 3>> add[1010101], rem[1010101];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> M >> N;
    cin >> B >> P;
    for (int i = 1; i <= P; i++) {
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2] >> arr[i][3] >> arr[i][4];
    }
    
    seg.init(1, 1, N);
    
    for (int i = 1; i <= P; i++) {
        add[arr[i][0]].push_back({arr[i][1], arr[i][3], +1});
        rem[arr[i][2]+1].push_back({arr[i][1], arr[i][3], -1});
    }
    
    int p = 1, q = 0, ans = 0;
    while (q <= M) {
        //cout << p << " " << q << " " << seg.mx[1] << "\n";
        if (seg.mx[1] >= q-p+1) {
            ans = max(ans, q-p+1);
            q++;
            for (auto &[l, r, w] : add[q]) seg.update(1, 1, N, l, r, w);
        }
        else {
            p++;
            for (auto &[l, r, w] : rem[p]) seg.update(1, 1, N, l, r, w);
        }
    }

    cout << ans << "\n";

    return 0;
}

Compilation message

pyramid_base.cpp: In function 'int main()':
pyramid_base.cpp:76:24: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   76 |             for (auto &[l, r, w] : add[q]) seg.update(1, 1, N, l, r, w);
      |                        ^
pyramid_base.cpp:80:24: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   80 |             for (auto &[l, r, w] : rem[p]) seg.update(1, 1, N, l, r, w);
      |                        ^
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 59988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 59996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 59996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 60128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 59996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 90964 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 90968 KB Output is correct
2 Incorrect 31 ms 90964 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 60488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 61276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 92712 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 93008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 99 ms 93612 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 453 ms 109956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 600 ms 119392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 749 ms 128640 KB Output is correct
2 Correct 1219 ms 127240 KB Output is correct
3 Correct 1010 ms 126916 KB Output is correct
4 Incorrect 772 ms 125552 KB Output isn't correct
5 Halted 0 ms 0 KB -