Submission #159312

# Submission time Handle Problem Language Result Execution time Memory
159312 2019-10-22T09:46:17 Z TAISA_ Wall (IOI14_wall) C++14
8 / 100
181 ms 8160 KB
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Segtree {
    int n;
    vector<int> s1, s2;
    Segtree(int n_) {
        n = 1;
        while (n < n_) {
            n <<= 1;
        }
        s1.resize(2 * n, 0);
        s2.resize(2 * n, 998244353);
    }
    void upd(int a, int b, P x, int t, int k, int l, int r) {
        if (b <= l || r <= a) {
            return;
        }
        if (a <= l && r <= b) {
            if (x.second == 1) {
                if (s1[k] < x.first) {
                    s1[k] = x.first;
                }
            } else {
                if (s2[k] > x.first) {
                    s2[k] = x.first;
                }
            }
            return;
        }
        upd(a, b, x, t, k << 1, l, (l + r) >> 1);
        upd(a, b, x, t, k << 1 | 1, (l + r) >> 1, r);
    }
    void upd(int a, int b, P x, int t) { upd(a, b, x, t, 1, 0, n); }
    pair<int, int> get(int k) {
        k += n;
        int r1 = s1[k], r2 = s2[k];
        k >>= 1;
        while (k > 0) {
            r1 = max(r1, s1[k]);
            r2 = min(r2, s2[k]);
            k >>= 1;
        }
        return make_pair(r1, r2);
    }
};
void buildWall(int n, int k, int op[], int left[], int right[], int height[],
               int finalHeight[]) {
    if (k <= 5000 && n <= 10000) {
        for (int i = 0; i < n; i++) {
            finalHeight[i] = 0;
        }
        for (int i = 0; i < k; i++) {
            for (int j = left[i]; j <= right[i]; j++) {
                if (op[i] == 1) {
                    finalHeight[j] = max(finalHeight[j], height[i]);
                } else {
                    finalHeight[j] = min(finalHeight[j], height[i]);
                }
            }
        }
    } else {
        Segtree seg(n);
        for (int i = 0; i < k; i++) {
            seg.upd(left[i], right[i] + 1, P(height[i], op[i]), i);
        }
        for (int i = 0; i < n; i++) {
            pair<int, int> p = seg.get(i);
            cout << p.first << " " << p.second << endl;
            finalHeight[i] = min(p.first, p.second);
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 26 ms 504 KB Output is correct
5 Correct 28 ms 504 KB Output is correct
6 Correct 26 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 175 ms 8156 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 4 ms 380 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 25 ms 504 KB Output is correct
5 Correct 26 ms 504 KB Output is correct
6 Correct 26 ms 504 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Incorrect 178 ms 8156 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 26 ms 504 KB Output is correct
5 Correct 26 ms 504 KB Output is correct
6 Correct 26 ms 504 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Incorrect 181 ms 8160 KB Output isn't correct
9 Halted 0 ms 0 KB -