Submission #930528

# Submission time Handle Problem Language Result Execution time Memory
930528 2024-02-20T05:46:36 Z Der_Vlapos Wall (IOI14_wall) C++17
Compilation error
0 ms 0 KB
#include "wall.h"
#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define pii pair<int, int>
#define ll long long

const int BIG = 2e9 + 500;

struct segTree
{
  struct Node
  {
    deque<pii> ops;
  };
  vector<Node> tree;
  int sz;

  void init(int n)
  {
    sz = 1;
    while (sz < n)
      sz *= 2;
    tree.resize(2 * sz);
  }

  // 0 - min=
  // 1 - max=

  void upd(int v, int lv, int rv, pii op)
  {
    // cout << lv << " " << rv << " " << op.f << " " << op.s << "!!!\n";
    if (tree[v].ops.size() and op.f == tree[v].ops.back().f)
      tree[v].ops.back().s = (op.f == 0 ? min(op.s, tree[v].ops.back().s) : max(op.s, tree[v].ops.back().s));
    else if (tree[v].ops.size() < 2)
      tree[v].ops.push_back(op);
    else
    {
      if (op.f == 1)
      {
        int C1 = tree[v].ops.begin()->s;
        tree[v].ops.pop_front();
        int C2 = tree[v].ops.begin()->s;
        int C3 = op.s;
        tree[v].ops.push_back({1, max(min(C1, C2), C3)});
      }
      else
      {
        int C1 = tree[v].ops.begin()->s;
        tree[v].ops.pop_front();
        int C2 = tree[v].ops.begin()->s;
        int C3 = op.s;
        tree[v].ops.push_back({0, min(max(C1, C2), C3)});
      }
    }
  }

  void push(int v, int lv, int rv)
  {
    if (rv - lv == 1)
      return;
    int m = (lv + rv) >> 1;
    while (tree[v].ops.size())
    {
      pii op = tree[v].ops.front();
      tree[v].ops.pop_front();
      upd(v * 2 + 1, lv, m, op);
      upd(v * 2 + 2, m, rv, op);
    }
  }

  void addOp(int l, int r, pii op, int v, int lv, int rv)
  {
    push(v, lv, rv);
    if (l <= lv and rv <= r)
    {
      upd(v, lv, rv, op);
      return;
    }
    if (rv <= l or r <= lv)
      return;
    int m = (lv + rv) >> 1;
    addOp(l, r, op, v * 2 + 1, lv, m);
    addOp(l, r, op, v * 2 + 2, m, rv);
  }

  void addOp(int l, int r, pii op)
  {
    addOp(l, r, op, 0, 0, sz);
  }

  void outArray(vector<int> &a, int v, int lv, int rv)
  {
    push(v, lv, rv);
    if (rv - lv == 1)
    {
      if (lv < a.size())
      {
        while (tree[v].ops.size())
        {
          pii op = tree[v].ops.front();
          tree[v].ops.pop_front();
          a[lv] = op.f ? max(a[lv], op.s) : min(a[lv], op.s);
        }
      }
      return;
    }
    int m = (lv + rv) >> 1;
    outArray(a, v * 2 + 1, lv, m);
    outArray(a, v * 2 + 2, m, rv);
  }

  void outArray(vector<int> &a)
  {
    outArray(a, 0, 0, sz);
  }
};

Compilation message

wall.cpp: In member function 'void segTree::outArray(std::vector<int>&, int, int, int)':
wall.cpp:100:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  100 |       if (lv < a.size())
      |           ~~~^~~~~~~~~~
/usr/bin/ld: /tmp/cc4OjCWZ.o: in function `main':
grader.cpp:(.text.startup+0x133): undefined reference to `buildWall(int, int, int*, int*, int*, int*, int*)'
collect2: error: ld returned 1 exit status