Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //██████╗ ██╗ ██╗██╗ ██████╗ ███████╗
- //██╔══██╗██║ ██║██║ ██╔══██╗██╔════╝
- //██████╔╝██║ ██║██║█████╗██║ ██║█████╗
- //██╔══██╗██║ ██║██║╚════╝██║ ██║██╔══╝
- //██║ ██║╚██████╔╝██║ ██████╔╝███████╗
- //╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚══════╝
- #include <bits/stdc++.h>
- #include <set>
- using namespace std;
- #define fst first
- #define snd second
- #define mp make_pair
- #define mt make_tuple
- #define pb push_back
- #define eb emplace_back
- #define all(v) (v).begin(), (v).end()
- #define sz(v) ((int)(v).size())
- #define sqr(x) ((x) * (x))
- #define ADD_OPERATORS_IN(T, COMP) \
- bool operator < (const T& ot) const { return COMP(ot) == -1; } \
- bool operator > (const T& ot) const { return COMP(ot) == 1; } \
- bool operator == (const T& ot) const { return COMP(ot) == 0; } \
- bool operator != (const T& ot) const { return COMP(ot) != 0; }
- #define ADD_OPERATORS_OUT(T, COMP) \
- bool operator < (const T& a, const T& b) const { return COMP(a, b) == -1; } \
- bool operator > (const T& a, const T& b) const { return COMP(a, b) == 1; } \
- bool operator == (const T& a, const T&b) const { return COMP(a, b) == 0; } \
- bool operator != (const T& a, const T&b) const { return COMP(a, b) != 0; }
- typedef long long ll;
- typedef long double ld;
- typedef pair <int, int> pii;
- typedef pair <ll, ll> pll;
- mt19937 mt_rand(chrono::system_clock::now().time_since_epoch().count());
- template<typename T1, typename T2> inline bool upmax(T1& a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
- template<typename T1, typename T2> inline bool upmin(T1& a, T2 b) { if (b < a) { a = b; return 1; } return 0; }
- const int maxn = (int) 10002;
- const int base = 2147483647;
- const ld PI = acos(-1.);
- #define next ajksdslk
- int n, q;
- bitset<maxn> a, ans;
- int main() {
- scanf ("%d%d", &n, &q);
- a.set(0);
- ans.set(0);
- vector<pair<int, int>> event;
- for (int i = 1; i <= q; i ++) {
- int l, r, x;
- scanf ("%d%d%d", &l, &r, &x);
- event.eb(l, x);
- event.eb(r + 1, -x);
- }
- sort(all(event));
- int ptr = 0;
- for (int i = 1; i <= n; i ++) {
- while (ptr < event.size() && event[ptr].first == i) {
- int x = event[ptr].second;
- if (x < 0) {
- x = abs(x);
- a = (a >> x) & a;
- } else {
- a = (a << x) | a;
- }
- ptr ++;
- }
- ans |= a;
- }
- vector<int> vec;
- for (int i = 1; i <= n; i ++) {
- if (ans[i]) {
- vec.pb(i);
- }
- }
- cout << vec.size() << '\n';
- for (int v : vec) {
- cout << v << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement