Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Problem: D - AtCoder Express 2
- // Contest: AtCoder - AtCoder Beginner Contest 106
- // URL: https://atcoder.jp/contests/abc106/tasks/abc106_d
- // Memory Limit: 976 MB
- // Time Limit: 3000 ms
- //
- // Powered by CP Editor (https://cpeditor.org)
- #include <assert.h>
- #include <bits/stdc++.h>
- using namespace std;
- #define dbg(...) logger(#__VA_ARGS__, __VA_ARGS__)
- template <typename... Args> void logger(string vars, Args &&... values)
- {
- cerr << vars << " = ";
- string delim = "";
- (..., (cerr << delim << values, delim = ", "));
- cerr << endl;
- }
- template <class T> inline auto vv(int m) { return vector<vector<T>>(m, vector<T>(m)); }
- template <class T> inline auto vv(int m, int n) { return vector<vector<T>>(m, vector<T>(n)); }
- template <class T, T init> inline auto vv(int m) { return vector<vector<T>>(m, vector<T>(m, init)); }
- template <class T, T init> inline auto vv(int m, int n) { return vector<vector<T>>(m, vector<T>(n, init)); }
- template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
- using ll = long long;
- using pii = pair<int, int>;
- int n, m, q;
- vector<pii> lr;
- vector<pii> pq;
- int main(int argc, char **argv)
- {
- cin >> n >> m >> q;
- lr = vector<pii>(m);
- for (int i = 0; i < m; ++i)
- cin >> lr[i].first >> lr[i].second;
- pq = vector<pii>(q);
- for (int i = 0; i < q; ++i)
- cin >> pq[i].first >> pq[i].second;
- auto arr = vv<int>(501);
- for (auto [l, r] : lr) {
- arr[l - 1][r + 1] += 1;
- }
- auto dp = vv<int>(501);
- for (int i = 500; i >= 0; --i)
- for (int j = i + 1; j <= 500; ++j)
- // dp[i][j] = dp[i - 1][j] + dp[i][j + 1] - dp[i - 1][j + 1] + arr[i][j];
- dp[i][j] = dp[i + 1][j] + dp[i][j - 1] - dp[i + 1][j - 1] + arr[i][j];
- for (auto [l, r] : pq)
- cout << dp[l - 1][r - 1] << endl;
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement