Advertisement
Guest User

Untitled

a guest
May 27th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.05 KB | None | 0 0
  1. //██████╗ ██╗   ██╗██╗      ██████╗ ███████╗
  2. //██╔══██╗██║   ██║██║      ██╔══██╗██╔════╝
  3. //██████╔╝██║   ██║██║█████╗██║  ██║█████╗
  4. //██╔══██╗██║   ██║██║╚════╝██║  ██║██╔══╝
  5. //██║  ██║╚██████╔╝██║      ██████╔╝███████╗
  6. //╚═╝  ╚═╝ ╚═════╝ ╚═╝      ╚═════╝ ╚══════╝
  7. #include <bits/stdc++.h>
  8. #include <set>
  9. using namespace std;
  10.  
  11. #define fst first
  12. #define snd second
  13. #define mp make_pair
  14. #define mt make_tuple
  15. #define pb push_back
  16. #define eb emplace_back
  17.  
  18. #define all(v) (v).begin(), (v).end()
  19. #define sz(v) ((int)(v).size())
  20. #define sqr(x) ((x) * (x))
  21.  
  22. #define ADD_OPERATORS_IN(T, COMP) \
  23.     bool operator < (const T& ot) const { return COMP(ot) == -1; } \
  24.     bool operator > (const T& ot) const { return COMP(ot) == 1; } \
  25.     bool operator == (const T& ot) const { return COMP(ot) == 0; } \
  26.     bool operator != (const T& ot) const { return COMP(ot) != 0; }
  27.  
  28. #define ADD_OPERATORS_OUT(T, COMP) \
  29.     bool operator < (const T& a, const T& b) const { return COMP(a, b) == -1; } \
  30.     bool operator > (const T& a, const T& b) const { return COMP(a, b) == 1; } \
  31.     bool operator == (const T& a, const T&b) const { return COMP(a, b) == 0; } \
  32.     bool operator != (const T& a, const T&b) const { return COMP(a, b) != 0; }
  33.  
  34.  
  35. typedef long long ll;
  36. typedef long double ld;
  37. typedef pair <int, int> pii;
  38. typedef pair <ll, ll> pll;
  39.  
  40. mt19937 mt_rand(chrono::system_clock::now().time_since_epoch().count());
  41.  
  42. template<typename T1, typename T2> inline bool upmax(T1& a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
  43. template<typename T1, typename T2> inline bool upmin(T1& a, T2 b) { if (b < a) { a = b; return 1; } return 0; }
  44.  
  45. const int maxn = (int) 10002;
  46. const int base = 2147483647;
  47.  
  48. const ld PI = acos(-1.);
  49.  
  50. #define next ajksdslk
  51.  
  52. int n, q;
  53. bitset<maxn> a, ans;
  54.  
  55. int main() {
  56.     scanf ("%d%d", &n, &q);
  57.     a.set(0);
  58.     ans.set(0);
  59.     vector<pair<int, int>> event;
  60.  
  61.     for (int i = 1; i <= q; i ++) {
  62.         int l, r, x;
  63.         scanf ("%d%d%d", &l, &r, &x);
  64.         event.eb(l, x);
  65.         event.eb(r + 1, -x);
  66.     }
  67.  
  68.     sort(all(event));
  69.     int ptr = 0;
  70.     for (int i = 1; i <= n; i ++) {
  71.         while (ptr < event.size() && event[ptr].first == i) {
  72.             int x = event[ptr].second;
  73.             if (x < 0) {
  74.                 x = abs(x);
  75.                 a = (a >> x) & a;
  76.             } else {
  77.                 a = (a << x) | a;
  78.             }
  79.             ptr ++;
  80.         }
  81.         ans |= a;
  82.     }
  83.     vector<int> vec;
  84.     for (int i = 1; i <= n; i ++) {
  85.         if (ans[i]) {
  86.             vec.pb(i);
  87.         }
  88.     }
  89.     cout << vec.size() << '\n';
  90.     for (int v : vec) {
  91.         cout << v << " ";
  92.     }
  93.     return 0;
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement