Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; map<int, int> a, b; int x, y, n, m; char ch; int main() { scanf("%d%d", &n, &m); while (m--) { scanf("%d%d %c", &x, &y, &ch); int ans = 0; map<int, int>::iterator it; if (ch == 'U') { it = a.lower_bound(x); if (a.count(x)) { puts("0")...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> int n, m; int ax[200100]; int ay[200100]; int az[200100]; char c[200100][10]; struct qry { int loc, orig; bool operator<(const qry& r) const { return loc < r.loc; } }; qry b[200100]; int it[1 << 19]; int left[200100]; int up[200100]; void push(int x) { x += 3; int val = x; x += 1 << 1...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
//package codeforces; import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import ja...
JAVA
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int n, m, i, j, lx, ly, lval; pair<int, int> htree[800005], vtree[800005]; char s[10]; void push(int ind, pair<int, int>* tree) { if (tree[ind].second == 0) return; tree[ind * 2].first = max(tree[ind * 2].first, tree[ind].second); tree[ind * 2].second = max(tree[ind *...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
import java.io.File; import java.io.FileNotFoundException; import java.lang.reflect.Array; import java.util.*; public class Test4A { static int n = 0; public static class Border{ int left; int upper; public Border(int left, int upper) { this.left = left; this.upper = upper; // TODO Auto-generated...
JAVA
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
import java.util.TreeSet; import java.util.TreeMap; import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.util.Map; import java.math.BigInteger; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.Set; import java.util....
JAVA
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.HashSet; import java.util.Set; import java.util.StringTokenizer; public class Problem555C { private static class Tree { public Tree(int maxN...
JAVA
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 2000005; int val[1 << 19][2]; int tag[1 << 19][2]; int x[200005]; int x_val[200005]; int y[200005]; int y_val[200005]; int oper[200005]; struct node { int val; int id; friend bool operator<(const node &a, const node &b) { return a.val < b.val; } }; no...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; struct node { int l, d; } v[200010]; struct data1 { int max, po; } f2[1000000]; struct data2 { int min, po; } f1[1000000]; const int MAX = 1000000000; int n, q, l[200010], r[200010], k, w[200010], t, back[200010]; bool b[200010]; char c; int comp(node x, node y) { ret...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; set<pair<int, int> > s; set<pair<int, int> >::iterator it; int n, m; int x[maxn]; int y[maxn]; char c[maxn]; int main() { while (scanf("%d%d", &n, &m) != EOF) { s.clear(); memset(x, 0, sizeof(x)); memset(y, 0, sizeof(y)); memset(...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; char c; int x, y, n, m; map<int, int> f; map<int, int>::iterator t; int main() { scanf("%d%d", &n, &m); for (f[0] = 0, f[n + 1] = 1 << 31; m--;) { scanf("%d%d %c", &x, &y, &c); t = f.lower_bound(x); if (t->first == x) { puts("0"); continue; }...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int mr[1000050]; int mc[1000050]; int qx[1000050], qy[1000050]; map<int, int> mpx, mpy; void build(int l, int r, int i) { mr[i] = mc[i] = -1; if (l != r) { int mid = (l + r) >> 1; build(l, mid, i << 1); build(mid + 1, r, i << 1 | 1); } } void update(int l,...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; map<int, int> xg, yg; map<int, int>::iterator it; int n, q; int x, y; string s; int main() { cin >> n >> q; for (int i = 1; i <= q; i++) { cin >> x >> y >> s; if (s == "U") { it = xg.lower_bound(x); if (it->first == x) { cout << "0" << endl; ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000007; template <typename T> class segtree { private: long long n, sz; vector<T> node, min_val, second_val, lazy; vector<long long> count; vector<bool> lazyFlag; void update(long long id) { node[id] = node[2 * id + 1] + node[2 * id + 2]; ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 250000; struct node { node *l, *r; int ll, rr, m, pr; }; struct node *new_tree(int l, int r) { struct node *a; a = new (struct node); a->m = 0; a->pr = 0; a->ll = l; a->rr = r; if (r - l > 1) { a->l = new_tree(l, (r + l) / 2); a->r...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int t[400100], sz; int e[400100][3]; int n, q; map<int, int> vis; struct Seg { int v[400100 << 2]; void up(int o) { v[o] = min(v[(o << 1)], v[((o << 1) | 1)]); } void build(int o, int l, int r) { v[o] = 0x3f3f3f3f; if (l == r) return; build((o << 1), l, ((...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; typedef struct node { int leftEnd; int rightEnd; int ans; node* leftChild; node* rightChild; } node; int a[2 * 200001]; pair<pair<int, int>, int> queries[200001]; vector<int> compressedValues; int CompressCoordinate(int a[], int n) { vector<int> temp; for (int...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const long long N = 400010; char t[10]; map<long long, long long> mp[3]; long long n, q, col; long long s[N], xx[N], yy[N], op[N], ff[N], gg[N]; struct Point { long long x, op, id; } X[N], Y[N]; inline bool cmp(Point A, Point B) { return A.x < B.x; } struct SegmentTree { ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; const int B = 262144; struct BIT { int tr[2 * B]; int modified[2 * B]; int mod_val[2 * B]; void push(int nd) { if (!modified[nd]) return; tr[nd] = max(tr[nd], mod_val[nd]); int mv = mod_val[nd]; mod_val[nd] = modified[...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
import java.util.TreeSet; import java.util.HashSet; import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Comparator; import java.io.IOException; import java.util.StringTokenizer; /** * Built using CHelper...
JAVA
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int n, m; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; set<pair<int, pair<int, bool> > > eaten; set<pair<int, pair<int, bool> > >::iterator it; int x, y, ans; char d; bool dr; eaten.insert(make_pair(0, make_pair(...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int n, m; struct wen { int x, y, opt; } a[400005]; int u[400005]; struct aa { int l, r, x; } c[400005 << 2], d[400005 << 2]; void jianshu(aa *c, int i, int l, int r) { int mid = (l + r) >> 1; c[i].l = l; c[i].r = r; if (l == r) { return; } jianshu(c, (i ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int BASE = 1 << 18; const int INF = 3e5 + 7; struct query { char direction; int x, y; int num, numX, numY; int answer; query(char c = ' ', int a = 0, int b = 0, int d = 0) { direction = c; x = a; y = b; num = d; numX = numY = answer = 0; ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; inline long double min(long double a, long double b) { if (a < b) return a; return b; } inline long double max(long double a, long double b) { if (a < b) return b; return a; } int n, q; int x[200010]; int y[200010]; map<int, int> m; unordered_set<int> uset; int main...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; struct tree { int bit[4 * 200111], u[4 * 200111], v[4 * 200111]; void init(int i, int x, int y) { bit[i] = 1000000007; u[i] = x; v[i] = y; if (x == y) return; int mid = (x + y) >> 1; init(i << 1, x, mid); init(i << 1 | 1, mid + 1, y); } i...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
import java.util.*; import java.io.*; public class CaseOfChocolate { public static void main(String[] args) throws Exception { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int q = in.nextInt(); TreeSet<Integer> tsc = new TreeSet<Inte...
JAVA
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int qmax = 2e5 + 42; int n, q; struct query { int x, y; char type; }; query inp[qmax]; int u_n = 0, u_values[qmax], u_tree[4 * qmax]; int l_n = 0, l_values[qmax], l_tree[4 * qmax]; set<int> u_, l_; int ROT(int q) { return n + 1 - q; } int where_l(int val, bool up)...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; long long lazy[800200 * 4][2], seg[800200 * 4][2]; void updLazy(int node, int ini, int fim, int k) { if (lazy[node][k] == 0) return; seg[node][k] = max(seg[node][k], lazy[node][k]); if (ini != fim) { lazy[node * 2][k] = max(lazy[node * 2][k], lazy[node][k]); l...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; struct Segment { long long l; long long r; long long h; long long w; Segment(long long l = 0, long long r = 0, long long h = 0, long long w = 0) : l(l), r(r), h(h), w(w) {} bool operator<(const Segment a) const { if (r != a....
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 200020; int n, q; set<pair<pair<int, int>, pair<int, int> > > s; map<int, bool> mark; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> q; s.insert(make_pair(make_pair(1, n), make_pair(1, 1))); while (q--) { int a, b; char ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
import sys from bisect import bisect def input(): return sys.stdin.readline().strip() def solve(): n, q = map(int, input().split()) was = set() Q = [None]*q all = [0]*(2*q) for i in range(q): x, y, t = input().split() x, y = int(x), int(y) Q[i] = (x, y, t) all[2*i] = x all[2*i+1] = y all.sort() i = ...
PYTHON3
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; struct SegmentTree { int maxv[210000 << 2], pushdowntag[210000 << 2]; void pushdown(int o) { maxv[o << 1] = max(maxv[o << 1], pushdowntag[o]); maxv[o << 1 | 1] = max(maxv[o << 1 | 1], pushdowntag[o]); pushdowntag[o << 1] = max(pushdowntag[o], pushdowntag[o <...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int P = 1e9 + 7; int add(int a, int b) { if ((a += b) >= P) a -= P; return a; } int sub(int a, int b) { if ((a -= b) < 0) a += P; return a; } int mul(int a, int b) { return 1ll * a * b % P; } int kpow(int a, int b) { int r = 1; for (; b; b >>= 1, a = mul(a...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int maxq = 200005; int ans, x, y, neo; int n, q, a, b, sizedesu; char c; struct node { int l, r, Mw, lz, mw; } allcl[maxq * 4], allcu[maxq * 4]; set<int> checkpie; vector<int> allpie; pair<int, char> allcmd[maxq]; void buildl(int l, int r, int k) { allcl[k].l = l;...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> #pragma GCC optimize("inline,Ofast", 3) #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize("Ofast") #pragma GCC optimize("inline") #pragma GCC optimize("-fgcse") #pragma GCC optimize("-fgcse-lm") #pragma GCC optimize("-fipa-sra") #pragma GCC optimize("-ftree-pre") #pragma GCC ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; map<int, int> X, Y; int n, q; set<int> s; int main() { cin >> n >> q; X[0] = Y[0] = 0; for (int i = 0; i < q; i++) { int x, y; char d; cin >> x >> y >> d; if (s.find(x) != s.end()) cout << "0\n"; else { s.insert(x); auto a = X.low...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int n, q; vector<pair<pair<int, int>, char> > V; int revR[800010]; map<int, int> R; set<int> setR; int tree[2000010][2]; int lazy[2000010][2]; void upd(int idx, int l, int r, int a, int b, int x, bool k) { if (idx * 2 + 1 < 2000010) lazy[idx * 2 + 1][k] = max(lazy[idx...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; template <class T, class BASE, T (*op)(T, T), T (*multop)(T, BASE), T nonMod> struct segtree { vector<BASE> pts; vector<pair<BASE, BASE> > segment; vector<T> val, addval; vector<bool> lazy; size_t sz; void push_back(BASE pt) { pts.push_back(pt); } void initial...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; template <class T> void chmax(T &x, T y) { x = x > y ? x : y; return; } template <class T> void chmin(T &x, T y) { x = x < y ? x : y; return; } const int inf = 1000000000, mod = 1000000007; int n, q, X, Y; char c; set<pair<pair<int, int>, pair<int, int> > > s; set<p...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 200005; typedef struct Query { int x, md; Query(int x = 0, int md = 0) : x(x), md(md) {} } Query; Query Q[maxn]; int bdes1[maxn], bdes2[maxn], n, q, c; map<int, int> mp1, mp2; map<int, int>::iterator it; typedef struct BiT { int t[maxn * 3]; int laz...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 400005; struct SegmentTree { int tree[N << 2]; int lazy[N << 2]; inline void push_down(int rt) { if (lazy[rt] > tree[rt]) tree[rt] = lazy[rt]; lazy[rt << 1] = max(lazy[rt << 1], lazy[rt]); lazy[rt << 1 | 1] = max(lazy[rt << 1 | 1], lazy[rt]);...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 200000; int x[N + 2], y[N + 2], t[N + 2]; int main() { int n, q; cin >> n >> q; set<pair<int, int> > s; t[q] = 1; x[q] = 0; s.insert(make_pair(0, q)); t[q + 1] = 0; y[q + 1] = 0; s.insert(make_pair(n + 1, q + 1)); for (int i = 0; i < q; ++i...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { cin.sync_with_stdio(0); cin.tie(0); int n, q; long long int k; cin >> n >> q; map<int, pair<int, int> > pieces; map<pair<int, int>, int> rev; pieces.clear(); rev.clear(); set<int> seen; seen.clear(); pieces[n ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.InputMismatchException; ...
JAVA
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int n, m; map<int, pair<bool, int> > mp; int main() { scanf("%d%d", &n, &m); mp.insert(make_pair(n + 1, make_pair(0, n + 1))); mp.insert(make_pair(0, make_pair(1, n + 1))); int x, y; bool q; char ch[2]; for (int i = 1; i <= m; ++i) { scanf("%d%d%s", &x, &y...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; struct Node { Node(int s = 0, Node* left = nullptr, Node* right = nullptr) : val(s), L(left), R(right), lazy(s) {} Node* L; Node* R; int val; int lazy; }; struct DynamicSegmentTree { DynamicSegmentTree(int sz) : n(sz) { root = fetchNode(); } void upd(int...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> long long mpow(long long a, long long n, long long mod) { long long ret = 1; long long b = a; while (n) { if (n & 1) ret = (ret * b) % mod; b = (b * b) % mod; n >>= 1; } return (long long)ret; } using namespace std; map<int, int> ma1; map<int, int> ma2; vector<pair<pair<in...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.PriorityQueue; import java.util.Random; import java.util.StringT...
JAVA
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; set<pair<long long, int> > s; set<pair<long long, int> >::iterator it; long long n, q, x, y; char dir; map<long long, long long> m; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> q; s.insert(make_pair(0, 1)); s.insert(make_pa...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; set<pair<int, int> > s; set<pair<int, int> >::iterator it; int x[N], y[N]; int main() { int n, m; scanf("%d%d", &n, &m); s.insert(make_pair(n + 1, m + 1)); s.insert(make_pair(0, 0)); for (int i = 1; i <= m; i++) { char c[5]; scanf("...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const long long N = 200001; struct SegmentTree { vector<long long> t; SegmentTree() { t.assign(4 * N, 0); } void update(long long v, long long tl, long long tr, long long pos, long long new_val) { if (tl == tr) { t[v] = new_val; } else { ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const double PI = acos(-1); const int N = 2e5 + 10; int n, q; set<int> cells, negcells; set<int>::iterator it; unordered_map<int, int> blocked; unordered_map<int, char> dir; int getUP(int at) { it = cells.lower_bound(at); if (it != cells.end(...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int MAX_N = 2e5 + 9; set<pair<int, int> > vec; set<pair<int, int> >::iterator it; int ansx[MAX_N]; int ansy[MAX_N]; int main() { int N, M, T; while (scanf("%d%d", &N, &M) != EOF) { vec.clear(); memset(ansx, -1, sizeof(ansx)); memset(ansy, -1, sizeof(an...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const int inf = 0x3f3f3f3f; const double eps = 1e-15; const long long INF = (1LL << 60); const int N = 200000 + 100; int xis[N << 1]; bool vis[N << 1]; struct QUE { bool flag; int x, y; } que[N]; struct SegTree { int l, r; int val; } tr...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int n, m; map<int, pair<char, int> > mp; int x, y; char c; void query() { cin >> x >> y >> c; auto yy = mp.lower_bound(x); if (yy->first == x) { cout << "0" << endl; return; } if (c == 'L') { yy--; } int res = abs(yy->first - x); if (yy->second.f...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
import java.io.*; import java.util.*; public class CODEFORCES { @SuppressWarnings("rawtypes") static InputReader in; static PrintWriter out; public static class SegmentTree { int n; int arr[], lazy[]; SegmentTree(int n) { this.n = n; arr = new int[n << 2]; lazy = new int[n << 2]; } Segment...
JAVA
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; map<int, int> r; int x[200010], y[200010]; int main() { int n, q; cin >> n >> q; r[0] = r[n + 1] = q; x[q] = 0; y[q] = 0; while (q--) { char c; cin >> x[q] >> y[q] >> c; map<int, int>::iterator it = r.lower_bound(x[q]); if (it->first == x[q]) { ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int n, q, x, y, ans; char ch; map<int, pair<char, int> > mp; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ; cin >> n >> q; mp[0] = {'U', 0}; mp[n + 1] = {'L', 0}; while (q--) { cin >> x >> y >> ch; auto it = mp.lower_bound(x); ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int n, q; struct data1 { int x, ans; bool opt; bool operator<(const data1 &p) const { return x < p.x; } }; struct data2 { int x, ans; bool opt; bool operator<(const data2 &p) const { return x > p.x; } }; set<data1> s1; set<data2> s2; int main() { scanf("%d%d",...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int n, q, x, y; char c; map<int, int> M; pair<int, int> P, T; set<pair<int, int> > S; int main() { scanf("%d %d", &n, &q); T.first = 0; T.second = 2; S.insert(T); T.first = n + 1; T.second = 1; S.insert(T); for (int i = 1; i <= q; i++) { scanf("%d %d %c"...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int read() { int w = 0, f = 1; char c = ' '; while (c < '0' || c > '9') c = getchar(), f = c == '-' ? -1 : f; while (c >= '0' && c <= '9') w = w * 10 + c - 48, c = getchar(); return w * f; } int readop() { char c = getchar(); while (c != 'U' && c != 'L') c = g...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1000000000 + 7; int bs(int *st, int *en, int val, char c) { int k; if (c == 'l') k = lower_bound(st, en, val) - st; if (c == 'u') k = upper_bound(st, en, val) - st; return k; } set<int> sx; set<int> sy; int ans[200005]; map<int, int> mx, my, m; int x...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> const char en = '\n'; using namespace std; int main() { ios::sync_with_stdio(false); int n, q; cin >> n >> q; map<long long, long long> M; M[n + 1] = -n - 1; M[0] = n + 1; while (q--) { int x, y; char c; cin >> x >> y >> c; if (c == 'U') { auto it = M.lower_b...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
import java.awt.Point; import java.io.File; import java.io.FileInputStream; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; import java.util.TreeMap; public class main { static class Area { Area(int row, int rows, int rowsize, int colu...
JAVA
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; struct Node { int l, r, len_u, len_l; inline Node() {} inline Node(int _l, int _r, int _len_u, int _len_l) : l(_l), r(_r), len_u(_len_u), len_l(_len_l) {} inline bool operator<(const Node &oth) const { return l < oth.l; } }; int n, q; set<Node> st; int main() ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int INF = 0x7fFFffFF; struct MinTree { int n; vector<int> c; MinTree(int _n) : n(_n), c(4 * _n + 3, INF) {} int _query(int l, int r, int nl, int nr, int node) { if (l <= nl && nr <= r) return c[node]; if (nr < l || r < nl) return INF; return min(_q...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; struct ask { int x, y; string xx; } ask[200001]; struct tree { int l, r; int ma; int tag; } tr[2][1600001]; inline void build(int p, int l, int r, int pp) { tr[pp][p].l = l; tr[pp][p].r = r; if (l != r) { int mid = (l + r) / 2; build(p * 2, l, mid, p...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; struct t { int v; t() { v = 0; } t(int v_) { v = v_; } t operator+(const t &t_) { return t(max(v, t_.v)); } }; struct u { int v; u() { v = 0; } u(int v_) { v = v_; } t operator()(const t &t_) { return t(max(v, t_.v)); } u operat...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; map<int, pair<char, int> > inMap; map<int, pair<char, int> >::iterator itlow; int N, Q, i, x, y, ans; string type; int main() { cin >> N >> Q; inMap[0] = {'U', 0}; inMap[N + 1] = {'L', 0}; for (i = 1; i <= Q; ++i) { cin >> x >> y >> type; itlow = inMap.lower...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int n, ans, T; map<int, int> l; map<int, int> u; int main() { scanf("%d %d", &n, &T); while (T--) { int x, y; char ch; scanf("%d %d", &x, &y); ch = getchar(); while (ch != 'U' && ch != 'L') ch = getchar(); if (ch == 'U') { map<int, int>::it...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> struct Piece { int x0, x1, y0, y1, n; Piece left(int x) { return {x0, std::min(x - 1, x1), y0, y1, n}; } Piece right(int x) { return {std::max(x0, x + 1), x1, y0, y1, n}; } Piece up(int y) { return {x0, x1, y0, std::min(y - 1, y1), n}; } Piece down(int y) { return {x0, x1, std::max(y0...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> const int md = 1e9 + 7; using namespace std; int n, q, x, y; char c; struct shape { int l, r, h, w; shape(int l = 0, int r = 0, int h = 0, int w = 0) : l(l), r(r), h(h), w(w){}; pair<shape, shape> cut(int x, char d) { int l1 = l, r1 = x - 1, l2 = x + 1, r2 = r, h1, w1, h2, w2; w1 ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; inline int read() { register int x; register char c(getchar()); register bool k; while ((c < '0' || c > '9') && c ^ '-') if ((c = getchar()) == EOF) exit(0); if (c ^ '-') x = c & 15, k = 1; else x = 0, k = 0; while (c = getchar(), c >= '0' && c <= ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int M = 2e5 + 5; set<std::pair<int, int> > st; set<std::pair<int, int> >::iterator it; int n, m, x[M], y[M]; char str[2]; int main() { scanf("%d %d", &n, &m); st.insert(make_pair(0, 0)); st.insert(make_pair(n + 1, m + 1)); for (int i = 1; i <= m; i++) { sc...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStream; ...
JAVA
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; long long int inline ipow(long long int a, long long int b, long long int m) { long long int val = 1; a %= m; while (b) { if (b & 01) val = (val * a) % m; b >>= 1; a = (a * a) % m; }; return val % m; } long long int inline ipow(long long int a, long lo...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int n, q; const int N = (1 << 20) + 2, MOD = 1000000007LL; struct Query { int x, y; char typ; } queries[N]; struct segmentTree { int tree[N]; int lazy[N]; void push_down(int ni, int ns, int ne) { if (ns == ne || !lazy[ni]) return; int lf = 2 * ni + 1, rt =...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int x[400010], y[400010], op[400010], hashx[400010], hashy[400010], cnt1 = 0, cnt2 = 0, Max[2][400010 << 2], lazy[2][400010 << 2]; map<pair<int, int>, bool> M; void pushdown(int i, int type) { if (lazy[type][i]) { lazy[type][i << 1] = max(lazy[type][i << 1], lazy[...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int INF = 0x7f7f7f7f; void setup() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(15); } struct seg_tree { struct node { int val; node(int _val = 0x7f7f7f7f) { val = _val; } node operator+(const node &y) { return min(...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:100000000000,100000000000") using namespace std; const double eps = 1E-9; const double Exp = 2.718281828459045; const double Pi = 3.1415926535897932; const int NMAX = 200000 + 5; const int MMAX = 100000 + 5; const int INF = 1000000000; const int BS = 1000000007; ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Bit...
JAVA
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int n, m; map<int, pair<char, int> > M; map<int, pair<char, int> >::iterator it; int x, y, tmd; char c[2]; int main() { scanf("%d%d", &n, &m); M[0] = {'U', 0}; M[n + 1] = {'L', 0}; while (m--) { scanf("%d%d%s", &x, &y, c); it = M.lower_bound(x); if (it->...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 200005; struct pi { int lazy; int le, ri; } pp[2][maxn << 2]; void build(int u, int tot, int l, int r) { pp[u][tot].le = l; pp[u][tot].ri = r; pp[u][tot].lazy = 0; if (l == r) return; build(u, 2 * tot, l, (l + r) / 2); build(u, 2 * tot + 1, ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; template <class T> inline void amin(T &a, const T &b) { if (b < a) a = b; } template <class T> inline void amax(T &a, const T &b) { if (a < b) a = b; } struct Data { int sx, sy; int le, ri, to, bo; bool operator<(const Data &y) const { return sx < y.sx; } }; int N...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> template <class T> inline bool cmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } template <class T> inline bool cmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } using namespace std; const int N = 5e6 + 5; char s[5]; int ls[N], rs[N], mx[N], mn[N], nd, n, q, rt; inline int max(r...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 200005; struct Segment_Tree { struct Node { int v; bool Tag; int sl; }; Node tree[N << 2]; void Update(int root, int left, int right) { if (tree[root].Tag == false) return; tree[root].v = max(tree[root].v, tree[root].sl); tree[r...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int a; int answer(int l, int r, int b, int e, int i, const vector<int>& x) { if ((l == b) && (r == e)) return x[i]; int m = (e + b) / 2; if (m <= l) return max(x[i], answer(l, r, m, e, i * 2 + 2, x)); if (m >= r) return max(x[i], answer(l, r, b, m, i * 2 + 1, x)); ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = (1 << 19) + 10; char c; bool dir, mark[maxn]; int n, q, low, high, val, seg[2][maxn]; vector<int> v; vector<pair<int, bool>> folan; void shift(int& id, int& left, int& right) { if (dir) { seg[dir][left] = min(seg[dir][left], seg[dir][id]); seg[dir...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; map<int, int> u, l; int main() { int n, t; scanf("%d%d", &n, &t); while (t--) { int x, y, saber = 0; char ch; cin >> x >> y >> ch; map<int, int>::iterator it; if (ch == 'U') { if (u.count(x)) { printf("0\n"); continue; }...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 400000 + 123; class Cseg { public: int h, M; int n; int maxx[N * 4 * 2]; int flag[N * 4 * 2]; void ini(int n) { int i; this->n = n; h = ceil(log(n + 2.0) / log(2.0)) + 1; M = 1 << (h - 1); memset(flag, 0, sizeof(flag)); memse...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> const double PI = acos(-1.0); const int maxn = 1e5; const int INF = 1e9; using namespace std; int n, q; map<int, int> u; map<int, int> l; int main() { while (scanf("%d %d", &n, &q) != EOF) { u.clear(); l.clear(); while (q--) { map<int, int>::iterator p; int x, y; ...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> const double PI = acos(-1.0); using namespace std; struct Tree { int m, d; Tree *L, *R; Tree(int _m) : m(_m), d(0), L(0), R(0) {} }; void push(Tree *T) { T->m = max(T->m, T->d); if (T->L) T->L->d = max(T->L->d, T->d); if (T->R) T->R->d = max(T->R->d, T->d); } int get(Tree *T, int tl...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; int n, q; int x, y, z; int sum = 0; map<int, pair<char, int> > ans; map<int, pair<char, int> >::iterator t; int main() { scanf("%d%d", &n, &q); ans[0] = {'U', 0}; ans[n + 1] = {'L', 0}; for (int i = 1; i <= q; i++) { scanf("%d%d%c%c", &x, &y, &z, &z); t = an...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; struct node { int maximum; int lazy; node *l, *r; node(int value) { maximum = value; lazy = 0; l = r = NULL; } }; node *tree[2]; void push(node *curr, int l, int r) { if (curr->lazy) { if (curr->l != NULL) { curr->l->lazy = max(curr->l->laz...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
import jdk.nashorn.internal.ir.Assignment; import java.io.*; import java.util.Arrays; import java.util.Map; import java.util.StringTokenizer; import java.util.TreeMap; public class Main { public static void main(String[] args) throws Exception { IOUtils ut = new IOUtils(System.in, System.out); ne...
JAVA
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
import java.io.*; import java.util.Scanner; import java.util.StringTokenizer; import java.util.TreeSet; public class Main { public static void main(String[] args){ new TaskC().solve(); } } class TaskC { public void solve() { InputStream inputStream = System.in; Outpu...
JAVA
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; long long power(long long a, long long b, long long m = 1000000007) { long long res = 1; while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res; } long long inverse(long long a, long long m = 1000000007) { return power(a...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; class Node { public: int val; Node *l, *r; Node(int v) { val = v; l = NULL; r = NULL; } }; int Q(Node *root, int ind, int beg, int end) { int mid = (beg + end) / 2; if (ind >= beg && ind <= mid) { if (root->l == NULL) return root->val; retur...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; map<long long, pair<char, long long> > m; long long query() { char c; long long x, y; cin >> x >> y >> c; map<long long, pair<char, long long> >::iterator b = m.lower_bound(x); if ((*b).first == x) { return 0; } if (c == 'L') { b--; } long long ans...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n Γ— n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; char s[10]; int main() { map<int, int> A; map<int, char> B; int n, m; scanf("%d%d", &n, &m); while (m--) { int x, y, z = 0; scanf("%d%d%s", &x, &y, s); if (A.find(x) != A.end()) { puts("0"); continue; } if (s[0] == 'L') { auto...
CPP