Advertisement
pb_jiang

ABC106D WA

Nov 20th, 2022
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.86 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>(501);
  45.     for (auto [l, r] : lr) {
  46.         arr[l - 1][r + 1] += 1;
  47.     }
  48.    
  49.     auto dp = vv<int>(501);
  50.     for (int i = 500; i >= 0; --i)
  51.         for (int j = i + 1; j <= 500; ++j)
  52.             // dp[i][j] = dp[i - 1][j] + dp[i][j + 1] - dp[i - 1][j + 1] + arr[i][j];
  53.             dp[i][j] = dp[i + 1][j] + dp[i][j - 1] - dp[i + 1][j - 1] + arr[i][j];
  54.  
  55.     for (auto [l, r] : pq)
  56.         cout << dp[l - 1][r - 1] << endl;
  57.  
  58.     return 0;
  59. };
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement