답안 #926478

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
926478 2024-02-13T05:34:24 Z math_rabbit_1028 Pyramid Base (IOI08_pyramid_base) C++14
0 / 100
4889 ms 262144 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 tree[1<<21], lazy[1<<21];
    void init(int v, int st, int ed) {
        if (st == ed) {
            tree[v] = 0;
            lazy[v] = 0;
            return;
        }
        int mid = (st+ed)/2;
        init(2*v, st, mid);
        init(2*v+1, mid+1, ed);
        tree[v] = min(tree[2*v], tree[2*v+1]);
        lazy[v] = 0;
    }
    void prop(int v, int st, int ed) {
        tree[v] += lazy[v];
        if (st != ed) {
            lazy[2*v] += lazy[v];
            lazy[2*v+1] += lazy[v];
        }
        lazy[v] = 0;
    }
    void update(int v, int st, int ed, int lt, int rt, int val) {
        prop(v, st, ed);
        if (lt > ed || st > rt) return;
        if (lt <= st && ed <= rt) {
            lazy[v] = val;
            prop(v, st, ed);
            return;
        }
        int mid = (st+ed)/2;
        update(2*v, st, mid, lt, rt, val);
        update(2*v+1, mid+1, ed, lt, rt, val);
        tree[v] = min(tree[2*v], tree[2*v+1]);
        cout << st << " " << ed << " " << lt << " " << rt << " " << tree[v] << " " << tree[2*v] << " " << tree[2*v+1] << "\n";
    }
    int get(int v, int st, int ed, int lt, int rt) {
        prop(v, st, ed);
        if (lt > ed || st > rt) return 1e9;
        if (lt <= st && ed <= rt) return tree[v];
        int mid = (st+ed)/2;
        return min(get(2*v, st, mid, lt, rt), get(2*v+1, mid+1, ed, lt, rt));
    }
} seg;

vector<pii> add[1010101], rem[1010101];
bool solve(int L) {
    cout << "length: " << L << "\n";
    for (int i = 0; i <= M; i++) add[i].clear();
    for (int i = 0; i <= M; i++) rem[i].clear();
    seg.init(1, 0, N-L);
    for (int i = 1; i <= P; i++) {
        cout << arr[i][0]-L << " " << arr[i][2]-1 << " ";
        cout << arr[i][1]-L << " " << arr[i][3]-1 << "\n";
        if (arr[i][0]-L < 0) seg.update(1, 0, N-L, arr[i][1]-L, arr[i][3]-1, +1);
        else add[arr[i][0]-L].push_back({arr[i][1]-L, arr[i][3]-1});
        rem[arr[i][2]].push_back({arr[i][1]-L, arr[i][3]-1});
    }
    
    for (int i = 0; i <= M-L; i++) {
        for (auto &[l, r] : add[i]) seg.update(1, 0, N-L, l, r, +1);
        for (auto &[l, r] : rem[i]) seg.update(1, 0, N-L, l, r, -1);
        if (seg.get(1, 0, N-L, 0, N-L) == 0) return true;
    }
    //for (int i = 0; i <= N-L; i++) cout << i << " " << seg.get(1, 0, N-L, i, i) << "\n";
    cout << N-L << " " << seg.get(1, 0, N-L, 0, N-L) << "\n"; 
    return false;
}

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];
    }

    int st = 0, ed = min(M, N);
    while (st < ed) {
        int mid = (st+ed+1)/2;
        if (solve(mid)) st = mid;
        else ed = mid-1;
    }
    cout << st << "\n";

    return 0;
}

Compilation message

pyramid_base.cpp: In function 'bool solve(int)':
pyramid_base.cpp:72:20: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   72 |         for (auto &[l, r] : add[i]) seg.update(1, 0, N-L, l, r, +1);
      |                    ^
pyramid_base.cpp:73:20: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   73 |         for (auto &[l, r] : rem[i]) seg.update(1, 0, N-L, l, r, -1);
      |                    ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 53848 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 53852 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 48 ms 55996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 66 ms 57424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 214 ms 69292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 190 ms 70000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 709 ms 105136 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 742 ms 107416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4889 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4298 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4280 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3430 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4025 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2112 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4245 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -