Advertisement
pb_jiang

abc106d ac

Nov 20th, 2022
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.74 KB | None | 0 0
  1. // Problem: D - AtCoder Express 2
  2. // Contest: AtCoder - AtCoder Beginner Contest 106
  3. // URL: https://atcoder.jp/contests/abc106/tasks/abc106_d
  4. // Memory Limit: 976 MB
  5. // Time Limit: 3000 ms
  6. //
  7. // Powered by CP Editor (https://cpeditor.org)
  8.  
  9. #include <assert.h>
  10. #include <bits/stdc++.h>
  11. using namespace std;
  12. #define dbg(...) logger(#__VA_ARGS__, __VA_ARGS__)
  13. template <typename... Args> void logger(string vars, Args &&... values)
  14. {
  15.     cerr << vars << " = ";
  16.     string delim = "";
  17.     (..., (cerr << delim << values, delim = ", "));
  18.     cerr << endl;
  19. }
  20.  
  21. template <class T> inline auto vv(int m) { return vector<vector<T>>(m, vector<T>(m)); }
  22. template <class T> inline auto vv(int m, int n) { return vector<vector<T>>(m, vector<T>(n)); }
  23. template <class T, T init> inline auto vv(int m) { return vector<vector<T>>(m, vector<T>(m, init)); }
  24. template <class T, T init> inline auto vv(int m, int n) { return vector<vector<T>>(m, vector<T>(n, init)); }
  25.  
  26. template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
  27. using ll = long long;
  28. using pii = pair<int, int>;
  29.  
  30. int n, m, q;
  31. vector<pii> lr;
  32. vector<pii> pq;
  33.  
  34. int main(int argc, char **argv)
  35. {
  36.     cin >> n >> m >> q;
  37.     lr = vector<pii>(m);
  38.     for (int i = 0; i < m; ++i)
  39.         cin >> lr[i].first >> lr[i].second;
  40.     pq = vector<pii>(q);
  41.     for (int i = 0; i < q; ++i)
  42.         cin >> pq[i].first >> pq[i].second;
  43.  
  44.     auto arr = vv<int>(502);
  45.     for (auto [l, r] : lr)
  46.         arr[l][r] += 1;
  47.  
  48.     auto dp = vv<int>(502);
  49.     for (int l = 500; l >= 0; --l)
  50.         for (int r = l; r <= 500; ++r)
  51.             dp[l][r] = dp[l][r - 1] + dp[l + 1][r] - dp[l + 1][r - 1] + arr[l][r];
  52.  
  53.     for (auto [l, r] : pq)
  54.         cout << dp[l][r] << endl;
  55.  
  56.     return 0;
  57. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement