Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ▄███████▀▀▀▀▀▀███████▄
- ░▐████▀▒ Дядя ▒▀██████▄
- ░███▀▒▒▒Богдан▒▒▒▒▒▀█████
- ░▐██▒▒▒▒▒▒Чекает▒▒▒▒▒████▌
- ░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
- ░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
- ░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
- ░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
- ░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
- ░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
- ░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
- ░░░░▄██████████████▒▒▐▌
- ░░░▀███▀▀████▀█████▀▒▌
- ░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
- ░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
- */
- #pragma comment(linker,"/STACK:128000000")
- #include <stdio.h>
- #include <cstdlib>
- #include <cctype>
- #include <cstring>
- #include <cmath>
- #include <ctime>
- #include <cassert>
- #include <deque>
- #include <string>
- #include <vector>
- #include <queue>
- #include <stack>
- #include <map>
- #include <set>
- #include <unordered_set>
- #include <unordered_map>
- #include <utility>
- #include <algorithm>
- #include <tuple>
- #include <iostream>
- #include <random>
- #include <iterator>
- #include <list>
- #include <iomanip>
- #include <random>
- #include <complex>
- #include <list>
- #include <deque>
- #include <numeric>
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- typedef vector<ll> vl;
- typedef vector<vl> vvl;
- typedef vector<int> vi;
- typedef vector<vi> vvi;
- typedef pair<int, int> pii;
- typedef pair<double, double> ptd;
- const int inf = (int)1e9 + 1000;
- const ll infLL = 10000000000000001LL;
- const int mod = (int)1e9 + 7;
- const double eps = 1e-7;
- const double pi = 3.141592653589793;
- const int maxlen = (int)1e6 + 10;
- const int base = (int)1e9;
- const int dd = (int)100 + 1;
- #define ACCEPTED return 0;
- #define mp make_pair
- #define all(x) (x).begin(), (x).end()
- #define rall(x) (x).rbegin(), (x).rend()
- #define optimize cin.sync_with_stdio(false);cout.sync_with_stdio(false);cin.tie(0);
- #define name "dwarf"
- #define scnaf scanf
- #define X first
- #define Y second
- struct triple
- {
- int x, y, z;
- bool operator<(triple t) const
- {
- return x < t.x && y < t.y && z < t.z;
- }
- };
- int a;
- int b;
- int C;
- int M;
- int r()
- {
- a = 36969 * (a & M) + (a >> 16);
- b = 18000 * (b & M) + (b >> 16);
- return (C & ((a << 16) + b)) % 1000000;
- }
- int t[maxlen];
- void add(int i, int x)
- {
- for (; i < maxlen; i = i | (i + 1))
- t[i] = max(t[i], x);
- }
- int get(int i)
- {
- int ans = 0;
- for (; i >= 0; i = (i & (i + 1)) - 1)
- ans = max(ans, t[i]);
- return ans;
- }
- void solve()
- {
- memset(t, 0, sizeof(t));
- int m, n, A, B;
- scanf("%d %d %d %d", &m, &n, &A, &B);
- if (m == 0 && n == 0)
- exit(0);
- a = A;
- b = B;
- C = ~(1<<31);
- M = (1<<16)-1;
- vector<triple> v;
- for (int i = 0; i < m; i++) {
- int x, y, z;
- scanf("%d %d %d", &x, &y, &z);
- v.push_back({x, y, z});
- }
- for (int i = 0; i < n; i++) {
- int x = r();
- int y = r();
- int z = r();
- v.push_back({x, y, z});
- }
- auto w = v;
- sort(all(w));
- vi q;
- for (int i = 0; i < v.size(); i++)
- q.push_back(lower_bound(all(w), v[i]) - w.begin());
- int ans = 0;
- for (int x : q) {
- ans = max(ans, get(x - 1) + 1);
- add(x, ans);
- }
- printf("%d\n", ans);
- }
- int main()
- {
- #ifdef _DEBUG
- freopen("input.txt", "rt", stdin);
- freopen("output.txt", "wt", stdout);
- //#else
- // freopen(name".in", "rt", stdin);
- // freopen(name".out", "wt", stdout);
- #endif
- while (true)
- solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement