Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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); ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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 ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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)...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); new Main().run(in, out); out.close(); } public static long mod =...
JAVA
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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) <= (...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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() { ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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; ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
def read_ints(): return [int(i) for i in input().split()] n, w, h = read_ints() tanc = [read_ints() for i in range(n)] vert = [(k[0], k[1], k[2], i) for i, k in enumerate(tanc) if k[0] == 1] hor = [(k[0], k[1], k[2], i) for i, k in enumerate(tanc) if k[0] == 2] vert_st = dict() for v in vert: st = v[1] - v[2] if s...
PYTHON3
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
import java.io.*; import java.util.*; import static java.math.BigDecimal.valueOf; public class Solution { static MyScanner sc; private static PrintWriter out; static long M2 = 1_000_000_000L + 7; public static void main(String[] s) throws Exception { StringBuilder stringBuilder = new StringBu...
JAVA
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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 ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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],...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
import java.util.*; public class d{ static int W, H; static class Dancer{ int dex; int type; int x, y, xy; int[] across = new int[2]; int[] dest = new int[2]; Dancer(int dex, int type, int coord, int time){ this.dex = dex; this.type = type; if(type == 2){ x = -time; y = coord; across[...
JAVA
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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 ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 100010; struct node { int first, second, z; bool operator<(const node &a) const { return first - second < a.first - a.second || (first - second == a.first - a.second && first < a.first); } } a[N], b[N]; pair<int, int> ans[N]; int main() { ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 100010; pair<int, int> fim[N]; map<int, vector<pair<int, int> > > grupos[2]; int ans[N]; int n, w, h; void calc_fim(int tipo, int first, int i) { if (tipo == 0) { fim[i] = make_pair(first, h); } else { fim[i] = make_pair(w, first); } } int main()...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; pair<int, int> P[100010]; map<int, vector<int>> m1, m2; struct Vertical { int x, t, id; bool operator<(const Vertical& rhs) const { return x < rhs.x; } }; struct Horizon { int x, t, id; bool operator<(const Horizon& rhs) const { return t < rhs.t; } }; vector<Vertica...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; template <class TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << "=" << h << "\n"; } template <class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) { while (*sdbg != ',') cerr << *sdbg++; cerr << "=" << h << ","; _dbg(sdbg + 1, a...); } int test;...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> #pragma comment(linker, "/stack:16777216") using namespace std; const int INF = 1000000000; const int BASE = 1000000007; const int MAX = 100007; const int MAX2 = 10007; const int MAXE = 100000; const int ADD = 1000000; const int MOD = 1000000007; const int CNT = 0; pair<int, int> res[MAX]; int ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 100; pair<int, int> gl[maxn], ans[maxn]; vector<int> g[3][2 * maxn + 100]; pair<pair<int, int>, pair<int, int> > in[maxn]; int main() { ios_base::sync_with_stdio(false); int n, w, h; int pos = 1e5; cin >> n >> w >> h; for (int i = 1; i <= n;...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; pair<int, int> ans[100005]; vector<pair<int, pair<int, int> > > v[2]; int main() { int n, w, h; scanf("%d%d%d", &n, &w, &h); for (int i = 0; i < n; i++) { int aa, bb, cc; scanf("%d%d%d", &aa, &bb, &cc); aa--; v[aa].push_back({bb - cc, {bb, i}}); } ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast,no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; template <typename T> void read(T &a) { T x = 0, f = 1; char ch = getchar(); while (ch < '0' || c...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, x, y; cin >> n >> x >> y; map<int, vector<pair<int, int>>> g1; map<int, vector<pair<int, int>>> g2; for (int i = 0; i < n; i++) { int g, p, t; cin >> g >> p >> t; if (g == 1) { ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; struct Node { int x, y; int val; int g; } node[MAXN], res[MAXN]; int p[MAXN]; bool cmp(int a, int b) { if (node[a].val == node[b].val) { if (node[a].x == node[b].x) return node[a].y > node[b].y; return node[a].x < node[b].x; } ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; int pos[200005][2], flip[200005]; vector<pair<int, int> > V[200005], H[200005]; int main() { int N, w, h; 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); flip[i] = i; if (g == 1) { pos[i][...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; struct P { int g, p, t, id, c; void input(int i) { scanf("%d%d%d", &g, &p, &t); id = i; c = p - t; } bool operator<(const P& b) const { if (c != b.c) return c < b.c; if (g != b.g) return g < b.g; if (g == 1) return p < b.p; return p > b.p...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; map<int, deque<int>> mp; int n, w, h, ansx[N], ansy[N], temp[N]; struct node { int g, p, t, id; bool operator<(const node& a) const { return p < a.p; } } q[N]; void cal(int a, int b) { for (int i = 1; i <= n; i++) if (q[i].g == a) mp[q[i].t...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:102400000,102400000") template <class T> inline void gmax(T &a, T b) { if (b > a) a = b; } template <class T> inline void gmin(T &a, T b) { if (b < a) a = b; } using namespace std; const int N = 1e5 + 10, M = 2e6 + 10, Z = 1e9 + 7, maxint = 2147483647, ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
import os,io input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline n,w,h=map(int,input().split()) dic={} ansx=[0]*n ansy=[0]*n for i in range(n): g,x,t=map(int,input().split()) if x-t in dic: dic[x-t][g-1].append([x,i]) else: dic[x-t]=[] dic[x-t].append([]) dic[x-t].append([]) dic[x-t][g-1...
PYTHON3
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, w, h, g[N], lis1[N], c1, lis2[N], c2, body[N]; struct ray { bool ver; int p, t; pair<int, int> direct() { if (ver) return pair<int, int>(p, h); else return pair<int, int>(w, p); } } a[N]; list<int> que[N]; pair<int,...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int INF = 1 << 30; int MAXN = 1e7 + 2; const double eps = 1e-13; map<int, vector<pair<int, int> > > di; map<pair<int, int>, int> ptoi; pair<int, int> p[100009]; pair<int, int> ans[100009]; int main() { int n, w, h; scanf("%d%d%d", &n...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 88; struct _dance { int x, t, no; }; struct _point { int x, y; }; int readint() { int cur; scanf("%d", &cur); return cur; } bool cmp(_dance i, _dance j) { return i.x < j.x; } queue<int> q[2 * maxn], pos[2 * maxn]; vector<_dance> x, y; _point...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
import java.util.*; import java.io.*; public class Rooter { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (s...
JAVA
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; int n, w, h; struct node { int tag, l, t, id; } rec[105000]; int x[105000], y[105000]; int id[105000]; int pp[105000]; bool cmp(node a, node b) { if (a.l - a.t == b.l - b.t) { if (a.tag == b.tag) { return a.l < b.l; } return a.tag < b.tag; } return...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; int g[100100], p[100100], t[100100], id[100100]; bool cmp(int u, int v) { if (t[u] != t[v]) return t[u] < t[v]; if (g[u] != g[v]) return g[u] > g[v]; if (g[u] == 2) return p[u] > p[v]; return p[u] < p[v]; } pair<int, int> ans[100100]; vector<int> adj; int main() { ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
import java.io.*; import java.util.*; public class MainB { public static void main(String[] args) { StdIn in = new StdIn(); int n=in.nextInt(), w=in.nextInt(), h=in.nextInt(); Dancer[] dancers = new Dancer[n]; for(int i=0; i<n; ++i) dancers[i] = new Dancer(in.nextInt(), in.nextInt(), in.nextInt()); //f...
JAVA
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long M = 1e5 + 7; long long p[M], g[M], t[M]; map<long long, vector<long long> > mpx, mpy; bool cmp(long long a, long long b) { return p[a] < p[b]; } pair<long long, long long> kq[M]; int main() { long long n, w, h; cin >> n >> ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> const int maxn = 1e5 + 5; using namespace std; int n, h, w, cnt0, cnt1; struct node { int x, num, tim; node() {} node(int _x, int _tim, int _num) { x = _x; num = _num; tim = _tim; } bool operator<(const node &a) const { if (tim != a.tim) return tim < a.tim; e...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7; const int N = 100000 + 10; const int NN = 100000; struct Node { int id, x, y; Node() {} Node(int id, int x, int y) : id(id), x(x), y(y) {} }; vector<Node> pa[N * 2], a[N * 2], b[N * 2]; int n, W, H; Node ans[N * 2]; bool cmp_a(Node a, Node b) { ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
import java.io.*; import java.util.*; public class B_new { static class Dancer { int type; int x; int id; int initPos; public Dancer(int type, int x, int id) { this.type = type; this.x = x; this.id = id; } } int[] xs; int[] ys; int n, w, h; void go(ArrayList<Dancer> lst) { Collecti...
JAVA
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int N, w, h; struct Dancer { int group, p, t, id; } D[maxn]; vector<Dancer> coll[maxn << 1]; bool cmp1(const Dancer &a, const Dancer &b) { if (a.group != b.group) return a.group < b.group; if (a.group == 1) return a.p < b.p; else ret...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; int n, w, h; unordered_map<int, vector<pair<int, int>>> starts; unordered_map<int, vector<pair<int, pair<int, int>>>> endss; pair<int, int> results[100001]; int main() { cin >> n >> w >> h; for (int i = 0; i < n; i++) { int g, p, t; cin >> g >> p >> t; if (g...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; struct node { int x, y, id; bool operator<(const node& e) const { if (x == e.x) return y > e.y; return x < e.x; } }; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, w, h; cin >> n >> w >> h; vector<vector<node>> a(200005); for (int i = 0; ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const int MAXN = 1e5 + 7; const double EPS = 1e-8; const int LOGN = 30; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, w, h; cin >> n >> w >> h; vector<vector<pair<int, int> > > points1(2 * MAXN), points2(2 * ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; namespace ioput { template <typename T> T read() { T x = 0, f = 1; char c = getchar_unlocked(); while ((c < '0') || (c > '9')) { if (c == '-') f = -1; c = getchar_unlocked(); } while ((c >= '0') && (c <= '9')) x = (x << 1) + (x << 3) + (c ^ 48), c = ge...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int MOD2 = 1007681537; const int INF = (int)1e9; const long long LINF = (long long)1e18; const long double PI = acos((long double)-1); const long double EPS = 1e-9; inline long long gcd(long long a, long long b) { long long r; while (...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
import java.util.*; import java.awt.PageAttributes; import java.io.*; public class _0848_B_RootersSong { static class Trio implements Comparable<Trio>{ int x, y, id; public Trio(int x, int y) { this.x = x; this.y = y; } public Trio(int x, int y, int id) { this.x = x; this.y = y; this.id = id; } ...
JAVA
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; int n, w, h, g[100005], pos[100005], t[100005]; pair<int, int> sol[100005]; map<int, vector<int> > m; bool Comp(int a, int b) { return pos[a] < pos[b]; } pair<int, int> getSol(int idx) { if (g[idx] == 1) return make_pair(pos[idx], h); return make_pair(w, pos[idx]); } vo...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; struct node { int id, g, p, t; bool operator<(const node &rhs) const { return p - t < rhs.p - rhs.t; } void read(int id_) { scanf("%d%d%d", &g, &p, &t); id = id_; } } per[(100000 + 5)], g1[(100000 + 5)], g2[(100000 + 5)]; bool cmp(node a, node b) { return a....
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 100006; int g[N], p[N], t[N]; int x[N], y[N]; vector<int> v[2 * N]; pair<int, int> ans[N]; int main() { int q, h, w; scanf("%d %d %d", &q, &h, &w); for (int i = 1; q >= i; i++) { scanf("%d %d %d", &g[i], &p[i], &t[i]); if (g[i] == 1) { x[i]...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 1; int n, w, h; pair<int, int> ans[N]; vector<pair<int, int> > d[N][2]; void input() { cin >> n >> w >> h; for (int i = 0; i < n; ++i) { int p; cin >> p; int x; cin >> x; int t; cin >> t; d[t - x + (N >> 1)][p == 1].push_b...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> int main() { int n, w, h; scanf("%d%d%d", &n, &w, &h); std::map<int, std::vector<std::pair<int, int>>> map[2]; std::set<int> keys; for (int i = 0; i < n; ++i) { int g, p, t; scanf("%d%d%d", &g, &p, &t); map[g - 1][p - t].emplace_back(p, i); keys.emplace(p - t); } s...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, w, h, g, t, p; struct Node { int g, t, p, id; Node() {} Node(int id, int g, int p, int t) : id(id), g(g), t(t), p(p) {} int ord() const { return p - t; } pair<int, int> getEnd() { if (g == 1) { return {p, h}; } else { ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using db = double; int n, w, h; struct Obj { int g, p, t, id; }; const int mxn = 100006; int x[mxn]; int y[mxn]; unordered_map<int, vector<Obj>> s; int main() { cin >> n >> w >> h; for (int i = 0; i < n; ++i) { int g, ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int NR = 1e5 + 10; void Min(int& x, int y) { x = min(x, y); } void Max(int& x, int y) { x = max(x, y); } int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && c...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; int Y[] = {-1, 1, 0, 0, -1, -1, 1, 1}; int X[] = {0, 0, -1, 1, -1, 1, -1, 1}; int directions = 4; long long power(long long a, long long n) { if (a == 0) return 0; if (a == 1 || n == 0) return 1; if (n == 1) return a % 1000000007; long long t = power(a, n / 2); t ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; vector<vector<long long> > mul(vector<vector<long long> > a, vector<vector<long long> > b) { vector<vector<long long> > c; c.resize(a.size()); for (int i = 0; i < c.size(); i++) c[i].resize(b[0].size(), 0); for (int i = 0; i < c.size()...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int INF = 0x3f3f3f3f; const int N = 1e5 + 9; const int shift = 1e5 + 9; const double Eps = 1e-9; struct node { int dir, p, t; } a[N]; int n, w, h; vector<int> v[N + shift], gx, gy; pair<int, int> ans[N]; bool cmp(int u, int v) { if (a...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int typ[N], x[N], t[N], v[N], id[N]; pair<int, int> ans[N], p[N]; int pn; int main() { int n, w, h; scanf("%d %d %d", &n, &w, &h); for (int i = 0; i < n; i++) { scanf("%d %d %d", typ + i, x + i, t + i); v[i] = x[i] - t[i]; id[i] = i...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; int main(int argc, char **argv) { int n, w, h; cin >> n >> w >> h; vector<vector<pair<int, pair<int, int>>>> finish(400000); vector<vector<pair<int, int>>> start(400000); vector<pair<int, int>> result(n); for (int i = 0; i < n; ++i) { int g, p, t, start_x, e...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:256000000") using namespace std; const long double PI = 3.14159265358979323846; const long double eps = 1e-5; const int INF = numeric_limits<int>::max(); const long long LINF = numeric_limits<long long>::max(); const long long mod = 1000 * 1000 * 1000 + 7; void s...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; long long gcd(long long n1, long long n2) { if (n2 == 0) return n1; if (n1 % n2 == 0) return n2; return gcd(n2, n1 % n2); } long long powmod(long long base, long long exponent) { long long ans = 1; while (exponent) { if (exponent & 1) ans = (ans * base) % 1000...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; bool fuckingGoodComp(pair<int, pair<int, int> > first, pair<int, pair<int, int> > second) { return first.second.first < second.second.first; } void solve(vector<pair<int, pair<int, int> > > group, int sol[][2], const int width, const int he...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; map<int, pair<vector<pair<int, int> >, vector<pair<int, int> > > > mapp; int g[100010], p[100010], t[100010]; pair<int, int> ans[100010]; int main() { int n, w, h, i, j; scanf("%d", &n); scanf("%d", &w); scanf("%d", &h); for (i = 0; i < n; i++) { scanf("%d", &...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using db = double; const int N = 2e5L + 11; int g[N], p[N], t[N]; map<int, vi> mp[3]; int x[N], y[N]; bool cmp(int i, int j) { return p[i] < p[j]; } using pii = pair<int, int>; bool cmp2(pii a, pii b) { if (a.second == b.secon...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int MAXT = 100000; const int MAXN = 200005; int g[MAXN], p[MAXN], t[MAXN]; vector<int> x[MAXN], y[MAXN]; int ansx[MAXN], ansy[MAXN]; bool comp(int x, int y) { return p[x] < p[y]; } int main() { int n, w, h; scanf("%d%d%d", &n, &w, &h); for (int i = 1; i <= n; i+...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> const int maxn = 100010; int n, w, h, ans[maxn]; struct pos { int x, y; } Pos[maxn]; struct lr { int i, p, t, ty, x; bool operator<(const lr &a) const { return ty != a.ty ? ty < a.ty : p < a.p; } } a[maxn], b[maxn], x[maxn], tmp[maxn]; int main() { scanf("%d%d%d", &n, &w, &h); for (in...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 100005, inf = 0x3f3f3f3f; const long long llinf = 0x3f3f3f3f3f3f3f3f; const long double pi = acos(-1.0L); int x[maxn], y[maxn], b[maxn], c[maxn]; struct Dancer { int g, p, t, id; }; Dancer a[maxn]; bool cmp(Dancer a, Dancer b) { return a.t - a.p < b.t -...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 200000 + 20; struct node { int id, y; friend bool operator<(const node& a, const node& b) { return a.y < b.y; } } no; int n, w, h; pair<int, int> ans[N]; int p[N]; set<node> a[N], s[N]; set<node>::iterator ita, its; set<int> y[N]; set<int>::iterator it; in...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int M = 400010, mod = 1000000007; map<int, vector<pair<int, pair<int, int> > > > mep; vector<pair<int, int> > first, second; vector<pair<int, int> > a, b; pair<int, int> ans[M]; int n, w, h; void solve_for(vector<pair<int, pair<int, int> > > A) { int i, j, k; firs...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; pair<int, int> endpos[100000]; vector<pair<pair<int, int>, int> > vs[200020]; int _harr[200020]; int poschg[100000]; int func(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) { if (a.first.first != b.first.first) { return a.first.first > b.first.first; } ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const long double PI = 3.14159265359; const long long MOD = (long long)998244353ll; const long long MAXN = (long long)1e5 + 10; const long long INF = (long long)9223372036854775; const long double EPS = (long double)1e-8; vector<long long> dan[2 * MAXN]; vector<pair<long lo...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; stringstream output; inline void eOP(); int main() { int n, w, h; cin >> n >> w >> h; map<int, map<int, int>> data; for (int i = 0; i < n; ++i) { int g, p, t; cin >> g >> p >> t; int x, y; switch (g) { case 1: x = p; y = -t; ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
class Dancer: def __init__(self, group, i, pos, t0): self.group = group self.i = i self.pos = pos self.t0 = t0 n, w, h = [int(x) for x in raw_input().split()] dancers = [] dancers_by_vpos = {} for i in range(n): g, p, t = [int(x) for x in raw_input().split()] dancer = Dancer...
PYTHON
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
import java.awt.geom.Line2D; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.u...
JAVA
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 5; int N, W, H, p[MAX], q[MAX], ans[MAX][2], who[MAX]; vector<pair<int, int> > xx, yy; vector<int> X[MAX * 2], Y[MAX * 2]; int main() { scanf("%d%d%d", &N, &W, &H); for (int i = 0; i < N; ++i) { int g; scanf("%d%d%d", &g, &p[i], &q[i]); ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.PrintStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import java.io.BufferedReader; i...
JAVA
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.io.IOException; import java.util.stream.Collectors; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.stream.Stream...
JAVA
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#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]; inline 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, ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int off = 1e5; queue<int> p[200005], v[200005]; int g, c, t; int ax[100005], ay[100005]; int n, w, h; vector<pair<int, pair<int, int> > > a, b; int main() { scanf("%d %d %d", &n, &w, &h); for (int i = 0; i < n; i++) { scanf("%d %d %d", &g, &c, &t); if (g =...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; int n, w, h; vector<pair<pair<int, int>, int>> dancers; map<int, vector<pair<pair<int, int>, int>>> groups; bool comp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) { return (a.first).second < (b.first).second; } vector<pair<int, int>> f() { vector<pair<int, ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; int n, w, h; int g[200001], p[200001], t[200001]; int a[200001]; int b[200001]; int x[200001], y[200001]; void qsort(int l, int r) { int i = l, j = r, q; int k = i + rand() % (j - i + 1); int m1 = g[k], m2 = p[k]; int m0 = a[k]; while (i <= j) { while (a[i] < ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; struct Dancer { int x, y, idx, g; Dancer() { x = y = idx = g = 0; } Dancer(int _x, int _y, int _g, int _idx) { x = _x, y = _y, g = _g, idx = _idx; } }; vector<Dancer> bucket[100010]; map<int, int> buck; pair<int, int> rez[100010]; int k = 0; bool cmp(Dancer a, D...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collections; import java.util.StringTokenizer; public clas...
JAVA
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
# https://codeforces.com/problemset/problem/848/B def push(d, val, type_, arr): # pos index type_ %= 2 if val not in d: d[val] = [[],[]] d[val][type_].append(arr) d = {} n, w, h = map(int, input().split()) for index in range(n): g, p, t = map(int, input().split()) push(d, p-t, g, [p ,...
PYTHON3
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } int h, w, n, R[131072 *...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int mx = 1e5; int n, w, h, g, p, t, x[N], y[N]; int read() { int x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, w, h, g[N], x[N], t[N], idx[N]; map<int, vector<int> > hs; void solve() { scanf("%d%d%d", &n, &w, &h); for (int i = 0; i < n; i++) { scanf("%d%d%d", &g[i], &x[i], &t[i]); hs[x[i] - t[i]].push_back(i); } for (auto vec : hs) { ...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
#include <bits/stdc++.h> using namespace std; int n, w, h, an[3][100005], now[100005], cnt = 1, cnt1 = 1, cnt2 = 1, lol[100005]; pair<pair<int, int>, pair<int, int> > pr[100005]; map<int, int> mp[3]; vector<int> vt[3][100005], v; void process(int ex, int wye) { int tmp, siz1 =...
CPP
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
from collections import namedtuple Dancer = namedtuple('Dancer', ['category', 'x', 'y', 'idx', 'group']) def read_dancer(idx): group, pos, time = [int(x) for x in input().split(' ')] x, y = None, None if group == 1: x, y = pos, 0 else: x, y = 0, pos return Dancer(time-pos, x, y, idx, group) n, w, h = [int(x...
PYTHON3
848_B. Rooter's Song
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 collisions will happen before one enters the stage. On the sides of t...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import java.io.BufferedReader; impo...
JAVA