Submission #1010179

# Submission time Handle Problem Language Result Execution time Memory
1010179 2024-06-28T12:45:53 Z somefjord Wall (IOI14_wall) C++17
0 / 100
108 ms 22252 KB
#include "wall.h"
#include <bits/stdc++.h>

constexpr int N = 1 << 21;

struct SegTree {
  int seg[N];
  int n;
  SegTree(int n) : n(n) {}

  void update(int l, int r, int d) {
    l += n;
    r += n;
    while (r > l) {
      if (l & 1) {
        seg[l++] += d;
      }
      if (r & 1) {
        seg[--r] += d;
      }

      l /= 2;
      r /= 2;
    }
  }

  int query(int i) { return seg[n + i]; }
};

void buildWall(int n, int k, int op[], int left[], int right[], int height[],
               int finalHeight[]) {
  SegTree tr(n);

  for (int i = 0; i < k; ++i) {
    tr.update(left[i], right[i] + 1, op[i] == 1 ? height[i] : -height[i]);
  }

  for (int i = 0; i < n; ++i) {
    finalHeight[i] = tr.query(i);
  }

  return;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8540 KB Output is correct
2 Incorrect 5 ms 8636 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8540 KB Output is correct
2 Incorrect 108 ms 22252 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8540 KB Output is correct
2 Incorrect 5 ms 8540 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8540 KB Output is correct
2 Incorrect 6 ms 8540 KB Output isn't correct
3 Halted 0 ms 0 KB -