답안 #886134

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886134 2023-12-11T13:38:39 Z vjudge1 Curtains (NOI23_curtains) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

template<typename A, typename B>
string to_string(pair<A, B>);
string to_string(string S) {
  return '"' + S + '"';
}
string to_string(const char* c) {
  return to_string(string(c));
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
template<size_t T>
string to_string(bitset<T> bs) {
  return bs.to_string();
}
string to_string(vector<bool> v) {
  string res = "{";
  for (int i = 0; i < int(v.size()); ++i) {
    if (int(res.size()) > 1) {
      res += ", ";
    }
    res += to_string(v[i]);
  }
  return res + "}";
}
template<typename T>
string to_string(T v) {
  string res = "{";
  for (auto e : v) {
    if (int(res.size()) > 1) {
      res += ", ";
    }
    res += to_string(e);
  }
  return res + "}";
}
template<typename A, typename B>
string to_string(pair<A, B> p) {
  return '(' + to_string(p.first) + ", " + to_string(p.second) + ')';
}
void debug_out() {
  cerr << endl;
}
template<typename H, typename... T>
void debug_out(H head, T... tail) {
  cerr << "  " << to_string(head);
  debug_out(tail...);
}

#ifdef DEBUG 
  #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) 
#else 
  #define debug(...) void(37)
#endif

struct node {
  int mn = -1;
  int tag = -1;
  void modify(int x) {
    tag = max(tag, x);
    mn = max(mn, x);
  }
};
node unite(node x, node y) {
  return node{min(x.mn, y.mn), -1};
}
const int inf = int(1e9);
#define def int mid = (l + r) >> 1, rv = v + ((mid - l + 1) * 2)
struct SegTree {
  vector<node> tree;
  int n;
  void push(int v, int l, int r) {
    def;
    if (tree[v].tag != -1) {
      tree[v + 1].modify(tree[v].tag);
      tree[rv].modify(tree[v].tag);
      tree[v].tag = -1;
    }
  }
  void modify(int v, int l, int r, int ll, int rr, int x) {
    if (l >= ll && rr >= r) {
      tree[v].modify(x);
      return;
    }
    def;
    push(v, l, r);
    if (mid >= ll) {
      modify(v + 1, l, mid, ll, rr, x);
    }
    if (mid < rr) {
      modify(rv, mid + 1, r, ll, rr, x);
    }
    tree[v] = unite(tree[v + 1], tree[rv]);
  }
  int get(int v, int l, int r, int ll, int rr) {
    if (l >= ll && rr >= r) {
      return tree[v].mn;
    }
    def;
    push(v, l, r);
    int res = inf;
    if (mid >= ll) {
      res = min(res, get(v + 1, l, mid, ll, rr));
    }
    if (mid < rr) {
      res = min(res, get(rv, mid + 1, r, ll, rr));
    }
    return res;
  }
  SegTree(int _n) : n(_n) { 
    tree.resize(n * 2);
  }
  void modify(int ll, int rr, int x) {
    modify(0, 0, n - 1, ll, rr, x);
  }
  int get(int ll, int rr) {
    return get(0, 0, n - 1, ll, rr);
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<int> L(M), R(M);
  for (int i = 0; i < M; ++i) {
    cin >> L[i] >> R[i];
    --L[i], --R[i];
  }
  vector<int> S(Q), E(Q);
  for (int i = 0; i < Q; ++i) {
    cin >> S[i] >> E[i];
    --S[i], --E[i];
  }
  debug(L, R, S, E);
  vector<vector<int>> lefts(N);
  for (int i = 0; i < M; ++i) {
    lefts[R[i]].push_back(L[i]);
  }
  vector<vector<int>> qs(N);
  for (int i = 0; i < Q; ++i) {
    qs[E[i]].push_back(i);
  } 
  debug(lefts, qs);
  vector<bool> ans(Q);
  SegTree st(N);
  for (int i = 0; i < N; ++i) {
    for (auto l : lefts[i]) {
      st.modify(l, i, l);
    }
    for (auto q : qs[i]) {
      ans[q] = st.get(S[q], i) >= S[q];
    }
  }
  for (int i = 0; i < Q; ++i) {
    cout << (ans[i] ? "YES" : "NO") << '\n';
  }

Compilation message

curtains.cpp: In function 'int main()':
curtains.cpp:162:3: error: expected '}' at end of input
  162 |   }
      |   ^
curtains.cpp:125:12: note: to match this '{'
  125 | int main() {
      |            ^