text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; long long n, k, t, a, b; vector<long long> v, va, vb; int main() { cin >> n >> k; for (long long i = 0; i < n; i++) { cin >> t >> a >> b; if (a == 1 && b == 1) v.push_back(t); else if (a == 1 && b == 0) va.push_back(t); else if (a == 0 && b =...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long INF = 1e9 + 9; const int MAX = 100; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(10); cout << fixed; long long t = 1; while (t--) { long long n, k; cin >> n >> k; ...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 100; const int inf = 1e9 + 7; const long long mod = 1e9 + 7; int a[maxn]; int b[maxn]; int t[maxn]; vector<int> both; vector<int> alice; vector<int> bob; int psum_alice[maxn]; int psum_bob[maxn]; int psum_both[maxn]; int main() { ios_base::sync_with...
#include <bits/stdc++.h> using namespace std; int s[200000], m[200000], n[200000]; int main() { long long ans = 0; int f, k, t[200000], a[200000], b[200000], i, count = 0; int g = 0, h = 0; cin >> f >> k; for (i = 0; i < f; i++) { cin >> t[i] >> a[i] >> b[i]; if (a[i] == 1 && b[i] == 1) { s[coun...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios::sync_with_stdio(false); cin.tie(nullptr); long long t = 1; while (t--) { long long n, k; ; cin >> n >> k; multiset<long long> alice, bob, both; for (long long i = 0; i < n; i++) { long long ti, ai, bi; cin >> ti ...
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long> > al, bob, both, v, ansb, alr, bobr, norr, vc, neither; set<long long> ans; int vis[200005], l1[200005], l2[200005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long a = 0, b = 0, c, d, e, ...
#include <bits/stdc++.h> using namespace std; const int N = 200005; struct P { int t, a, b; }; vector<P> A, B, C; int sa[N], sb[N], sc[N]; bool cmp(P a, P b) { return a.t < b.t; } int main() { int n, k; P t; scanf("%d%d", &n, &k); for (int i = 1; i <= n; ++i) { scanf("%d%d%d", &t.t, &t.a, &t.b); if (t...
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 5; struct st { int t, a, b; }; deque<st> v, al, bo, ne; int n, k; st st1; bool cmp(st stx, st sty) { if (stx.a + stx.b > sty.a + sty.b) return 1; else if (stx.a + stx.b < sty.a + sty.b) return 0; else return (stx.t < sty.t); } int mai...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3fll; const int N = 1e4 + 10; const int M = 3e6 + 10; const int maxn = 1e6 + 10; const int mod = 1000173169; const double eps = 1e-10; const double pi = acos(-1.0); struct Tree { int num[N << 2], sum[N << 2...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization("unroll-loops") using namespace std; long long dx[] = {1, 0, -1, 0}; long long dy[] = {0, 1, 0, -1}; void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { ...
#include <bits/stdc++.h> using namespace std; const int INF = 2e9 + 1; int n, m, k, p1, p2, sum = 0, sumSmall = 0, minVal = INF; pair<int, int> rs; vector<pair<int, int> > a[2][2]; set<pair<int, int> > small, large; void updateSmall(pair<int, int> val, int type) { if (type == 0) { small.insert(val); sumSmall ...
#include <bits/stdc++.h> using namespace std; void solve() { int n, k; cin >> n >> k; priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq; vector<int> t(n), a(n), b(n); int cnt1 = 0, cnt2 = 0; int cnt3 = 0; priority_queue<int, vector<int>, greater<i...
#include <bits/stdc++.h> using namespace std; struct cmp { bool operator()(const long long &a, const long long &b) { return a >= b; } }; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, k; cin >> n >> k; long long first = 0, second = 0, ans = 0; long long temp1 = 0, temp2 = 0, te...
#include <bits/stdc++.h> using namespace std; int mod = 1000000007; const int inf = 1034567891; const long long LL_INF = 1234567890123456789ll; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; } template <typename Arg1, typename... Args> void __f(const char* na...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, k; cin >> n >> k; vector<vector<long long>> b(4, vector<long long>(1, 0LL)); for (int i = 0; i < n; i++) { long long t, x, y; cin >> t >> x >> y; b[x * 2 + y].push...
#include <bits/stdc++.h> using namespace std; struct book { int val; int index; }; int n, m, k, tim, minTim = 2000000001; int minIndexVal, xIndex[5]; vector<book> x[4]; int xS[5]; vector<int> books; int currNum[4], minNum[4]; bool compareVal(book p1, book p2) { return p1.val < p2.val; } int sizeOfCurrBooks() { in...
#include <bits/stdc++.h> const int factor_N = 10000005; using namespace std; int read() { char c = getchar(); int x = 0, f = 1; for (; !isdigit(c); c = getchar()) if (c == '-') f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return x * f; } struct Node { int t, a, b; }; const int N = 2e5 ...
#include <bits/stdc++.h> using namespace std; struct node { int a, b, t; int index; node() {} node(int _a, int _b, int _t, int _index) { a = _a; b = _b; t = _t; index = _index; } bool operator<(const struct node &nd) const { return t < nd.t; } bool operator>(const struct node &nd) const { ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; vector<long long int> a, b, c; for (int i = 0; i < n; i++) { int t, x, y; cin >> t >> x >> y; if (x && y) c.push_back(t); else if (x && !y) a.push_back(t); else if (!x && y) b.push_bac...
#include <bits/stdc++.h> using namespace std; void quick_sort(int a[], int left, int right) { int l = left, r = right, m = a[rand() % (r - l) + l]; while (l < r) { while (a[l] < m) l++; while (a[r] > m) r--; if (l <= r) { int t = a[l]; a[l] = a[r]; a[r] = t; l++; r--; }...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n, k; cin >> n >> k; vector<long long> alice; vector<long long> bob; vector<long long> combined; long long atotal = 0, btotal = 0; for (long long i = 0; i < n; ++i) { lo...
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 99; int n, k, m, x, y, p0, p1, p2, b0, b1, b2, b3, a[N]; vector<pair<long long, int> > v0, v1, v2, v3; long long ans = 1e18, sum; void calc(int x) { if (p0 < v0.size() - 1) p0++, sum += v0[p0].first; if (p0 < v0.size() - 1) p0++, sum += v0[p0].first;...
#include <bits/stdc++.h> const long long maxn = 2e5 + 1; using namespace std; struct triple { long long t, ci; bool a = 0, b = 0; triple() {} }; bool cmp(triple x, triple y) { return x.t < y.t; } triple v[maxn]; bool usd[maxn]; long long ci = -1; long long cs = 0; inline void add() { ++ci; for (; usd[ci]; ci+...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; template <typename T> void read(T &x) { int f = 1; x = 0; char s = getchar(); while (s < '0' || s > '9') { if (s == '-') f = -1; s = getchar(); } while (s >= '0' && s <= '9') { x = x * 10 + s - '0'; s = getchar(); } ...
#include <bits/stdc++.h> using namespace std; vector<long long> D; vector<long long> B; vector<long long> A; int main() { long long a = 0, b = 0; long long n, k; long long ti, al, bl, time = 0; cin >> n >> k; for (long long i = 0; i < n; ++i) { cin >> ti >> al >> bl; if (al + bl == 2) D.push_bac...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n, k, c1 = 0, c2 = 0, v = 0, ans = 0, res; cin >> n >> k; long long a[n][3]; vector<long long> s1, s2, s3; for (long long i = 0; i < n; i++) { for (long long j = 0; j...
#include <bits/stdc++.h> const int MAXN = 3e5 + 10; const double eps = 1e-8; const int inf = 2e9 + 9; using namespace std; struct edge { int t, v; edge *next; } e[MAXN << 1], *h[MAXN], *o = e; void add(int x, int y, int vul) { o->t = y; o->v = vul; o->next = h[x]; h[x] = o++; } long long read() { long lon...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long powM(long long x, long long y, long long m) { if (y == 0) return 1; long long p = powM(x, y / 2, m) % m; p = (p * p) % m; return (y % 2 == 0) ? p : (x * p) % m; } int main() { ios:...
#include <bits/stdc++.h> using namespace std; inline long long read() { long long f = 1, ans = 0; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { ans = ans * 10 + c - '0'; c = getchar(); } return f * ans; } const long l...
#include <bits/stdc++.h> using namespace std; void readtxt() {} void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); } int32_t main() { fast(); long long int n, k; cin >> n >> k; vector<long long int> a1b1, a1b0, a0b1; long long int ans = 0, t, a, b; for (long long int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9; long long A(long long x) { if (x >= 0) return x; else return -x; } long long gcd(long long a, long long b) { if (b > a) { long long tmp = b; b = a; a = tmp; } if (a % b == 0) return b; else return gcd(b, a % ...
#include <bits/stdc++.h> using namespace std; long long int const mod = 1000000007; std::mt19937 rng( (int)std::chrono::steady_clock::now().time_since_epoch().count()); int rand_rng(int l, int r) { uniform_int_distribution<int> p(l, r); return p(rng); } long long int power(long long int x, long long int y, long...
#include <bits/stdc++.h> using namespace std; const int INF = 2e9 + 1; void updateSt(set<pair<int, int>> &st, set<pair<int, int>> &fr, int &sum, int need) { need = max(need, 0); while (true) { bool useful = false; while (int((st).size()) > need) { sum -= st.rbegin()->first; fr.inse...
#include <bits/stdc++.h> using namespace std; const unsigned long long int INF = numeric_limits<int>::max(); long long int k, n, A, B, T; unsigned long long int ab[200005], a[200005], b[200005]; int main() { std::ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); ; cin >> n >> k; int I =...
#include <bits/stdc++.h> using namespace std; priority_queue<pair<int64_t, int64_t>, vector<pair<int64_t, int64_t>>, greater<pair<int64_t, int64_t>>> a, b, c, d; priority_queue<pair<int64_t, int64_t>> both; vector<int64_t> ans; vector<pair<int64_t, pair<int64_t, int64_t>>> prblm; map<int64_t, bool> o...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast,no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops") template <class T> inline T bigMod(T p, T e, T M) { T ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret...
#include <bits/stdc++.h> using namespace std; int main() { int test = 1; while (test--) { int m, k, i; cin >> m >> k; int arr[3][m]; for (i = 0; i < m; i++) cin >> arr[0][i] >> arr[1][i] >> arr[2][i]; vector<int> a; vector<int> b; vector<int> c; for (i = 0; i < m; i++) { if (ar...
#include <bits/stdc++.h> using namespace std; const int maxm = 2e3 + 23; const int maxn = 2e5 + 35; int n, k, t[maxn], vis[maxn], a, b, num, m; vector<int> ve[4], ee; vector<pair<int, int> > we; bool cmp(int i, int j) { return t[i] < t[j]; } struct node { int ii, tt; friend bool operator<(node a, node b) { return a...
#include <bits/stdc++.h> using namespace std; const long long INF = 2000000000000; const long long MOD = 998244353; const int N = 100009; int main() { int n, k; cin >> n >> k; vector<long long> A, B, both; for (int i = 0; i < int(n); i++) { long long t, a, b; cin >> t >> a >> b; if (a == 1 && b == 1...
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; const long long int N = 2e5 + 9; long long int primes[6] = {1125899906842597, 1495921043, 1005985879, 1495921043, 1005985879, 1495921043}; vector<long long int> adj[N]; long long int parent[N]; long long in...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int inf = 1e9 + 7; const double eps = 1e-6; long long qpow(long long a, long long b, long long m) { long long r = 1; a %= m; for (; b; b >>= 1) { if (b & 1) r = r * a % m; a = a * a % m; } return (r + m) % m; } const do...
#include <bits/stdc++.h> using namespace std; const int INF = 2e9 + 1; void updateSt(set<pair<int, int>> &st, set<pair<int, int>> &fr, int &sum, int need) { need = max(need, 0); while (true) { bool useful = false; while (int((st).size()) > need) { sum -= st.rbegin()->first; fr.inse...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e4 + 9; int tree[(MAX << 2)][2], val, idx; void upd(int low, int high, int pos) { if (low == high) { tree[pos][1] += val; tree[pos][0] += val * low; return; } int mid = ((low + high) >> 1); if (idx <= mid) upd(low, mid, (pos << 1)); ...
#include <bits/stdc++.h> using namespace std; long long n; long long k; struct book { bool a; bool b; int time; }; book B[1000000]; bool compare(book x, book y) { return x.time < y.time; } void solve() { cin >> n; cin >> k; int x, y, z; int as = 0; int bs = 0; int mx = 0; for (int i = 0; i < n; i++)...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) { if (x > y) x = y; } template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) { if (x < y) x = y; ...
#include <bits/stdc++.h> using namespace std; const int INF = 2e9 + 1; long long int m = 1000000007; string toString(char x) { string s(1, x); return s; } long long int pow1(long long int x, long long int y) { long long int temp; if (y == 0) return 1; temp = pow1(x, y / 2); if (y % 2 == 0) return (temp ...
#include <bits/stdc++.h> using namespace std; struct jg { int x, y, z; }; jg a[200001]; int n, k, t1, t2, t3, mx, ans[200001], sum[200001], ans1[200001]; bool bj1[200001], bj2; int main() { int i, j; cin >> n >> k; for (i = 1; i <= n; i++) { scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z); if (a[i].y == 1 &&...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pi = pair<int, int>; using pl = pair<ll, ll>; const ll N = 3e5 + 10; const ll INF = 1e10; const ll M = 1e3 + 1; const ll L = 31; const ll mod = 998244353; ll solve() { ll n, k; cin >> n >> k; ll t, a, b; ll...
#include <bits/stdc++.h> using namespace std; void printVector(vector<string> &v) { for (auto x : v) cout << x << "\n"; } void printVector(vector<int> &v) { for (auto x : v) cout << x << " "; cout << "\n"; } int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); int t; t = 1; while (t--) { ...
#include <bits/stdc++.h> using namespace std; long long time(vector<int> l, int il, vector<int> b, int ib, vector<int> r, int ir, int k) { long long ans = 0; int left = k, right = k; int index_both = 0; int index_right = 0; int index_left = 0; while (left != 0 && right != 0) { if (index_b...
#include <bits/stdc++.h> using namespace std; long long power(long long x, long long y, long long p) { long long res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } inline long long add(long long a, long long b) { return (a + b) % 100000...
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, i, ok, s = 0, sum = 0, ans = 0; multiset<long long> pi1; vector<long long> pi2, pi3; multimap<long long, long long>::iterator it; cin >> n >> ok; long long a, b, c; for (i = 0; i < n; i++) { cin >> a >> b >> c; if (b == 1 &...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf("%d %d", &n, &k); long long ans = 0; priority_queue<int, vector<int>, greater<int>> q1, q2, q3; int ct1 = 0; int ct2 = 0; for (int i = 1; i <= n; i++) { long long t; int a, b; scanf("%lld %d %d", &t, &a, &b); if (a ...
#include <bits/stdc++.h> using namespace std; int n, k, m, x, y, z; int ans; vector<int> a[2][2]; vector<pair<int, int> > f[2][2]; int id[2][2]; int main() { scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < n; i++) { scanf("%d%d%d", &x, &y, &z); a[y][z].push_back(x); f[y][z].push_back({x, i + 1}); } ...
#include <bits/stdc++.h> using namespace std; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << '\n'; err(++it, args...); } long long powMod(long long x, long long y) { long long p = 1; while (...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n, i, j, k, t, p, q; cin >> n >> k; multiset<long long> a, b, d; long long al = 0, bl = 0; for (i = 0; i < n; i++) { cin >> t >> p >> q; if (p && q) { d...
#include <bits/stdc++.h> using namespace std; using ll = long long; vector<ll> L, R, M; ll p(const vector<ll>& v, ll c) { if (c <= 0) return 0; return v[c - 1]; } const ll INF = 5e10; int main() { ios::sync_with_stdio(false); cin.tie(0); ll N, K; cin >> N >> K; for (int i = 0; i < N; ++i) { ll time, l...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; int n, k; cin >> n >> k; vector<int> t(n), a(n), b(n); for (int i = 0; i < n; i++) cin >> t[i] >> a[i] >> b[i]; vector<vector<int>> elements(4); for (int i = 0; i < n; i++) elements[2 * a[i] +...
#include <bits/stdc++.h> using namespace std; long long n, m, p, q; long long k; pair<int, pair<int, int> > a[2000005]; int main() { cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second.first >> a[i].second.second; sort(a, a + n); vector<int> alice, bob; int Alice = 0, Bob = 0; lo...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 7; int n, m, k; struct node { int t, id; bool operator<(const node &oth) const { return t < oth.t; } }; vector<node> sa[4]; int sz[4], ans; int tsz[4], tans; int main() { scanf("%d%d%d", &n, &m, &k); int t, a, b; for (int i = 1; i <= n; ++i)...
#include <bits/stdc++.h> using namespace std; int const MAXN = 2e5 + 10; int n, m, T, k; vector<pair<int, int>> a, b, ab, other; vector<int> ans; int check(int mid) { if ((int)a.size() < k - mid) return 2e9 + 11; if ((int)b.size() < k - mid) return 2e9 + 11; if (mid + max(0, k - mid) * 2 > m) return 2e9 + 11; i...
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; const int N = 2e5 + 5; long long t[N], a[N], b[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, k; cin >> n >> m >> k; int cnta = 0, cntb = 0; set<pair<long long, long long> > ab, aa, bb; for (int i...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e4 + 9; int tree[(MAX << 2)][2], val, idx; void upd(int low, int high, int pos) { if (low == high) { tree[pos][1] += val; tree[pos][0] += val * low; return; } int mid = ((low + high) >> 1); idx <= mid ? upd(low, mid, (pos << 1)) : upd(mi...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; const int mod = 1e9 + 7; struct ac { long long a, b, t; }; ac a[maxn]; bool cmp1(ac a, ac b) { return a.t < b.t; } int main() { ios::sync_with_stdio(false); cin.tie(0); vector<long long> suma, sumb, sumab; suma.push_back(0), sumb.push_ba...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; priority_queue<int, std::vector<int>, std::greater<int> > both; priority_queue<int, std::vector<int>, std::greater<int> > alice; priority_queue<int, std::vector<int>, std::greater<int> > bob; for (int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll inf = 1e18; const int N = 2 * 1e5 + 10; ll res, n, k; void solve() { ll tt, x, y; std::vector<ll> v, vv, vvv; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> tt >> x >> y; if (y == 1 && x == 1) v.push_back(tt); el...
#include <bits/stdc++.h> using namespace std; int n, k; int suma, sumb; priority_queue<int> both, alice, bob; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) { int t, a, b; cin >> t >> a >> b; if (a + b == 2) { both.push(-t); } else if (a == 1) { alice.push(-t); } else if (b...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; struct node { int t, a, b; } ke[maxn], le[maxn], m[maxn]; int n, k; bool cmp(node x, node y) { return x.t < y.t; } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> k; int cnt1 = 0, cnt2 = 0, cnt0 = 0; for (int i = 0; i...
#include <bits/stdc++.h> using namespace std; int Alice[200005], Bob[200005], Both[200005]; int PA[200005], PB[200005]; int FindMinReadingTime(int k, int a, int b, int bo) { int i, Ans = 0; if (a > 0) sort(Alice + 1, Alice + a + 1); if (b > 0) sort(Bob + 1, Bob + b + 1); if (bo > 0) sort(Both + 1, Both + bo + 1...
#include <bits/stdc++.h> using namespace std; long long n, k, t, a, b, boths, alices, bobs, cnt[2], ans, res, tmp; vector<int> both, alice, bob; int main() { ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); cin >> n >> k; for (int i = 0; i < n; i++) { cin >> t >> a >> b; if (a && b) both....
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << "\n"; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cout.write(nam...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long N = 3e2 + 5; int main() { ios_base::sync_with_stdio(false); long long n, k, one = 0, two = 0; cin >> n >> k; vector<long long> v1, v2, v3; for (int i = 0; i < n; i++) { long long x, y, z; cin >> x >> y >> z; ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5, OO = 0x3f3f3f3f, mod = 1e9 + 7; int main() { cin.tie(0); cin.sync_with_stdio(0); int n, k; cin >> n >> k; vector<int> both, A, B; for (int i = 0; i < n; i++) { int t, a, b; cin >> t >> a >> b; if (a && b) both.push_back(t); ...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; void solve() { long long n, k; cin >> n >> k; vector<long long> a[3], pre[3]; for (long long i = 0; i < n; i++) { long long x, y, z; cin >> x >> y >> z; if (y & z) a[0].push_back(x); else if (y) a[1].push_back(...
#include <bits/stdc++.h> using namespace std; int read(int &x) { return scanf("%d", &x); } int read(int &x, int &y) { return scanf("%d%d", &x, &y); } int read(int &x, int &y, int &z) { return scanf("%d%d%d", &x, &y, &z); } int read(long long &x) { return scanf("%lld", &x); } int read(long long &x, long long &y) { retur...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, t, a, b; int all[200000]; int Alice[200000]; int Bob[200000]; int numAll = 0; int numAlice = 0; int numBob = 0; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> t >> a >> b; if (a == b && a == 1) { all[numAll] = t; ...
#include <bits/stdc++.h> const int N = (int)5e5 + 7; const int inf = (int)1e9 + 7; const int mod = (int)1e9 + 7; const long long linf = (long long)1e18 + 7; const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1}; const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1}; using namespace std; int n, k, need; long long p1[N], p2[N]; struct tre...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int i, j, a, b, t; vector<int> time, temp1, temp2; for (i = 0; i < n; i++) { cin >> t >> a >> b; if (a == 1 && b == 1) time.push_back(t); else if (a == 1) temp1.push_back(t); else if (b == 1) ...
#include <bits/stdc++.h> using namespace std; long long n, m, k, t[200005], a[200005], b[200005]; vector<pair<long long, long long> > ta, tb, tboth, tnone; multiset<long long> second; int main() { ios::sync_with_stdio(false); cin >> n >> m >> k; for (long long i = 1; i <= n; ++i) cin >> t[i] >> a[i] >> b[i]; lo...
#include <bits/stdc++.h> using namespace std; const char nl = '\n'; const int MAX_N = 100011; const long long INF = (1LL << 50) + 123; const long long MOD = 1000000007; const long double PI = 4 * atan((long double)1); template <typename T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; } template <typena...
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; long long arr[n + 1]; long long a, b, c; vector<long long> A, B, common; for (long long i = 0; i < n; i++) { cin >> a >> b >> c; if (b == 1 && c == 1) { common.push_back(a); } else if (b == 1) { ...
#include <bits/stdc++.h> using namespace std; template <typename T = int> struct Fenwick { int n; vector<T> v; Fenwick(int size = 100005) : n(size), v(n + 1, 0) {} inline void add(int p, T val) { for (; p <= n; p += (p & -p)) { v[p] += val; } } inline T query(int p) { T tmp = 0; for (;...
#include <bits/stdc++.h> using namespace std; const long long mxn = 100010; void solve(long long tc) { long long n, k, x, y, z; cin >> n >> k; deque<long long> d00, d01, d10, d11; for (long long i = 0; i < n; i++) { cin >> x >> y >> z; if (y == 0 && z == 0) d00.push_back(x); else if (y == 0 &&...
#include <bits/stdc++.h> const long long INF = 1000000000000000001; using namespace std; mt19937 random1(179); struct Node { Node* l; Node* r; long long x, y, sum1, num, len; Node(long long x1) : x(x1), y(random1()), l(nullptr), r(nullptr), sum1(x1), num(1), len(1) {} }; void update(Node* tree) { if (tr...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3") const long long MOD = 1e9 + 7; long long n_bits(long long n) { long long x = __builtin_popcount(n); return x; } int pow(int a, int b, int m) { int ans = 1; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; ...
#include <bits/stdc++.h> using namespace std; double const EPS = 1e-8, PI = acos(-1); const int N = 2e5 + 9, M = 30 + 7, OO = (int)1e6 + 1, MAXN = 4 * N; const long long MOD = 1e9 + 7, INF = 1e18 + 9; void INPUT() {} bool cmp(pair<int, pair<bool, bool>> a, pair<int, pair<bool, bool>> b) { if (a.first == b.first) { ...
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << "\n"; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cout.write(nam...
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const int N = 1e5 + 5e4 + 2; const int inf = 2e9; const long long linf = 4e18; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cerr.tie(0); int n, k; cin >> n >> k; vector<int> alice, bob, common; for (int ...
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, k; cin >> n >> k; vector<long long int> a, b, c, d; a.emplace_back(0), b.emplace_back(0), c.emplace_back(0); for (int i = 0; i < n; i++) { int x, y, z; cin >> x >> y >> z; if (y + z == 2) { a.emplace_back(x); }...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; void solve() {} int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, k; cin >> n >> k; vector<long long> times[4]; vector<long long> sums[4]; for (long long i = 0; i < n; ++i) { long long t, a, b; ...
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { long long int n, i, j, w, x, y, k, cv1 = 0, cv2 = 0, cv3 = 0, c = 0, ans = 0; cin >> n >> k; vector<long long int> v2, v1, v3; for (i = 0; i < n; i++) { cin >> w >> x >> y;...
#include <bits/stdc++.h> using namespace std; using vl = vector<long long>; using vs = vector<string>; using vvl = vector<vector<long long>>; const long long INF = 1LL << 60; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, c...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; vector<int> a, b, ab; for (int i = 1; i <= n; ++i) { int x, l, r; cin >> x >> l >> r; if (l == 1 and r == 0) { a.push_back(x); } else if (l == 0 and r == 1) { ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; inline int read() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - 48; ch = getchar(); } return x * f; } priority_queue<i...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; int n, k; vector<int64_t> a; vector<int64_t> b; vector<int64_t> c; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> k; for (int i = 1; i <= n; i++) { int64_t _t; bool _a, _b; cin >> _t >> _a >> ...
#include <bits/stdc++.h> using std::cin; using std::cout; using std::endl; using std::string; void __Check(bool condition, const char* expression, int line) { if (!condition) { fprintf(stderr, "Check failed at line %d: %s\n", line, expression); exit(-1); } } template <class Collection, class Key> bool Conta...
#include <bits/stdc++.h> using namespace std; const int inf = 1 << 30; const long long mod = 1e9 + 7; const long long linf = 1LL << 62; const double EPS = 1e-7; template <class T> void chmin(T& x, T y) { if (x > y) x = y; } template <class T> void chmax(T& x, T y) { if (x < y) x = y; } int n, m, k; vector<pair<long...
#include <bits/stdc++.h> #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using std::cin; using std::cout; using std::lower_bound; using std::string; using std::upper_bound; using std::vector; using vi...
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 10; const long long inf = 1e9; struct node { long long num, tim; } A[N], B[N], C[N], D[N]; bool cmp(node l1, node l2) { return l1.tim < l2.tim; } signed main() { ios::sync_with_stdio(false); cin.tie(0); long long n, m, k, x, y, z, a = 0, b ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, x, xa, xb, aa = 0, bb = 0, cc; vector<int> a, b, c; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> x >> xa >> xb; aa += xa; bb += xb; if (xa & xb) c.push_back(x); else if (xa) a.push_back(x); else if (x...