Submission #1010189

# Submission time Handle Problem Language Result Execution time Memory
1010189 2024-06-28T12:54:08 Z somefjord Wall (IOI14_wall) C++17
0 / 100
6 ms 8540 KB
#include "wall.h"
#include <bits/stdc++.h>

using namespace std;

constexpr int N = 1 << 21;

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

  void update(int l, int r, int h, bool op) {
    l += n;
    r += n;
    while (r > l) {
      if (l & 1) {
        if (op) {
          seg[l] = max(seg[l++], h);
        } else {
          seg[l] = min(seg[l++], h);
        }
      }
      if (r & 1) {
        if (op) {
          seg[--r] = max(seg[r], h);
        } else {
          seg[--r] = min(seg[r], h);
        }
      }

      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, height[i], op[i] == 1);
  }

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

  return;
}

Compilation message

wall.cpp: In member function 'void SegTree::update(int, int, int, bool)':
wall.cpp:19:29: warning: operation on 'l' may be undefined [-Wsequence-point]
   19 |           seg[l] = max(seg[l++], h);
      |                            ~^~
wall.cpp:21:29: warning: operation on 'l' may be undefined [-Wsequence-point]
   21 |           seg[l] = min(seg[l++], h);
      |                            ~^~
wall.cpp:26:15: warning: operation on 'r' may be undefined [-Wsequence-point]
   26 |           seg[--r] = max(seg[r], h);
      |               ^~~
wall.cpp:28:15: warning: operation on 'r' may be undefined [-Wsequence-point]
   28 |           seg[--r] = min(seg[r], h);
      |               ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 8536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 8540 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 8536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 8400 KB Output isn't correct
2 Halted 0 ms 0 KB -