output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } template <typename T> inline void getint(T &first) { char c, sg = 0; while (c = getchar(), (c > '9...
### Prompt Your task is to create a cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen t...
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5; const long long off = 1e5; long long n, w, h; vector<pair<long long, pair<long long, long long> > > g[N]; pair<long long, long long> ans[N]; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; cin >> n >> w >> h; for...
### Prompt Your task is to create a CPP solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen t...
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; vector<pair<pair<int, int>, int>> dancers[300005]; vector<pair<int, int>> end_positions[300005]; pair<int, int> result[111111]; int main() { int N, W, H; scanf("%d%d%d", &N, &W, &H); for (int i = 0; i < (N); ++i) { int g, p, t; scan...
### Prompt In Cpp, your task is to solve the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no coll...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100100; int n, w, h; int G[MAXN], P[MAXN], T[MAXN]; void load() { scanf("%d%d%d", &n, &w, &h); for (int i = 0; i < n; i++) scanf("%d%d%d", G + i, P + i, T + i); } vector<int> V[3 * MAXN]; vector<pair<int, int> > Ps[3 * MAXN]; bool cmp1(int a, int b) { ...
### Prompt Please create a solution in CPP to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, -1, 0, 1}; template <class T> void inputVector(vector<T> &v, int n) { v.resize(n); for (int i = 0; i < v.size(); i++) cin >> v[i]; } int n, w, h; class Person { public: int x, y, g, id; int gx, gy; Person() {} Person(i...
### Prompt Create a solution in Cpp for the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no colli...
#include <bits/stdc++.h> using namespace std; vector<pair<pair<int, int>, int>> vert[500000], hori[500000]; void solve() { int n, w, h; cin >> n >> w >> h; for (int i = 0; i < n; i++) { int g, p, t; cin >> g >> p >> t; if (g == 1) { vert[p - t + 200000].push_back(make_pair(make_pair(p, -t), i));...
### Prompt Your challenge is to write a Cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; char getc() { char c = getchar(); while ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9')) c = getchar(); return c; } int gcd(int n, int m) { return m == 0 ? n : gcd(m, n % m); } int read() { int x = 0, f = 1; char c = getchar(); while (c...
### Prompt Please provide a cpp coded solution to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; struct node { int pos; int id; friend bool operator<(const node &a, const node &b) { return a.pos < b.pos; } } ans[100005]; int n, w, h; vector<node> v[2][200005]; int main() { ios::sync_with_stdio(false); cin >> n >> w >> h; for (int i = 1, p, g, t; i <= n; i++...
### Prompt Please create a solution in cpp to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996) const int maxn = 2e5 + 5; struct node { int idx, p; bool operator<(const node &b) const { return p < b.p; } } ver[100005], hor[100005]; int vcnt, hcnt; vector<node> V1[maxn], V2[maxn]; int tempx[100005], tempy[100005]; int ansx[100005], a...
### Prompt Generate a cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisi...
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; template <typename T> ostream& operator<<(ostream& out, const vector<T>& v); template <typename U, typename V> ostream& operator<<(ostream& out, const map<U, V>& v); template <typename U, typename V> ostream& operator<<(ostream& out, const pair<U...
### Prompt Develop a solution in Cpp to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; const int maxn = 202000; const int mm = 101000; int n, ans[maxn]; int W, H; vector<int> g[maxn], g2[maxn]; struct Node { int first, second, w, id; } a[maxn]; bool cmp1(const Node a, const Node b) { return a.first < b.first || (a.first == b.first && a.second < b.second);...
### Prompt Construct a Cpp code solution to the problem outlined: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no co...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int g[maxn], p[maxn], t[maxn], ax[maxn], ay[maxn]; vector<int> dif[maxn * 2]; bool cmp(const int &a, const int &b) { if (g[a] != g[b]) return g[a] > g[b]; else if (g[a] == 1) return p[a] < p[b]; else return p[a] > p[b]; } int main...
### Prompt Please provide a CPP coded solution to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); } template <typename T> T LCM(T a, T b) { return a * (b / gcd(a, b)); } template <typename T> T expo(T base, T e, T mod) { T res = 1; while (e > 0) { if (e ...
### Prompt Generate a Cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisi...
#include <bits/stdc++.h> using namespace std; int n, w, h; vector<pair<int, int> > xs[200007], ys[200007]; pair<int, int> ans[200007]; int main() { scanf("%d%d%d", &n, &w, &h); for (int i = 1; i <= n; ++i) { int g, p, t; scanf("%d%d%d", &g, &p, &t); if (g == 1) ys[p - t + 100 * 1000].push_back({p,...
### Prompt Please create a solution in cpp to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> static const int MAXN = 100004; static const int MAXW = 100003; static const int MAXT = 100002; int n, w, h; int g[MAXN], p[MAXN], t[MAXN]; std::vector<int> s[MAXW + MAXT]; int ans_x[MAXN], ans_y[MAXN]; int main() { scanf("%d%d%d", &n, &w, &h); for (int i = 0; i < n; ++i) { scanf("%d%d%...
### Prompt Your challenge is to write a Cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 20; struct Node { int x, t, id; Node(int x = 0, int t = 0, int id = 0) : x(x), t(t), id(id) {} bool operator<(const Node &A) const { return t < A.t; } } X[N], Y[N]; struct Point { int x, y; Point(int x = 0, int y = 0) : x(x), y(y) {} } ans[N]; ...
### Prompt Construct a Cpp code solution to the problem outlined: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no co...
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > px[200010], py[200010]; const int N = 1e5 + 1; pair<int, int> ans[200010], P[200010]; int main() { int n, w, h; cin >> n >> w >> h; int mx = 0; for (int i = 1; i <= n; i++) { int g, p, t; scanf("%d %d %d", &g, &p, &t); if (g == 1)...
### Prompt Please formulate a CPP solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; struct node { int org, g, p, t, sub, id, to; } d[100005]; int to[100005] = {0}; int tox[100005] = {0}; int toy[100005] = {0}; int bp[100005] = {0}, bpc = 0; int fr; bool cmpsub(node x, node y) { if (x.sub == y.sub) { if (x.g == y.g) { if (x.g == 2) return x.p ...
### Prompt Generate a Cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisi...
#include <bits/stdc++.h> using namespace std; const int N = 101000; const int zero = 110000; struct edge { int x, y, index; edge(){}; edge(int xx, int yy, int zz) { x = xx; y = yy; index = zz; } }; struct node { int x, y; } b[N]; vector<edge> v[N * 3]; vector<int> t; int e[N]; bool cmp1(const edge...
### Prompt Construct a Cpp code solution to the problem outlined: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no co...
#include <bits/stdc++.h> using namespace std; struct P { int i; int p; bool operator<(const P& o) const { return p < o.p; } }; int main() { ios::sync_with_stdio(false); unordered_map<int, vector<P>> groups; int n, w, h; cin >> n >> w >> h; vector<int> at(n); for (int i = 0; i < n; ++i) { int g, p,...
### Prompt Please create a solution in Cpp to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; const int maxN = 100005; int n, w, h; int g[maxN], p[maxN], t[maxN]; int u[maxN], v[maxN]; int ans[maxN]; int res[maxN]; vector<int> U; vector<int> V; bool compare(const int& x, const int& y) { if (p[x] - t[x] < p[y] - t[y]) return true; if (p[x] - t[x] > p[y] - t[y]) r...
### Prompt Your task is to create a CPP solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen t...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000 + 5; struct dancer { int g, p, t, no; } D[MAXN]; int n, w, h, k; int fp[MAXN][2]; bool comp(dancer a, dancer b) { if ((a.p - a.t) < (b.p - b.t)) return true; else if ((a.p - a.t) > (b.p - b.t)) return false; else { if (a.g != b.g)...
### Prompt Construct a cpp code solution to the problem outlined: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no co...
#include <bits/stdc++.h> using namespace std; const long long MAXN = 201 * 1001, k = 1e5 + 10; vector<pair<pair<long long, long long>, long long>> vx[MAXN], vy[MAXN]; pair<long long, long long> ans[MAXN]; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); long long n, w, h; cin >> n >> w >> h; for (long lo...
### Prompt Your challenge is to write a CPP solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, h, w, tp[N], pos[N], t[N], x[N]; vector<int> vx[N], vy[N]; pair<int, int> ans[N]; bool cmp(int x, int y) { return pos[x] < pos[y]; } int main() { scanf("%d%d%d", &n, &w, &h); for (int i = 1; i <= n; i++) { scanf("%d%d%d", &tp[i], &pos[...
### Prompt Please provide a CPP coded solution to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; int n, w, h; int gi[100003]; int pi[100003]; int ti[100003]; int di[100003]; map<int, vector<int> > collision; bool cmp(int k1, int k2) { return (gi[k1] > gi[k2] || (gi[k1] == 1 && gi[k2] == 1 && pi[k1] > pi[k2]) || (gi[k1] == 2 && gi[k2] == 2 && pi[k1] < pi[k2]...
### Prompt Construct a cpp code solution to the problem outlined: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no co...
#include <bits/stdc++.h> using namespace std; template <class T> inline void qread(T& x) { char c; bool f = 0; while ((c = getchar()) < '0' || '9' < c) f |= (c == '-'); for (x = (c ^ 48); '0' <= (c = getchar()) && c <= '9'; x = (x << 1) + (x << 3) + (c ^ 48)) ; if (f) x = -x; } inline int qread() {...
### Prompt Develop a solution in cpp to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; struct pp { long long first, second, t, k, id, fx, fy; } vet[101010]; int n, w, h, ansx[101010], ansy[101010]; int main() { ios_base::sync_with_stdio(false); cin >> n >> w >> h; for (int(i) = (0); (i) < (n); (i)++) { long long tp, p; cin >> tp >> p >> vet[i]...
### Prompt Construct a CPP code solution to the problem outlined: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no co...
#include <bits/stdc++.h> using namespace std; int n, w, h, i, j, x, y, z; pair<int, int> res[233333]; vector<pair<pair<int, int>, int> > s[233333], t[233333]; int main() { ios::sync_with_stdio(false); ; cin >> n >> w >> h; for (i = 1; i <= n; i++) { cin >> x >> y >> z; if (x == 2) { s[y - z + 1000...
### Prompt Please formulate a CPP solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; const long long INFLL = 0x3f3f3f3f3f3f3f3f; template <int MOD> struct ModInt { long long x; ModInt(long long n = 0) { n %= MOD; if (n < 0) n += MOD; x = n; } int get() const { return (int)x; } ...
### Prompt Construct a Cpp code solution to the problem outlined: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no co...
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 5; int w, h; int g[maxn], p[maxn], t[maxn]; int n; const int maxt = 4 * 100000 + 5; vector<int> can[maxt]; const int rol = 100000; bool cmp(int A, int B) { if (g[A] != g[B]) return g[A] == 2; return g[A] == 2 ? p[A] > p[B] : p[A] < p[B]; } pair...
### Prompt Develop a solution in cpp to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const int big = 1e9 + 10; const long double pai = 3.141592653589793238462643383279502884197; const long double eps = 1e-7; template <class T, class U> void mineq(T& a, U b) { if (a > b) { a = b; } } template <class T, class U> void maxeq(...
### Prompt Please create a solution in Cpp to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; struct data { int g, p, t, id; } a[100100]; int n, w, h, ans[100100][2], q[100100]; int I() { int x = 0, f = 1; char ch = getchar(); for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1; for (; ch >= '0' && ch <= '9'; x = (x << 3) + (x << ...
### Prompt Your challenge is to write a Cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7; const long long infll = 1e18 + 7; int n, w, h; pair<int, int> ans[N]; map<int, vector<pair<pair<int, int>, int>>> mpp; bool cmp(pair<pair<int, int>, int> x, pair<pair<int, int>,...
### Prompt Develop a solution in cpp to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, W, H, pos[N], ti[N], gi[N], idx; pair<int, int> ans[N]; map<int, int> id; deque<int> dq[N]; vector<int> va[N], vb; bool cmp(int x, int y) { if (pos[x] != pos[y]) return pos[x] < pos[y]; return ti[x] < ti[y]; } int main() { scanf("%d%d%d", ...
### Prompt Your challenge is to write a Cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, w, h; struct node { int id; int p; bool operator<(const node& temp) const { return p < temp.p; } }; map<int, vector<node> > group; int ans[N]; int main() { cin >> n >> w >> h; for (int i = 1; i <= n; i++) { int g, p, t; scanf(...
### Prompt Create a solution in CPP for the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no colli...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int n, w, h, g[maxn], p[maxn], t[maxn]; pair<int, int> ans[maxn]; vector<int> xv, yv, res, v[2 * maxn]; bool cmp(const int u, int v) { if (g[u] != g[v]) return g[u] == 2; else return g[u] == 2 ? p[u] > p[v] : p[u] < p[v]; } int main() ...
### Prompt Please create a solution in CPP to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; int n, w, h; struct dancer { int x, y, t, it; dancer() {} dancer(int x, int y, int t, int it) : x(x), y(y), t(t), it(it) {} }; vector<dancer> hor, ver, alld; deque<int> ho[250000]; vector<int> hoinit[250000]; int add = 125000; bool cmp(const dancer &lhs, const dancer ...
### Prompt Generate a CPP solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisi...
#include <bits/stdc++.h> using namespace std; int n, w, h; struct node { int p, t, dir, key, endx0, endx1, endy0, endy1, id; } a[100005]; int cmp_id(node a, node b) { return a.id < b.id; } int cmp(node a, node b) { return ((a.key != b.key) ? (a.key < b.key) : ((a.dir != b.dir) ? (a.dir <...
### Prompt Please create a solution in Cpp to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-8; const double PI = acos(-1.0); const int oo = 0x3f3f3f3f; long long read() { long long d, f = 1; char c; while (!isdigit(c = getchar())) if (c == '-') f = -1; d = c ^ '0'; while (isdigit(c = getchar())) d = (d * 10) + (c ^ '0'); retur...
### Prompt Generate a cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisi...
#include <bits/stdc++.h> using namespace std; int n, w, h, g[100005], p[100005], t, st1[100005], st2[100005]; pair<int, int> ans[100005]; inline pair<int, int> cal(int x) { if (g[x] == 1) return {p[x], h}; return {w, p[x]}; } vector<int> v[100005 << 1]; bool cmp1(int x, int y) { return g[x] == g[y] ? g[x] == 1 ? ...
### Prompt Develop a solution in CPP to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; using lint = long long; using pii = pair<int, int>; using pll = pair<lint, lint>; template <typename T> using vc = vector<T>; template <typename T> using vvc = vector<vector<T>>; template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;...
### Prompt Please create a solution in cpp to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> int n, w, h, g[100005], p[100005], t[100005]; std::pair<int, int> s[100005], e[100005]; std::vector<int> l[200005]; bool cmp1(int x, int y) { if (s[x].first > 0 && s[y].first > 0) return s[x].second > s[y].second; if (s[x].first > 0 || s[y].first > 0) return s[y].first > 0; return s[x].fi...
### Prompt Your challenge is to write a CPP solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; const int inf = 1000000005; const int sz = 100000 + 5; int x[sz], y[sz]; int n; map<int, vector<int> > group; int ansx[sz], ansy[sz]; struct sortx { bool operator()(const int a, const int b) const { if (x[a] == x[b]) throw 2; return x[a] < x[b]; } }; int w, h; v...
### Prompt Please provide a cpp coded solution to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; using ll = long long; template <typename S, typename T> void xmin(S &a, T const &b) { if (b < a) a = b; } template <typename S, typename T> void xmax(S &a, T const &b) { if (b > a) a = b; } signed main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);...
### Prompt In Cpp, your task is to solve the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no coll...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, w, h; bool vis[N]; struct node { int op, p, t, res; } a[N]; map<int, vector<int> > mp; bool cmp1(int x, int y) { if (a[x].op != a[y].op) return a[x].op < a[y].op; if (a[x].op == 1) return a[x].p > a[y].p; else return a[x].p < a...
### Prompt Develop a solution in cpp to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; struct D { int l, t, id; }; unordered_map<int, vector<D>> H, V; unordered_map<int, int> id_shift; pair<int, int> ans[(int)1e5]; int main() { ios::sync_with_stdio(0); int n, w, h; cin >> n >> w >> h; for (int i = 0; i < int(n); i++) { int a, b, c; cin >> a ...
### Prompt In cpp, your task is to solve the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no coll...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100010; const int N = 100000; int n, w, h; int p[MAXN], t[MAXN]; vector<int> pos[MAXN << 1][2]; pair<int, int> ans[MAXN]; inline bool cmp(int x, int y) { return p[x] ^ p[y] ? p[x] < p[y] : t[x] < t[y]; } int main() { scanf("%d%d%d", &n, &w, &h); int m...
### Prompt Generate a Cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisi...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long INFF = 0x3f3f3f3f3f3f3f3fll; const int MAX = 1e5 + 5; const int MAX_N = MAX; const long long MOD = 998244353; const long double pi = acos(-1.0); int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } template <typename T> inline ...
### Prompt Your challenge is to write a cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> int main() { int n, dim[2]; std::cin >> n >> dim[0] >> dim[1]; int fin[n][2]; std::vector<std::pair<int, std::pair<int, int> > > cat[300000]; std::vector<std::vector<int> > len(300000, std::vector<int>(2, 0)); for (int i = 0; i < n; i++) { int g, p, t; std::cin >> g >> p >> ...
### Prompt Please create a solution in cpp to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; const int mod = 1000000007; const int inf = 1 << 29; int n, w, h; void work() { char str[303]; int ck[303][303]; int dp[303][303][303]; int idx, icase = 0; scanf("%d", &idx); while (idx--) { scanf("%s", str); int n = strlen(str);...
### Prompt Your challenge is to write a CPP solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } const double EPS = 1e-10; const double...
### Prompt Please create a solution in cpp to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(false); int n, w, h; cin >> n >> w >> h; vector<pair<pair<int, int>, pair<int, int> > > a; for (int i = 0; i < n; i++) { int first, second, z; cin >> first >> second >> z; z -= second; a.push_back(make_pa...
### Prompt Please provide a Cpp coded solution to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > m[200200]; vector<pair<int, int> > finish[200200]; pair<int, int> ans[100100]; bool cmp(pair<int, int> a, pair<int, int> b) { return a.first - a.second < b.first - b.second; } int main() { int n, w, h; cin >> n >> w >> h; for (int i = 0; i < ...
### Prompt Generate a cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisi...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, w, h; cin >> n >> w >> h; map<int, vector<vector<int>>> mp; vector<int> g(n), p(n), t(n); vector<pair<int, int>> final(n); for (int i = 0; i < n; ++i) { cin >> g[i] >> p[i] >> t[i]; mp[p[i] - t...
### Prompt Generate a Cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisi...
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") using namespace std; int a, b, c, d, n, m, k, w, h; pair<int, int> orig[100002], en[100002]; vector<pair<pair<int, int>, int>> tx, ty; pair<int, int> ans[100002]; int rp[100002]; int main() { scanf("%d%d%...
### Prompt Please formulate a Cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 9; int N, w, h, p[maxn], g[maxn], Id[maxn], t[maxn]; pair<int, int> ans[maxn]; int main() { cin >> N >> w >> h; for (int i = 0; i < N; i++) { scanf("%d%d%d", g + i, p + i, t + i); Id[i] = i; } sort(Id, Id + N, [](const int &l...
### Prompt Construct a cpp code solution to the problem outlined: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no co...
#include <bits/stdc++.h> using namespace std; struct dancer { int p, t, ind; bool operator<(const dancer& x) const { return t < x.t || t == x.t && p < x.p; } }; int main() { ios_base::sync_with_stdio(false); int n, w, h; cin >> n >> w >> h; int maxT = (int)1e5; vector<vector<dancer>> x[2]; for (in...
### Prompt Generate a cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisi...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 7, tot = 3 * maxn, disp = 1e5 + 1; vector<pair<int, int> > mv[tot], mh[tot]; int ans[maxn], polarity[maxn], n, w, h, g, p, t; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; cin >> n >> w >> h; for (int i = ...
### Prompt Create a solution in CPP for the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no colli...
#include <bits/stdc++.h> using namespace std; const int N = 100000 + 10; const int M = 1000000007; const double PI = atan(1) * 4; const int oo = 1000000000; int n, w, h, ans[N], gt[N]; pair<int, int> an[N]; vector<int> dif[2][2 * N], pt[2][2 * N]; vector<pair<pair<int, int>, int> > v[2]; int main() { cin >> n >> w >>...
### Prompt Your challenge is to write a cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; constexpr int MOD = 1000000007; template <typename T, typename U> std::istream& operator>>(std::istream& i, pair<T, U>& p) { i >> p.first >> p.second; return i; } template <typename T> std::istream& operator>>(std::istream& i, vector<T>& t) { for (auto& v : t) { i...
### Prompt Your challenge is to write a CPP solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; struct node { int x, y, id; } a[N], b[N], ans[N]; inline int cmp(node A, node B) { return (A.x + A.y == B.x + B.y) ? (A.x < B.x) : (A.x + A.y < B.x + B.y); } inline int cmp2(node A, node B) { return (A.x == B.x) ? (A.y > B.y) : (A.x < B.x); } in...
### Prompt Please provide a cpp coded solution to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; pair<int, int> ans[maxn]; int main() { unordered_map<int, vector<pair<int, int>>> mpx, mpy; int n, w, h; cin >> n >> w >> h; for (int i = 1; i <= n; i++) { int g, p, t; cin >> g >> p >> t; if (g == 1) { mpx[p - t].push_back...
### Prompt Construct a cpp code solution to the problem outlined: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no co...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int n, w, h; struct Node { int g, p, t, _id; bool operator<(const Node &n) const { return p < n.p; } } a[maxn]; map<int, deque<int> > mp; int idx[maxn], ax[maxn], ay[maxn]; void doit(int g1, int g2) { mp.clear(); for (int i = 1; i <= n; i+...
### Prompt Please formulate a CPP solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, w, h, to[N], cnt = 0; struct people { int x, y, id, op; }; struct answer { int x, y; } ans[N]; vector<people> a, b; bool cmp1(people p1, people p2) { return p1.y < p2.y; } bool cmp2(people p1, people p2) { return p1.x < p2.x; } namespace su...
### Prompt Create a solution in cpp for the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no colli...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; struct dancer { int type; int t; int x; int num; dancer(int type = 0, int t = 0, int x = 0, int num = 0) : type(type), t(t), x(x), num(num) {} }; deque<int> deqs[MAXN * 2]; vector<int> ansy[MAXN * 2]; vector<pair<int, int> > ans; ve...
### Prompt Your challenge is to write a Cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; const int MAXD = 200000; const int MAXN = 100000; vector<pair<int, int> > vecX[MAXD + 10], vecY[MAXD + 10]; int respx[MAXN + 10], respy[MAXN + 10], w, h; int p[MAXN + 10], g[MAXN + 10], t[MAXN + 10], n; int main() { scanf("%d%d%d", &n, &w, &h); for (int i = 1; i <= n; i...
### Prompt Please provide a cpp coded solution to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { if (a == 0) return b; return gcd(b % a, a); } template <typename T> T pow(T a, T b, long long m) { T ans = 1; while (b > 0) { if (b % 2 == 1) ans = ((ans % m) * (a % m)) % m; b /= 2; a = ((a % m) * (a % m)) % m; ...
### Prompt Create a solution in Cpp for the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no colli...
#include <bits/stdc++.h> #pragma GCC optimize(2) const int maxn = 1e5 + 5; std::map<int, std::vector<int> > Reading; struct Walk { int p, t, dir; int id; } M[maxn]; int n, w, h; int ansx[maxn], ansy[maxn]; inline bool Comp(int Alpha, int Beta) { return M[Alpha].p > M[Beta].p; } int main() { scanf("%d%d%d", &n, &w...
### Prompt Please formulate a Cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; using ll = long long; int g[100010], p[100010], t[100010], finalPoint[100010]; map<int, vector<pii>> points; void addPoint(int x, int y, int id) { points[x + y].emplace_back(x, id); } int main() { int n, w, h, i, mid, diff, sgn; cin >> n >> w...
### Prompt Please formulate a cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; int A[100001][3]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; int w, h; cin >> n >> w >> h; unordered_map<int, vector<int>> left, right; for (int i = 1; i <= n; ++i) { cin >> A[i][0] >> A[i][1] >> A[i][2]; if (A[i][0] == 1) righ...
### Prompt Construct a CPP code solution to the problem outlined: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no co...
#include <bits/stdc++.h> using namespace std; queue<int> q[200005], qs[200005]; int ans[100005][2]; int cnt1 = 0, cnt2 = 0, n, h, w; struct node { int pos, t, id; } a[100005], b[100005]; inline int read() { int x = 0; char c = getchar(); while (c < '0' || c > '9') c = getchar(); while (c >= '0' && c <= '9') x...
### Prompt Please create a solution in Cpp to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, w, h; int g[N], p[N], t[N]; pair<int, int> ans[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> w >> h; map<int, vector<int> > ma; for (int i = (0); i < (n); i++) { cin >> g[i] >> p[i] >> t[i]; ma[p[i] - t...
### Prompt Generate a Cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisi...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:32000000") const int nil = -1; using namespace std; inline bool read(int& val) { return scanf("%d", &val) != -1; } inline bool read(long long& val) { return scanf("%I64d", &val) != -1; } inline bool read(double& val) { return scanf("%lf", &val) != -1; } inline bo...
### Prompt Construct a Cpp code solution to the problem outlined: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no co...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, h, w, tp[N], pos[N], t[N], x[N]; vector<int> vx[N], vy[N]; pair<int, int> ans[N]; bool cmp(int x, int y) { return pos[x] < pos[y]; } int main() { scanf("%d%d%d", &n, &w, &h); for (int i = 1; i <= n; i++) { scanf("%d%d%d", &tp[i], &pos[...
### Prompt In Cpp, your task is to solve the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no coll...
#include <bits/stdc++.h> using namespace std; struct Dancer { int coord; int t; int id; bool operator<(const Dancer& d) const { return coord < d.coord; } }; int n, w, h; vector<Dancer> vers; vector<Dancer> hors; bool read() { if (scanf("%d%d%d", &n, &w, &h) < 3) { return 0; } vers.clear(); hors.clea...
### Prompt Please provide a CPP coded solution to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; int n, w, h; struct Node { int id, pos, ti; int ansx, ansy; } x[MAXN], y[MAXN]; int tx, ty; struct Node2 { int x, y; } ans[MAXN]; bool cmp1(Node a, Node b) { return a.pos < b.pos; } bool cmp2(Node a, Node b) { return a.pos > b.pos; } map<int,...
### Prompt Your challenge is to write a CPP solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; class UnionFind { private: vector<int> p, rank; public: UnionFind(int N) { rank.assign(N + 1, 0); p.assign(N + 1, 0); for (int i = 0; i <= N; i++) p[i] = i; } int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); } bool isSameSet(int...
### Prompt Construct a CPP code solution to the problem outlined: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no co...
#include <bits/stdc++.h> using namespace std; static inline void canhazfast() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <typename T> T extgcd(T a, T b, T &x, T &y) { T x0 = 1, y0 = 0, x1 = 0, y1 =...
### Prompt Please create a solution in Cpp to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; struct dancer { int p, t, ind; dancer() = default; bool operator<(const dancer& x) const { return t < x.t || t == x.t && p < x.p; } }; int main() { ios_base::sync_with_stdio(false); int n, w, h; cin >> n >> w >> h; vector<dancer> ver, hor; ver.reserve(...
### Prompt Your task is to create a Cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen t...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 100; vector<int> ver[MAXN]; int g[MAXN], p[MAXN], t[MAXN]; pair<int, int> res[MAXN], ans[MAXN]; bool cmp1(int a, int b) { if (g[a] != g[b]) return g[a] > g[b]; return (p[a] < p[b]) ^ (g[a] == 1); } bool cmp2(int a, int b) { if (g[a] != g[b]) ret...
### Prompt Construct a CPP code solution to the problem outlined: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no co...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000 + 10; int g[MAXN], p[MAXN], t[MAXN]; map<int, int> mp; vector<int> gg[MAXN]; pair<int, int> ans[MAXN]; int n, w, h; int cmp(int a, int b) { if (g[a] < g[b]) return 1; if (g[a] > g[b]) return 0; if (g[a] == 1) return p[a] < p[b]; return p[a] >...
### Prompt Please create a solution in Cpp to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; bool B[N]; int A[N], n, X, Y, t, tmp, tmp2; vector<int> D[2 * (N + 10)]; pair<int, int> ans[N]; bool cmp(int a, int b) { if (B[a] != B[b]) return (B[a]); return (B[a] ? A[a] < A[b] : A[a] > A[b]); } int main() { scanf("%d %d %d", &n, &X, &Y); ...
### Prompt Your task is to create a cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen t...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization("unroll-loops") using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, w, h; cin >> n >> w...
### Prompt In cpp, your task is to solve the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no coll...
#include <bits/stdc++.h> using namespace std; int n, w, h; int g[100001]; int p[100001]; int t[100001]; int ans[100001]; vector<pair<int, int> > t_p; vector<int> tmp; vector<pair<int, int> > from; vector<pair<int, int> > to; int main() { scanf("%d %d %d", &n, &w, &h); for (int i = 0; i < n; i++) { scanf("%d %d ...
### Prompt Create a solution in CPP for the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no colli...
#include <bits/stdc++.h> const int N = 2e5; int n, w, h; std::pair<int, int> ans[N + 5]; std::vector<int> p[N + 5], q[N + 5]; struct People { int opt, t, x; } a[N + 5]; int main() { scanf("%d%d%d", &n, &w, &h); std::vector<int> vec; for (int i = 1; i <= n; i++) { scanf("%d%d%d", &a[i].opt, &a[i].x, &a[i].t)...
### Prompt Your task is to create a Cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen t...
#include <bits/stdc++.h> using namespace std; int n, w, h; struct ed1 { int x, y, clas, id, ANSx, ANSy; } p[2000099]; struct ed2 { int x, y, clas; } ans[2000099]; bool cmp1(const ed1 &A, const ed1 &B) { if (A.clas != B.clas) return A.clas < B.clas; return A.x < B.x; } bool cmp2(const ed2 &A, const ed2 &B) { i...
### Prompt Your task is to create a CPP solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen t...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 9; int n, w, h; struct pp { int op, p, t, id, val; } p[N]; bool cmp(pp x, pp y) { return x.val == y.val ? (x.op == y.op ? (x.p < y.p) : (x.op < y.op)) : (x.val < y.val); } deque<int> q; pair<int, int> ans[N]; int main() { sc...
### Prompt Your task is to create a CPP solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen t...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; const int ZERO = 2e5 + 5000; int n, w, h; struct node { int id, x, t; node() {} node(int _id, int _x, int _t) : id(_id), x(_x), t(_t) {} bool operator<(const node &a) const { return x < a.x; } } X[MAXN]; vector<node> Y[MAXN * 4]; int cnt[MA...
### Prompt Generate a Cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisi...
#include <bits/stdc++.h> using namespace std; long long n, w, h; long long g[100005], p[100005], t[100005]; map<long long, vector<pair<long long, long long> > > mp; pair<long long, long long> ans[100005]; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> w >> h; for (long long(i) = (1); (i) <= (...
### Prompt Develop a solution in CPP to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; struct node { int a, b, c, num; bool operator<(const node &y) const { if (c == y.c) { if (a == y.a) return b < y.b; return a < y.a; } return c < y.c; } } f[maxn]; int posx[maxn], posy[maxn], pos[maxn]; int main() { ...
### Prompt Generate a Cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisi...
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 123; const int M = 123; const long double Pi = acos(-1); const long long Inf = 1e18; const int inf = 1e9; const int mod = 1e9 + 7; const int Sz = 501; const int MOD = 1e9 + 7; const long double eps = 1e-9; void add(int &a, int b) { a += b; if (a >= m...
### Prompt Please provide a Cpp coded solution to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; int main() { pair<long double, long double> dest[100005]; long long int my[100005]; long long int gi[100005]; long long int pi[100005]; long long int ti[100005]; long long int n, w, h; cin >> n >> w >> h; map<long long int, vector<long long int> > verhorz; ...
### Prompt Construct a CPP code solution to the problem outlined: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no co...
#include <bits/stdc++.h> using namespace std; inline double POWER(double a) { return a * a; } inline long long _abs(long long a) { return a < 0 ? -a : a; } inline int _abs(int a) { return a < 0 ? -a : a; } inline long long power(long long a) { return a * a; } inline int power(int a) { return a * a; } inline long long g...
### Prompt Generate a CPP solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisi...
#include <bits/stdc++.h> using namespace std; const int N = 100001; vector<pair<int, pair<int, int> > > points; map<int, int> M; vector<int> actual[N << 2]; vector<int> mirror[N << 2]; bool cmp1(int i, int j) { pair<int, pair<int, int> > a = points[i]; pair<int, pair<int, int> > b = points[j]; if (a.first != b.fi...
### Prompt Generate a cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisi...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, w, h; pair<int, int> wyn[N]; vector<pair<pair<int, int>, pair<int, int>>> v[2 * N]; int main() { scanf("%d%d%d", &n, &w, &h); for (int i = 1; i <= n; ++i) { int g, p, t; scanf("%d%d%d", &g, &p, &t); v[p - t + N].push_back(make_p...
### Prompt Please formulate a cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; const int Maxk = 1005; string mul(string a, string b) { int res[Maxk]; memset(res, 0, sizeof(res)); reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); for (int i = 0; i < a.length(); i++) { for (int j = 0; j < b.length(); j++) { res[i + j] += (a[i...
### Prompt Develop a solution in Cpp to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no...
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 5; vector<long long> V, H; unordered_map<long long, vector<long long>> G; unordered_map<long long, long long> sz; unordered_map<long long, vector<long long>>::iterator it; long long a[N][3], ans[N]; bool comp(int i, int j) { pair<long long, long ...
### Prompt Please provide a Cpp coded solution to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; int n, w, h, g[110000], p[110000], t[110000], a[110000], b[110000]; set<int> sx[2 * 110000], sy[2 * 110000]; map<pair<int, int>, int> ansx; map<pair<int, int>, int> ansy; int main() { scanf("%d%d%d", &n, &w, &h); for (int i = 1; i <= n; i++) { scanf("%d%d%d", &g[i],...
### Prompt Generate a cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisi...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7; int p[N], t[N]; int g[N]; int n, w, h; int res[N][2], fin[N][2]; map<int, vector<int> > mp[2]; set<int> ts; int main() { scanf("%d %d %d", &n, &w, &h); for (int i = 0; i < n; i++) { scanf("%d %d %d", &g[i], &p[i], &t[i]); g[i]--; int c...
### Prompt Your challenge is to write a cpp solution to the following problem: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...
#include <bits/stdc++.h> using namespace std; int n, w, h; map<int, vector<pair<int, int>>> dancer; pair<int, int> ans[100000]; int main() { scanf("%d%d%d", &n, &w, &h); for (int i = 0; i < n; i++) { int g, p, t; scanf("%d%d%d", &g, &p, &t); int x, y; if (g == 2) x = -t, y = p; else ...
### Prompt Please provide a Cpp coded solution to the problem described below: Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be se...