prompt
string
response
string
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; const long long MN = numeric_limits<long long>::min(); template <typename T> struct convex_hull { vector<pair<T, T> > cvh; void pushBack(pair<T, T> a) { while (cvh.size() > 1) { pair<T, T> &b = cvh[cvh.size() - 1]; pair<T, T> &c = ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; long double safe_sqrt(long double x) { return sqrt(max((long double)0.0, x)); } long long GI(long long& x) { return scanf("%lld", &x); } const long long INF = 1000111000111000111LL; const long long MN = 300111; struct Line { long long a, b; long long from, to; } lines[M...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; bool Q; struct Line { mutable long long k, m, p; bool operator<(const Line& o) const { return Q ? p < o.p : k < o.k; } }; struct HullDynamic : multiset<Line> { const long long inf = LLONG_MAX; long long div(long long a, long long b) { return a / b - ((a ^ b) < 0...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; import java.util.TreeSet; public class CF_678F2 { static long NULL = -2_000_000_0...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> int sgn(int a) { if (!a) return 0; if (a > 0) return 1; return -1; } int di(int a, int b) { if (!a) return 0; if (sgn(a) == sgn(b)) return a / b; return a / b - 1; } struct query { int t, a, b; }; const int N = 300000; const int K = 8200; int n; long long ans[N]; query q[N]; bool ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int N = 300100; const int M = 1000100; const int K = 200100; const int oo = 2e9; const long long OO = 2e18; const int PW = 20; const int md = 1000000007; int tp[N], q, BLOCK, tt, siz, TT, mrk[N], vc[N], vec[N]; long long x[N], y[N], vl[N], fr[N], X[N], Y[N]; multiset<...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; constexpr int N = 300005; struct convex_hull { struct line { long long a, b; line(long long _a = 0, long long _b = 0) { a = _a, b = _b; } long long f(int x) { return a * x + b; } }; using float_type = __int128_t; float_type one = 1; bool bad(const line...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; struct jdb { int x, y; friend long long operator^(const jdb &a, const jdb &b) { return 1ll * a.x * b.y - 1ll * a.y * b.x; } friend long long operator*(const jdb &a, const jdb &b) { return 1ll * a.x * b.x + 1ll * a.y * b.y; } friend bool operator<(const j...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; struct node { long long x, y; void input() { scanf("%I64d%I64d", &x, &y); } node operator+(const node& tt) const { return node(x + tt.x, y + tt.y); } node operator-(const node& tt) const { return node(x - tt.x, y - tt.y); } long long operator^(const node& tt) cons...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; static const int maxn = 4e5 + 5; static const long long int is_query = LLONG_MIN; struct Line { long long int m, b; mutable function<const Line *()> succ; bool operator<(const Line &rhs) const { if (rhs.b != is_query) return m < rhs.m; const Line *s = succ(); ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int MAXN = 4e5 + 10; const long long INF = 2e18; const long double EPS = 1e-9; struct Line { int a, b; long double inter(const Line& l) const { assert(a != l.a); return (long double)(l.b - b) / (a - l.a); } Line() {} Line(int a, int b) : a(a), b(b) {...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.PrintStream; import java.util.Arrays; import java.io.BufferedInputStream; import java.util.concurrent.Callable; import java.util.InputMismatchException; import java.io.IOException; import java...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; const long long N = 1; const long long big = 6e18; long long block = 800; const long long mod = 1e6; long long n; set<pai...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; long long read() { long long a = 0, b = getchar(), c = 1; while (!isdigit(b)) c = b == '-' ? -1 : 1, b = getchar(); while (isdigit(b)) a = a * 10 + b - '0', b = getchar(); return a * c; } const int M = 3e5 + 5; struct node { long long x, y, id; bool operator<(co...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int N = 300100; const int M = 1000100; const int K = 200100; const int oo = 2e9; const long long OO = 2e18; const int PW = 20; const int md = 1000000007; int tp[N], q, BLOCK, tt, siz, TT, mrk[N], vc[N], vec[N]; long long x[N], y[N], vl[N], fr[N], X[N], Y[N]; multiset<...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int N = 301010; const int K = (int)log2(N) + 2; const int SQRTN = (int)sqrt(N) + 7; const long long infi = 1ll << 63; long long n, t[N], a[N], b[N], sz, ans[N], mn, mx; set<long long> remprev, rem; const long long is_query = -(1LL << 62); struct Line { long long m, ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; struct node { int x, y, id; bool operator<(const node &A) const { if (x != A.x) return x < A.x; return y < A.y; } } s[300005]; int O[300005], Q[300005], ki[300005], st[300005], ed[300005]; long long ans[300005]; void Max(long long &a, long long b) { if (a < ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; struct edge { int u, v; long long w; }; long long MOD = 1000000007; long long _MOD = 1000000009; double EPS = 1e-10; int INF = INT_MAX / 2; int B = 1000; bool f(pair<int, int>& p, pair<int, int>& q, pair<int, int>& r) { long long dx1 = q.first - p.first, dy1 = q.secon...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
import java.util.*; import java.io.*; /* 7 3 1 1 2 3 3 1 1 -1 100 3 1 2 4 3 1 48 3 -99 1 -1 32 2 2 1 -18 -86 2 4 3 -32 1 -21 -38 1 -60 -96 3 37 2 8 3 56 3 -72 1 -91 -7 1 21 -41 3 -59 3 -12 3 -33 3 -75 3 -7 2 7 2 14 2 13 3 -49 1 -79 -94 2 24 1 37 -39 3 60 3 93 2 26 1 34 72 3 -73 1 42 76 3 -17 1 64 64 1 17 -90 2 32 2 3...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const long long inf = 2e18; struct cht { vector<pair<int, int> > hull; int cur = 0; cht() { hull.clear(); } bool useless(const pair<int, int> left, const pair<int, int> middle, const pair<int, int> right) { return 1LL * (middle.second - left.secon...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; static const int maxn = 4e5 + 5; static const long long int is_query = LLONG_MIN; struct Line { long long int m, b; mutable function<const Line *()> succ; bool operator<(const Line &rhs) const { if (rhs.b != is_query) return m < rhs.m; const Line *s = succ(); ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int N = 1 << 19; int n; int C[N], x1[N], x2[N]; bool dead[N]; class line { public: int m, n; line() {} line(int m, int n) { this->m = m; this->n = n; } double intersect(line oth) { return (double)(n - oth.n) / (oth.m - m); } bool operator<(line ot...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.PrintStream; import java.util.Arrays; import java.io.BufferedInputStream; import java.util.concurrent.Callable; import java.util.InputMismatchException; import java.io.IOException; import java...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; template <typename T> inline T read(T& x) { x = 0; int f = 0; char ch = getchar(); while (ch < '0' || ch > '9') f |= (ch == '-'), ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x = f ? -x : x; } const int N = 3e5 + 1...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const long long inf = 2e18; struct cht { vector<pair<int, int> > hull; int cur = 0; cht() { hull.clear(); } inline bool useless(const pair<int, int> &left, const pair<int, int> &middle, const pair<int, int> right) { return 1LL * (middle.sec...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 2; const int M = 4e6 + 2; const long long mod = 1e9 + 7; const int inf = 2e9 + 3; const long long INF = 3e18; void data() {} int n, dl[N], block = 5000, cnt; set<pair<pair<long long, long long>, pair<long long, long long>>> al; vector<pair<pair<long long...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> const int N = 3e5 + 10; const int64_t inf = 1LL << 60; inline int read() { int x = 0, f = 0; char ch = getchar(); while (!isdigit(ch)) f |= ch == '-', ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return f ? -x : x; } struct node { int a, b, l, r; inli...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; inline char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } inline int read() { int x = 0; char ch = getchar(); bool positive = 1; for ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> #pragma GCC optimize(3) #pragma GCC optimize(2) using namespace std; const long long inf = 2e18 + 17; struct line { long long m, b; }; long long floordiv(long long a, long long b) { return a / b - (a % b && ((a < 0) ^ (b < 0))); } long long intersect(line a, line b) { return floordiv(b.b - ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
//package educational.round13; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; public class F { InputStream is; PrintWriter out; String INPUT = ""; ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; struct Node { long long x, y; Node(int a = 0, int b = 0) { x = a, y = b; } bool operator<(const Node &b) const { if (x == b.x) return y < b.y; else return x < b.x; } Node operator-(const Node &b) const { return Node(x - b.x, y - b.y); } long ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int N = 300005; struct line { long long a, b; int s, e; bool operator<(const line t) const { return a < t.a; } }; struct convexhull_trick { int s, e; line deq[N]; int size() { return e - s; } void insert(line v) { deq[e] = v; while (s + 1 < e && ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const long long N = 1; const long long big = 6e18; long long block = 800; const long long mod = 1e6; long long n; set<pair<long long, long long> > a; vector<pair<long long, pair<long long, long long> > > t; set<pair<long long, pair<long long, long long> > > cht; vector<pair...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const long long oo = 2E18; const int None = 1E9 + 10; struct point { long long x, y; point(long long _x = 0, long long _y = 0) { x = _x, y = _y; } point operator-(const point& w) const { return point(x - w.x, y - w.y); } point operator+(const point& w) const { retur...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const long long inf = 2e18; struct cht { vector<pair<int, int> > hull; int cur = 0; cht() { hull.clear(); } bool useless(const pair<int, int> left, const pair<int, int> middle, const pair<int, int> right) { return 1LL * (middle.second - left.secon...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; const long long N = 3e5 + 5, oo = 2e18; long long n, block_size, ans[N], a[N], b[N], type[N], time_end[N], n1, n2, pr...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; using ll = long long; struct Line { int m, b; ll evaluate(int x) { return static_cast<ll>(m) * x + b; } }; struct UpperHull { vector<Line> active; void insert(Line l) { while (active.size() >= 2 && supersedes(active.end()[-2], active.back(), l)) active.pop...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> struct point { int x, y; } p[300001]; int N, active[300001], right[300001], Q; int order[300001], L; struct query { int pos, x, id; } qry[300001], tmp[300001]; long long O[300001]; std::vector<int> T[1048576]; void P(int p, int l, int r, int L, int R, int id) { if (L <= l && r <= R) { ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int n0 = 1 << 19; const long long inf = 2e18; int n, alive[n0]; array<int, 3> qr[n0]; long long ans[n0]; struct Line { long long k, b; long long val(long long x) { return k * x + b; } long long ip(const Line &l) { return (l.b - b + (k - l.k - 1)) / (k - l.k); } ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; long long l[300005], r[300005], q[300005], ques[300005], mini = -2e18; pair<long long, long long> p[300005]; vector<long long> vp; vector<long long> v[1 << 20]; vector<double> vd[1 << 20]; bool cmp(long long x, long long y) { return p[x].first ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.PrintStream; import java.util.Arrays; import java.io.BufferedInputStream; import java.util.concurrent.Callable; import java.util.InputMismatchException; import java.io.IOException; import java...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 50; int n, cnt, x[N], y[N], s[N], t[N], q[N], m, p[N], L[N * 4], R[N * 4], tt[N], num; long long d, ans[N]; vector<int> v[N * 4]; int read() { int x = 0, f = 1; char c = getchar(); while (!isdigit(c)) c == '-' ? f = -1 : 0, c = getchar(); whi...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; import java.util.TreeSet; public class CF_678F2 { static long NULL = -2_000_000_0...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; mt19937 bruh(chrono::steady_clock::now().time_since_epoch().count()); mt19937_64 rofl(chrono::steady_clock::now().time_since_epoch().count()); const int N = 2e6 + 2; const int M = 1e5; const int mod = 0; const int inf = 1e9; const long long INF = 3e18 + 1; const int dx[4] =...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const long long inf = 3e18; const int inf2 = 1e9 + 2; const int mod = 1000000007; inline int mf(int a, int b) { int buf = 0; if (a % b != 0) buf++; if ((a >= 0 && b >= 0) || (a < 0 && b < 0)) return a / b + buf; return a / b; } const int dop = 800; pair<int, int> ma...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int N = 300005; struct Point { int x, y; Point(int _x = 0, int _y = 0) { x = _x; y = _y; } Point operator-(const Point &R) const { return Point(x - R.x, y - R.y); } long long operator^(const Point &R) const { return (long long)x * R.y - (long lon...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 20; const long long oo = 1e13 + 20; const int MOD = 1e9 + 7; struct line { long long m, b; long long eval(long long x) { return m * x + b; } }; struct cht { vector<line> lines; vector<double> inter; int n, i; double get_inter(line &a, line &b...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int M = 3e5 + 7; const int N = 1048583; const long long INF = 9187201950435737472; inline int ri() { int x = 0; bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const long long oo = 2E18; const int None = 1E9 + 10; struct point { long long x, y; point(long long _x = 0, long long _y = 0) { x = _x, y = _y; } point operator-(const point& w) const { return point(x - w.x, y - w.y); } point operator+(const point& w) const { retur...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; int const inf = 1000 * 1000 * 1000; long long const inf64 = 1ll * inf * inf; template <class T> struct ConvexHullTrick { size_t sz; vector<pair<T, T> > Lines, st; ConvexHullTrick() { sz = 0; } ConvexHullTrick(vector<pair<T, T> > _lines) : Lines(_lines) { sort((L...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; struct Point { long long x, y; Point() {} Point(long long a, long long b) : x(a), y(b) {} Point operator-(Point b) { return Point(x - b.x, y - b.y); } bool operator<(const Point& b) const { return (x != b.x) ? x < b.x : y < b.y; } }; inline long long cross(P...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; import java.util.TreeSet; public class CF_678F2 { static long NULL = -2_000_000_0...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int maxn = 300010; const long long INF = 2e18; int t[maxn]; long long a[maxn]; long long b[maxn]; bool ban[maxn]; long long ans[maxn]; long long ans2[maxn]; struct Point { long long x, y; Point(long long x, long long y) : x(x), y(y) {} Point() {} bool operator...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; int q, OP[300010][2]; struct Line { int k, b; double xLeft; bool type; Line(int _k = 0, int _b = 0) { k = _k; b = _b; xLeft = -9e18; type = false; } bool operator<(const Line &l) const { if (l.type) return xLeft < l.xLeft; return k < l.k ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 3e5 + 66; const ll inf = 2e18; struct node { int L, R; ll x, y; node(int a, int b, ll c, ll d) { L = a, R = b, x = c, y = d; } }; vector<node> lines; ll a[N], b[N], ans[N], q[N]; int t[N], rem[N], ind[N]; struct line { ll k, b; ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; inline int read() { register int X = 0; register char ch = 0, w = 0; while (ch < 48 || ch > 57) ch = getchar(), w |= (ch == '-'); while (ch >= 48 && ch <= 57) X = X * 10 + (ch ^ 48), ch = getchar(); return w ? -X : X; } struct Line { int k, b; double t; long...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int N = 300005; struct Point { int x, y; Point(int _x = 0, int _y = 0) { x = _x; y = _y; } Point operator-(const Point &R) const { return Point(x - R.x, y - R.y); } long long operator^(const Point &R) const { return (long long)x * R.y - (long lon...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; template <class X, class Y> void minimize(X &x, const Y &y) { if (x > y) x = y; } template <class X, class Y> void maximize(X &x, const Y &y) { if (x < y) x = y; } template <class T> T Abs(const T &x) { return (x < 0 ? -x : x); } const int INF = (int)1e9 + 7; const lo...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; using ll = long long; const char newl = '\n'; template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; } enum Objective { MINIMIZE = +1, MAXIMIZE =...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; struct yts { long long x, y; } st[300010]; bool operator<(yts x, yts y) { return x.x < y.x || (x.x == y.x && x.y < y.y); } yts operator+(yts x, yts y) { return (yts){x.x + y.x, x.y + y.y}; } yts operator-(yts x, yts y) { return (yts){x.x - y.x, x.y - y.y}; } long double o...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; inline int in() { int32_t x; scanf("%d", &x); return x; } inline long long lin() { long long x; scanf("%lld", &x); return x; } const int maxn = 5e5 + 10; const int maxm = 5e5 + 10; const int mod = 1e9 + 7; const long long infll = 2e18 + 10; const int inf = 1e9; ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; const long long INF = -(long long)2e18 - 1; struct point { int x, y; point(int x = 0, int y = 0) : x(x), y(y) {} long long calc(long long q) { return q * x + y; } } pt[N]; point operator-(point p, point q) { return point(p.x - q.x, p.y - q.y); ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:256000000") using namespace std; mt19937 ggen; struct query { int type; long long a, b; query() {} query(int type, long long a = 0, long long b = 0) : type(type), a(a), b(b) {} }; bool double_eq(const double &a, const double &b) { return fabs(a - b) < 1e-...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; import java.util.TreeSet; public class CF_678F2 { static long NULL = -2_000_000_0...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const long long Inf = 2e18; const long long maxn = 3e5 + 7; long long kq[maxn]; struct Segment { long long a, b; bool operator<(const Segment &other) const { if (this->a == other.a) return this->b < other.b; return this->a < other.a; } long long Val(long lon...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> const int MAX_N = (int)3e5 + 123; const double eps = 1e-6; const int mod = 2017; using namespace std; struct Line { int k, b; Line() {} Line(int k, int b) : k(k), b(b) {} bool operator<(const Line &first) const { if (k != first.k) return k < first.k; return b > first.b; } do...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; void addmod(int &a, long long b) { a = (a + b); if (a >= 1000000007) a -= 1000000007; } void mulmod(int &a, long long b) { a = (a * b) % 1000000007; } int gi() { int a; scanf("%d", &a); return a; } long long gll() { long long a; scanf("%I64d", &a); return a;...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const long long inf = 1LL << 62; const int Mod = 1e9 + 7; int dcmp(double x) { if (fabs(x) <= 1e-5) return 0; return x < 0 ? -1 : 1; } struct Point { int x, y; int l, r; Point(long long x = 0, long long y = 0) : x(x), y(y) {} Point operator-(const Point &a) cons...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; inline int Read() { char ch = getchar(); while (!((ch >= '0' && ch <= '9') || ch == '-')) ch = getchar(); int x = 0, p = 1; if (ch == '-') p = -1, ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * p; } struct cht { ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int n0 = 1 << 19; const long long inf = 2e18; int n, alive[n0]; array<int, 3> qr[n0]; long long ans[n0]; struct Line { long long k, b; long long val(long long x) { return k * x + b; } long long ip(const Line &l) { return (l.b - b + (k - l.k - 1)) / (k - l.k); } ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> int sgn(int a) { if (!a) return 0; if (a > 0) return 1; return -1; } int di(int a, int b) { if (!a) return 0; if (sgn(a) == sgn(b)) return a / b; return a / b - 1; } struct query { int t, a, b; }; const int N = 300000; const int K = 15000; int n; long long ans[N]; query q[N]; bool...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int N = 300100; const int M = 1000100; const int K = 200100; const int oo = 2e9; const long long OO = 2e18; const int PW = 20; const int md = 1000000007; int tp[N], q, BLOCK, tt, siz, TT, mrk[N], vc[N], vec[N]; long long x[N], y[N], vl[N], fr[N], X[N], Y[N]; multiset<...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; int const inf = 1000 * 1000 * 1000; long long const inf64 = 1ll * inf * inf; template <class T> struct ConvexHullTrick { size_t sz; vector<pair<T, T> > Lines, st; ConvexHullTrick() { sz = 0; } void add_line(pair<T, T> L) { pair<T, T> l1, l2; while (!st.empty...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int N = 300005; struct Point { int x, y; Point(int _x = 0, int _y = 0) { x = _x; y = _y; } Point operator-(const Point &R) const { return Point(x - R.x, y - R.y); } long long operator^(const Point &R) const { return (long long)x * R.y - (long lon...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int T = (1 << 19); pair<long long int, long long int> val[T]; const long long int INF = 1LL << 61; bool cmpA; struct Line { long long int a, b; mutable long double xl; bool operator<(const Line &l) const { if (cmpA) return a < l.a; else retur...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vll = vector<ll>; using vvll = vector<vll>; using vld = vector<ld>; using vi = vector<int>; using vvi = vector<vi>; template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) { o << "(" << v.f...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; struct Po { long long x, y; } s[300010], t[300010]; struct PP { int l, r; Po p; } p[300010]; struct QQ { int t, id; long long x; } q[300010]; long long ans[300010]; int Top, ty[300010], ed[300010]; bool operator<(Po a, Po b) { return a.x == b.x ? a.y < b.y : a.x <...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; bool SR(int &_x) { return scanf("%d", &_x) == 1; } bool SR(long long &_x) { return scanf("%" PRId64, &_x) == 1; } bool SR(double &_x) { return scanf("%lf", &_x) == 1; } bool SR(char *_s) { return scanf("%s", _s) == 1; } bool RI() { return true; } template <typename I, typen...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> long long inp() { char c = getchar(); long long neg = 1; while (c < '0' || c > '9') { if (c == '-') neg = -1; c = getchar(); } long long sum = 0; while (c >= '0' && c <= '9') { sum = sum * 10 + c - '0'; c = getchar(); } return sum * neg; } long long ans[400010], ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int MAXN = 4e5 + 10; const long long INF = 2e18; const long double EPS = 1e-9; struct Line { int a, b; long double inter(const Line& l) const { assert(a != l.a); return (long double)(l.b - b) / (a - l.a); } Line() {} Line(int a, int b) : a(a), b(b) {...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int MAXN = 300005; const int DEL = 1e9 + 7; const long long INF = 2e18; struct Line { int k, b; Line() {} Line(int k, int b) : k(k), b(b) {} long long f(int x) { return 1LL * k * x + b; } bool operator<(const Line& a) const { return k != a.k ? k < a.k : b < ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; struct line { long long a, b; double xleft; bool type; line(long long _a, long long _b) { a = _a; b = _b; type = 0; } bool operator<(const line &other) const { if (other.type) { return xleft < other.xleft; } return a > other.a; } ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const long long inf = 2e18; struct cht { vector<pair<int, int> > hull; int cur = 0; cht() { hull.clear(); } bool useless(const pair<int, int> left, const pair<int, int> middle, const pair<int, int> right) { return 1LL * (middle.second - left.secon...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 7; int n, l[N], r[N]; struct Point { long long x, y; Point(long long _x = 0, long long _y = 0) { x = _x; y = _y; } Point operator+(const Point &b) const { return Point(x + b.x, y + b.y); } Point operator-(const Point &b) const { return ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> #pragma GCC target("sse4,avx") const int64_t inf = 2000000000000000000; using TreeNode = std::vector<std::pair<int, int>>; struct Solution { std::vector<std::pair<int, int>> queries; std::vector<int64_t> qAnswer; std::vector<std::pair<int, int>> points; std::vector<std::pair<int, int>> ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; struct Point { long long x, y; Point() {} Point(long long a, long long b) : x(a), y(b) {} Point operator-(Point b) { return Point(x - b.x, y - b.y); } bool operator<(const Point& b) const { return (x != b.x) ? x < b.x : y < b.y; } }; inline long long cross(P...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const int MAXN = 4e5 + 10; const long long INF = 2e18; const long double EPS = 1e-9; struct Line { int a, b; long double inter(const Line& l) const { assert(a != l.a); return (long double)(l.b - b) / (a - l.a); } Line() {} Line(int a, int b) : a(a), b(b) {...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const long long oo = 2E18; const int None = 1E9 + 10; struct point { long long x, y; point(long long _x = 0, long long _y = 0) { x = _x, y = _y; } point operator-(const point& w) const { return point(x - w.x, y - w.y); } point operator+(const point& w) const { retur...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; template <class T> inline T bigmod(T p, T e, T M) { if (e == 0) return 1; if (e % 2 == 0) { T t = bigmod(p, e / 2, M); return (t * t) % M; } return (bigmod(p, e - 1, M) * p) % M; } template <class T> inline T gcd(T a, T b) { if (b == 0) return a; return ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> const int inf = 0x3f3f3f3f, Inf = 0x7fffffff; const long long INF = 0x7fffffffffffffff; const double eps = 1e-10; unsigned int seed = 19260817; const unsigned int _RAND_MAX_ = 4294967295u; __inline__ __attribute__((always_inline)) unsigned int Rand() { return seed = seed * 998244353u + 100000...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; struct point { long long x, y; point(int a = 0, int b = 0) { x = a; y = b; } }; point operator-(point a, point b) { return point(a.x - b.x, a.y - b.y); } long long operator*(point a, point b) { return a.x * b.y - a.y * b.x; } bool operator<(point a, point b) {...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; const long long N = 1; const long long big = 6e18; long long block = 800; const long long mod = 1e6; long long n; set<pai...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> #pragma warning(disable : 4996) #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("-ffloat-store") using namespace std; clock_t time_p = clock(); void aryanc403() { time_...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; struct query { int t, a, b; query() { t = a = b = 0; } query(int t, int a, int b) : t(t), a(a), b(b) {} bool operator<(const query& B) const { if (a == B.a) return b < B.b; return a < B.a; } }; query T[300005]; vector<query> lines; vector<pair<int, int> > ...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; using db = long long; using ll = long long; using ull = unsigned long long; using pII = pair<int, int>; using pLL = pair<ll, ll>; constexpr int mod = 1e9 + 7; template <class T1, class T2> inline void chadd(T1 &x, T2 y, int Mod = mod) { x += y; while (x >= Mod) x -= Mod...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; const long long N = 3e5 + 7; const long long M = 1e9 + 7; const long long MAXN = 2e18 + 7; const long long Mod = 998244353; long long _, i, j, k, n, m, p, s, T, t, l, r, o, u, v, w, x, y, z, ans, nex, sum, num, len, en, sx, sy, tx, ty, th, ma, mi, mod, cnt, la, op, res,...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool upmin(T &x, T y) { return y < x ? x = y, 1 : 0; } template <typename T> inline bool upmax(T &x, T y) { return x < y ? x = y, 1 : 0; } const long double eps = 1e-11; const long double pi = acos(-1); const long long oo = 1 << 30; const lo...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; struct CHT { public: vector<pair<int, int> > lines; public: CHT() {} void addLine(pair<int, int> line) { lines.push_back(line); } void build() { sort(lines.begin(), lines.end()); vector<pair<int, int> > _lines = lines; lines.clear(); for (pair<int...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; struct P { long long x, y; void read() { scanf("%lld%lld", &x, &y); } void write() const { printf("(%lld,%lld)", x, y); } long long operator*(const P& b) const { return x * b.y - y * b.x; } P operator+(const P& b) const { return P{x + b.x, y + b.y}; } P operator...
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; int convexP = 0; const int SQ = 1075; const long long mini = -8e18; bool isErased[300001]; long long type[300001], a[300001], b[300001]; long long out[300001]; long long la[300001], lb[300001]; int convexSz, p; double cross(int x, int y) { return (double)(lb[y] - lb[x]) / (...