Submission #1072461

# Submission time Handle Problem Language Result Execution time Memory
1072461 2024-08-23T19:27:09 Z MilosMilutinovic Pyramid Base (IOI08_pyramid_base) C++14
65 / 100
1432 ms 220512 KB
#include <bits/stdc++.h>

using namespace std;

#define y1 fuaihcoia

const int N = (int) (4e5);

int n, m, b, k;
int x1[N], y1[N], x2[N], y2[N], c[N];

void Solve0() {
  vector<vector<vector<int>>> qs(n, vector<vector<int>>(2));
  for (int i = 0; i < k; i++) {
    qs[x2[i]][0].push_back(i);
    qs[x1[i]][1].push_back(i);
  }
  vector<array<int, 6>> st(4 * m);
  auto Push = [&](int x) {
    if (x * 2 + 1 >= 4 * m) {
      return;
    }
    st[x * 2][0] += st[x][1];
    st[x * 2][1] += st[x][1];
    st[x * 2 + 1][0] += st[x][1];
    st[x * 2 + 1][1] += st[x][1];
    st[x][1] = 0;
  };
  function<void(int, int, int)> Build = [&](int x, int l, int r) {
    int d = r - l + 1; 
    st[x] = {0, 0, d, d, d, d}; 
    if (l == r) {
      return;
    }
    int mid = (l + r) >> 1;
    Build(x * 2, l, mid);
    Build(x * 2 + 1, mid + 1, r);
  };
  function<void(int, int, int, int, int, int)> Modify = [&](int x, int l, int r, int ll, int rr, int v) {
    if (ll <= l && r <= rr) {
      st[x][0] += v;
      st[x][1] += v;
      Push(x);
      return;
    }
    Push(x);
    int mid = (l + r) >> 1;
    if (rr <= mid) {
      Modify(x * 2, l, mid, ll, rr, v);
    } else if (ll > mid) {
      Modify(x * 2 + 1, mid + 1, r, ll, rr, v);
    } else {
      Modify(x * 2, l, mid, ll, rr, v);
      Modify(x * 2 + 1, mid + 1, r, ll, rr, v);
    }
    st[x][0] = min(st[x * 2][0], st[x * 2 + 1][0]);
    st[x][2] = max({(st[x * 2][0] == st[x][0] ? st[x * 2][2] : 0), (st[x * 2 + 1][0] == st[x][0] ? st[x * 2 + 1][2] : 0), (st[x * 2][0] == st[x][0] ? st[x * 2][4] : 0) + (st[x * 2 + 1][0] == st[x][0] ? st[x * 2 + 1][3] : 0)}); 
    st[x][3] = (st[x * 2][0] == st[x][0] ? st[x * 2][3] : 0) + (st[x * 2][0] == st[x][0] && st[x * 2 + 1][0] == st[x][0] && st[x * 2][3] == st[x * 2][5] ? st[x * 2 + 1][3] : 0);
    st[x][4] = (st[x * 2 + 1][0] == st[x][0] ? st[x * 2 + 1][4] : 0) + (st[x * 2][0] == st[x][0] && st[x * 2 + 1][0] == st[x][0] && st[x * 2 + 1][4] == st[x * 2 + 1][5] ? st[x * 2][4] : 0);
  };
  Build(1, 0, m - 1);
  int ptr = n - 1;
  int res = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j : qs[i][0]) {
      Modify(1, 0, m - 1, y1[j], y2[j], 1);
    }
    while (ptr - i + 1 > (st[1][0] == 0 ? st[1][2] : 0)) {
      for (int j : qs[ptr][1]) {
        Modify(1, 0, m - 1, y1[j], y2[j], -1);
      }
      ptr -= 1;
    }
    res = max(res, ptr - i + 1);
  }
  cout << res << '\n';
}

void Solve1() {

}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> b >> k;
  for (int i = 0; i < k; i++) {
    cin >> x1[i] >> y1[i] >> x2[i] >> y2[i] >> c[i];
    --x1[i]; --y1[i];
    --x2[i]; --y2[i];
  }
  if (b == 0) {
    Solve0();
  } else {
    Solve1();
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 24668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 130 ms 186592 KB Output is correct
2 Correct 117 ms 186704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 110 ms 186708 KB Output is correct
2 Correct 124 ms 186580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 7004 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 7260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 7312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 7648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 696 ms 204616 KB Output is correct
2 Correct 393 ms 114256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 840 ms 212672 KB Output is correct
2 Correct 947 ms 208320 KB Output is correct
3 Correct 593 ms 122484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 983 ms 220512 KB Output is correct
2 Correct 1384 ms 217424 KB Output is correct
3 Correct 1432 ms 217296 KB Output is correct
4 Correct 1191 ms 215056 KB Output is correct
5 Correct 846 ms 209456 KB Output is correct