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
import java.io.*; import java.util.*; public class C implements Runnable{ public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();} public void run() { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); System.err.println("Go!"); int n = fs...
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.Scanner; import java.util.TreeMap; public class P556Ef { static long get_val(TreeMap<Long, Long> map, long query){ return map.ceilingEntry(query).getValue()- query + 1; } static boolean has_val(TreeMap<Long, Long> map, long query){ return map.containsKey(query); } static void add_vals...
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, q; map<int, int> r; map<int, int> l; int main() { scanf("%d%d", &n, &q); map<int, int>::iterator it; for (int i = 0; i < q; i++) { int x, y; char cm[2]; scanf("%d%d%s", &x, &y, cm); if (cm[0] == 'U') { if (r.count(x)) { printf("0\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> using namespace std; const int N = 400010; struct tree { int l, r, minn, tag; } tl[4 * N], tu[4 * N]; int n, qq; map<int, map<int, int> > mp; struct question { int x, y, id; char c; } q[N], aq[N]; int lsh[2 * N], cnt, px[N]; void update(int i) { tl[i].minn = max(tl[i << 1].minn, tl[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; struct node { int x, up, left; node(int x, int up, int left) { this->x = x; this->up = up; this->left = left; } bool operator<(const node &cmp) const { return x < cmp.x; } }; set<node> a; int main() { int n, q; scanf("%d%d", &n, &q); a.insert(node(...
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 inft = 1000000009; const int MAXN = 1000006; const int T = 1024 * 1024; int drz[2][2 * T]; vector<int> X; pair<int, int> Q[MAXN]; char C[MAXN]; bool used[MAXN]; int ask(int a, int nr) { int ans = -1; a += T; while (a) { ans = max(ans, drz[nr][a]); 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
import java.io.*; import java.util.Scanner; import java.util.TreeSet; public class Main { public static void main(String[] args){ new TaskC().solve(); } } class TaskC { public void solve() { Scanner in=new Scanner(new BufferedInputStream(System.in)); long n=...
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> #pragma comment(linker, "/stack:20000000") using namespace std; using mt = int32_t; using fl = double; template <typename T> constexpr mt infValue = std::numeric_limits<T>::max() - 1000; template <typename T> constexpr mt maxValue = std::is_same<T, int>::value ? 1000000007 : 100000000000000...
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); } const int MN = 1 << 19; struct seg_tree { vector<int> arr; seg_tree() { arr = vector<int>(2 * MN + 100, INF); } int upd(int i, int v, 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
#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 GCC optimize("O3") using namespace std; map<int, pair<char, int> > ma; map<int, pair<char, int> >::iterator it; int ans = 0, n, m, x, y; string s; int main() { ios::sync_with_stdio(false); cin >> n >> m; ma[0] = pair<char, int>('U', 0); ma[n + 1] = pair<char, int>('L', 0); whi...
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:100000000") using namespace std; const double eps = 1.0e-11; const double pi = acos(-1.0); using namespace std; struct el { int x, y; char c; int old; int idx; bool operator<(const el& temp) const { if (x != temp.x) return x < temp.x; return old...
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 cnt = 0; char buf[100000000]; class Tree { public: int from, to; int value; Tree *L, *R; Tree() { cnt += 1; }; Tree(int from, int to) : from(from), to(to), value(0), L(nullptr), R(nullptr) { cnt += 1; } void modify(int pos, int val); int query...
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 = 0x3f3f3f3f3f3f3f3f; const long long mod = 998244353; int n, m; int x, y; char c; struct Tree { int cnt = 0, root = 0; struct Node { int ls = 0, rs = 0, ma = 0; } t[4 * 200010]; void add(int &o, int l, int r, int ql, int qr, int v) { if ...
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; int q; set<pair<pair<int, int>, pair<int, int> > > s; set<int> bio; int main() { cin >> n >> q; s.insert(make_pair(pair<int, int>(n, 1), pair<int, int>(1, n))); for (int i = 0; i < q; i++) { int bla, row; string dir; cin >> bla >> row >> dir; if...
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; #pragma warning(disable : 4996) const int INF = 1 << 30; const int N = 200000 + 10; set<pair<int, int> > s; set<pair<int, int> >::iterator it; int x[N], y[N]; int main() { int n, q; char d[2]; scanf("%d%d", &n, &q); s.insert(make_pair(0, q + 1)); s.insert(make_pai...
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.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashMap; import java.util.HashSet; import java.util.Map.Entry; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeMap; import ...
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, first, second; char w; map<int, pair<int, int>> z; int main() { cin >> n >> m; z[n + 1]; while (m--) { cin >> first >> second >> w; auto i = *z.lower_bound(first); cout << (i.first - first ? (w & 1 ? second - i.second.second : fi...
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[20]; map<int, int> row, col; map<int, int>::iterator it; int main() { int n, q, x, y, ans; scanf("%d%d", &n, &q); while (q--) { scanf("%d%d%s", &x, &y, s); if (s[0] == 'U') { it = col.lower_bound(x); if (it == col.end()) ans = 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; const int MN = 13000009, INF = 1196969696; int MIN[MN], MAX[MN], lewy[MN], prawy[MN]; int P2 = 1, lastNode; map<int, int> bylo[2]; void ustawMin(int x, int v, int curr, int l, int p) { if (l == p && l == x) { MIN[curr] = v; return; } int mid = (l + p) >> 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; int nextInt() { int x = 0, p = 1; char ch; do { ch = getchar(); } while (ch <= ' '); if (ch == '-') { p = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + (ch - '0'); ch = getchar(); } return x * p; } const int N = 10...
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 = 200000 + 100; struct T { long long r, c; int opr; }; struct Node { long long num; int id; Node(long long num, int id = 0) : num(num), id(id) {} bool operator<(const Node& rhs) const { return num < rhs.num; } }; T save[maxn]; int IDup[maxn], IDle...
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 val; int lzy; }; struct Data { int n; Node T[4000000]; vector<pair<int, int> > segs; void Init(vector<pair<int, int> > d) { segs = d; n = segs.size(); for (int i = 0; i <= n; i++) T[i].val = 0, T[i].lzy = 0; } void push(int node...
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 edge { int u, v; long long w; }; long long MOD = 1000000007; long long _MOD = 1000000009; double EPS = 1e-10; void f(vector<pair<int, int> >& e, vector<int>& a) { sort(e.begin(), e.end()); stack<int> I, X; I.push(-1); X.push(0); long long sum = 0; for...
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> using namespace std; map<int, int> h; map<int, int> l; map<int, int>::iterator it; int main() { int n, q; scanf("%d%d", &n, &q); for (int i = 1; i <= q; i++) { int x, y; char op[5]; scanf("%d%d%s", &x, &y, op); if (op[0] == 'U') { int ans = 0; it = h.lower_boun...
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.*; import java.util.List; public class C { private static StringTokenizer st; private static BufferedReader br; public static long MOD = 1000000007; private static double EPS = 0.0000001; public static void print(Object x) { System.out.println(x + ""); ...
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.Scanner; import java.util.TreeMap; import java.util.TreeSet; public class Main { public void solve() { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); int Q = scanner.nextInt(); TreeSet<Integer> xRecord = new TreeSet<>();// 前に出てきたx // 自分よりx座標の小さいクエリが来た時にどこが壁になるか、を記録する...
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.*; /** * Created by sbabkin on 9/14/2015. */ public class SolverE { public static void main(String[] args) throws IOException { new SolverE().Run(); } BufferedReader br; PrintWriter pw; StringTokenizer stok; private String nextToken() throws IOEx...
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 Q = 200100; int x[Q], y[Q], pos[Q]; char d[Q]; struct Node { int l, r, left, up; int lazy_left, lazy_up; Node() {} Node(int l, int r) : l(l), r(r), left(0), up(0), lazy_left(0), lazy_up(0) {} } node[4 * Q]; void build_tree(int seg, int l, int r) { node[s...
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; set<int> in; map<int, int> re, d; int N, M, X[200005], R[200005], V[200005], S[200005]; char D[200005]; int main() { scanf("%d %d", &N, &M); for (int i = 1; i <= M; i++) { scanf("%d %*d %c", &X[i], &D[i]); re[X[i]] = 0; } X[M + 1] = N + 1; D[0] = 'U'; 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
import java.io.*; import java.text.DecimalFormat; import java.util.*; public class Main { static InputStream inputStream = System.in; static OutputStream outputStream = System.out; static Scanner in = new Scanner(inputStream); static PrintWriter out = new PrintWriter(outputStream); public static void main(Strin...
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 main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, q; cin >> n >> q; map<int, pair<char, int>> mp; mp[0] = make_pair('U', 0); mp[n + 1] = make_pair('L', 0); while (q--) { int x, y; char cc; cin >> x >> y >> cc; auto ...
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 meo { int x, y, x1, y1, p; }; const int N = 200010; int n, q, dir[N], X, Y; meo a[N]; bool comparex(meo i, meo j) { if (i.x == j.x) { if (i.y == j.y) return i.p < j.p; else return i.y < j.y; } return i.x < j.x; } bool comparey(meo i, meo j...
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 Nod { int val; Nod *L, *R; Nod(int i) : val(i), L(NULL), R(NULL) {} }; int x[200005]; char c[200005]; int t[200005]; map<int, int> u; int v[200005]; void rfs(Nod *a) { if (a->L != NULL) { a->L->val = max(a->L->val, a->val); a->R->val = max(a->R->val, ...
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.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashSet; import java.util.StringTokenizer; import java.util.TreeMa...
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, q, x, y, hor, ver; char z; set<pair<int, pair<int, int> > > S; set<pair<int, pair<int, int> > >::iterator it; set<int> B; int main() { scanf("%d%d", &n, &q); S.insert(make_pair(0, make_pair(0, 0))); while (q--) { scanf("%d%d", &y, &x); cin >> z; if ...
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> using namespace std; int gi() { int a; scanf("%d", &a); return a; } long long gli() { long long a; scanf("%lld", &a); return a; } struct bar_ { int a; int b; int left; int top; }; map<int, bar_> m; map<int, bar_>::iterator it; void ins(bar_ &b) { if (b.a <= b.b) m[b.b] = 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
#include <bits/stdc++.h> using namespace std; const int N = 200100; int t[2 * N][2]; int sz[2]; void build(int i) { for (int p = sz[i] - 1; p > 0; p--) { t[p][i] = min(t[p << 1][i], t[p << 1 | 1][i]); } } void update(int i, int p, int v) { for (t[p += sz[i]][i] = v; p > 1; p >>= 1) { t[p >> 1][i] = min(t[...
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 val; node *l, *r; node() { val = 0; l = NULL; r = NULL; } }; node *segr, *segc; void update(node *cur, int l, int r, int x, int y, int val) { if (l > r || l > y || r < x) return; if (x <= l && r <= y) { cur->val = max(cur->val, ...
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 = 4e5 + 9; int n, q, tree[2][4 * MAX], lazy[2][4 * MAX], l, r, idx, val; vector<pair<pair<int, int>, char> > v; map<int, int> encode, decode; void push(int id, int low, int high, int pos) { tree[id][pos] = max(tree[id][pos], lazy[id][pos]); if (low != high...
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.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.List; 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
#include <bits/stdc++.h> using namespace std; struct query { int x, y; char d; }; struct node { int rmq; node() : rmq(2000000000) {} void merge(node& ls, node& rs) { rmq = min(ls.rmq, rs.rmq); } }; struct segtree { node seg[1000000]; node segQuery(int n, int l, int r, int i, int j) { if (i <= l && 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; struct node { int val; int lazy; node *l; node *r; node(node *x, node *y, int v, int ll) { l = x; r = y; val = v; lazy = ll; } }; int gv(node *x) { if (x == NULL) return 0; return x->val; } int gl(node *x) { if (x == NULL) return 0; 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; const long long MOD = 1e9 + 7; long long n, q, row[200010]; vector<pair<long long, long long> > que; vector<long long> v, r; map<long long, long long> mp; map<pair<long long, long long>, long long> res; struct segTree { long long n2, dat[800010]; void Init() { n2 = ...
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> #pragma comment(linker, "/STACK:256000000") using namespace std; struct State { int l, r; int addH, addV; State() { l = r = addH = addV = 0; } State(int l, int r, int addH, int addV) : l(l), r(r), addH(addH), addV(addV) {} bool operator<(const State &other) const { return l < ot...
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; map<int, pair<int, char> > Map; int main() { scanf("%d%d", &n, &Q); Map[0] = make_pair(n + 1, 'U'); Map[n + 1] = make_pair(n + 1, 'L'); while (Q--) { int x, y; char d; scanf("%d%d %c", &x, &y, &d); map<int, pair<int, char> >::iterator k = M...
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.StringTokenizer; import java.util.TreeSet; public class ProblemE { public static void main(String[] args) { int testMode = 0; String testInput = "15 7\n" + "8 8 U\n" + "6 10 L\n" + "9 7 L\n" + "3 13 ...
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 dr[] = {1, 0, -1, 0, 1, 1, -1, -1}; const int dc[] = {0, 1, 0, -1, 1, -1, -1, 1}; const double eps = 1e-9; const int INF = 0x7FFFFFFF; const long long INFLL = 0x7FFFFFFFFFFFFFFFLL; const double pi = acos(-1); template <class T> T take(queue<T> &O) { T tmp = O.fr...
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.Scanner; import java.util.TreeMap; public class Main { public void solve() { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); int Q = scanner.nextInt(); // 自分よりx座標の小さいクエリが来た時にどこが壁になるか、を記録する TreeMap<Integer, Wall> wallMap = new TreeMap<>(); wallMap.put(N + 1, new Wall(...
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 INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fll; const int MAX = 5e6; int N; namespace seg1 { int seg[MAX], lazy[MAX], R[MAX], L[MAX], ptr; int get_l(int i) { if (L[i] == 0) { seg[ptr] = seg[i]; L[i] = ptr++; } return L[i]; } int get_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; struct section { int s, e; int lb, lr; section(int a, int b, int c, int d) { s = a; e = b; lb = c; lr = d; } bool operator<(const section aa) const { return e < aa.e; } }; set<section> v; map<int, bool> vis; int cut(int pos, char action, section aa...
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> > mp; map<long long, pair<char, long long> >::iterator it; int main() { long long x, y, n, m, ans; char c; scanf("%lld %lld", &n, &m); mp[0] = make_pair('U', n); mp[n + 1] = make_pair('L', n); while (m--) { scanf("%lld %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
import java.util.*; public final class Chocolate { public static void main(String arg[]) { Scanner br=new Scanner(System.in); int n=br.nextInt(); int q=br.nextInt(); int x[]=new int[200005]; int y[]=new int[200005]; ArrayList<Integer> g=new ArrayList<Integer>(); int j=0; x[0]=y[0]=0; x[q+1]=y[q+1]=0; TreeMa...
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 sz = 1600006; int n, m; int co[sz]; typedef struct A { int x, y; char dir[5]; } AA; AA t[sz]; bool cmp(AA a, AA b) { if (a.x < b.x) return 1; return 0; } int get_idx(int x) { int l = 0, r = 2 * m; int mid; while (r != l) { mid = (l + r) >> 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; int N, Q; map<int, int> bio; map<int, pair<int, int> > vrhovi; int main(void) { scanf("%d%d", &N, &Q); vrhovi[N + 1] = make_pair(0, 0); for (int i = 0; i < Q; i++) { int x, y; string s; cin >> x >> y >> s; if (bio[x]) { printf("0\n "); 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; struct X { int orig; int other; int left; int top; X() {} X(int orig, int other, int left, int top) { this->orig = orig; this->other = other; this->left = left; this->top = top; } }; int main() { int n; cin >> n; int q; cin >> q; set<...
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; const int inv = 2e9; int n, q; map<int, int> vis; set<pair<int, int> > up, lt; set<pair<int, int> >::iterator it, ti; int main() { ios_base::sync_with_stdio(0); cin.tie(0); up.insert({-inv, -inv}); lt.insert({-inv, -inv}); cin >> n >> q; while...
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 NMAX = 200010, INF = 0x3f3f3f3f; int N, Q, X[NMAX], Y[NMAX], Aint[2][4 * NMAX], Cnt, Order[NMAX]; char T[NMAX]; map<int, int> Map; set<int> Used; void Update(int Index, int Node, int Left, int Right, int Pos, int Val) { if (Left == Right) { Aint[Index][Node]...
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
import java.io.*; import java.util.*; import java.awt.Point; public class CodeForces { static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; public class Intersect implements Comparable<Intersect> { public int x; public int y; public Intersect(int x, int y) { this.x = x; ...
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 query { int x, height, tab; }; int max(int a, int b) { if (a < b) return b; else return a; } int min(int a, int b) { if (a < b) return a; else return b; } int maxTree[2][1200000]; int getmax(int tab, int id, int lb, int ub, int cell) { if ...
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.Arrays; import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.StringTokenizer; /** * Built using CHelper plug-in * Actual solution is at the top * @author Ald...
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> const long long mod = 1000000007; const int maxn = 5e5 + 1; long long inf = 1LL << 60; using namespace std; int main() { ios_base::sync_with_stdio(0); int n, q; cin >> n >> q; map<int, pair<int, char>> used; used[0] = {0, 'U'}; used[n + 1] = {0, 'L'}; 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 n, q; struct line { int p, top; line(int p = 0, int top = 0) : p(p), top(top){}; }; bool operator<(const line& a, const line& b) { return a.p < b.p; } bool operator==(const line& a, const line& b) { return a.p == b.p; } set<line> up, fuck; int main(int argc, char* 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; struct segtree { int i, j; int minvalue; int pvalue; segtree *l, *r; segtree(vector<int> &v, int I, int J) : pvalue(-1), l(NULL), r(NULL) { i = v[I]; j = v[J]; minvalue = 0; if (I == J) { } else { int K = I + J >> 1; l = new segtree...
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.*; import static java.lang.Math.max; public class _310C_Shrinked { public static void main(String[] args) throws IOException { InputReader scanner = new InputReader(System.in); PrintWriter writer = new PrintWriter(System.out); int n = scanner.nextInt(); ...
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<int, int> > s; map<int, int> m; int main() { int i, n, q, x, y; char buf[5]; scanf("%d %d", &n, &q); s.insert(make_pair(0, 1)); s.insert(make_pair(n + 1, 0)); for (i = 0; i < q; i++) { scanf("%d %d", &x, &y); scanf("%s", buf); if (m.count(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; const int N = (1 << 19) + 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; struct seg { seg(int a, int x, int y) : A(a), X(x), Y(y) {} int A; int X; int Y; }; bool operator<(const seg &M, const seg &N) { return M.A < N.A; } set<seg> segs; int main() { int N, Q; scanf("%d %d\n", &N, &Q); segs.insert(seg(0, 0, 0)); for (int i = 0; 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.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.StringTokenizer; import java.util.TreeMap; publ...
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, q; set<pair<pair<int, int>, int>> yatay; set<pair<pair<int, int>, int>> dikey; void make(int x, int y, set<pair<pair<int, int>, int>> &yat, set<pair<pair<int, int>, int>> &dik) { set<pair<pair<int, int>, int>>::iterator it = --yat.upper_bound(make_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
import java.io.*; import java.util.*; import static java.lang.Math.max; public class _310C_Shrinked { public static void main(String[] args) throws IOException { InputReader scanner = new InputReader(System.in); PrintWriter writer = new PrintWriter(System.out); int n = scanner.nextInt(); ...
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<int> done; map<int, pair<int, int> > pi; int n, q; int main() { scanf("%d%d", &n, &q); pi[n + 1] = pair<int, int>(0, 0); int x, y; char dir; while (q--) { scanf("%d %d %c", &x, &y, &dir); if (done.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
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.io.UncheckedIOException; import java.util.TreeMap; import java.io.Closeable; import java.util.Map.Entry; import java.io.Writer; import java.io.OutputStreamWriter; imp...
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; class Tree { public: int n; int *val; Tree(int n) { this->n = n; val = new int[4 * n + 5]; fill(val, val + 4 * n + 5, -1); } void update(int l, int r, int v) { internalUpdate(0, 0, n - 1, l, r, v); } int get(int x) { return internalGet(0, 0, n - 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; int n, q, x, y; char type; map<int, pair<char, int> > Data; int solve() { auto fi = Data.lower_bound(x); if (fi->first == x) return 0; if (type == 'L') fi--; int ans = abs(x - fi->first); if (fi->second.first == type) ans += fi->second.second; Data[x] = make_pai...
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 n, q, x[200100], y[200100]; long long lzy1[800200], lzy2[800200], seg1[800200], seg2[800200]; map<long long, long long> m1, m2; map<pair<long long, long long>, bool> vis; char d[200200]; void update1(int st, int en, int l, int r, int id, long long val) { if (st ...
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.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.util.TreeMap; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java....
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
//package cf556; import java.util.*; public class E { private enum Direction { LEFT, UP } private static class Move { private final int x; private final int y; private final Direction direction; private Move(int x, int y, Direction direction) { this.x...
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 Q = 200020; class segment_tree { struct node { int l, r, maxv; } t[Q << 2]; void make_tree(int l, int r, int k) { if (l != r) { int mid = (l + r) >> 1; make_tree(l, mid, k << 1); make_tree(mid + 1, r, (k << 1) | 1); } t[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; int a[400010], cnt; int x[200010], y[200010], w[200010]; map<int, int> mp; int pre[400010]; struct Tree { int L, R, val, add; }; Tree seg[2][1600010]; void build(int pos, int L, int R, int id) { seg[id][pos].L = L; seg[id][pos].R = R; if (L != R) { int mid = (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> const int MAXN = 2e5 + 10; template <int N> struct SegmentTree { static const int M = N << 2; int tag[M], max[M]; inline void modify(int x, int val) { max[x] = std::max(max[x], val), tag[x] = std::max(tag[x], val); } inline void pushUp(int x) { max[x] = std::max(max[((x) << 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; map<int, int> rw, cl; map<pair<int, int>, bool> vis; int main() { int n, q; scanf("%d%d", &n, &q); rw[0] = 0; rw[n + 1] = 0; cl[0] = 0; cl[n + 1] = 0; int x, y; char ins[3]; for (int i = 0; i < q; ++i) { scanf("%d%d%s", &x, &y, ins); pair<int, 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 int maxn = 2e5 + 10; const long long mod = 1e9 + 7; int n, q, ans; map<int, int> u; map<int, int> l; int main() { scanf("%d%d", &n, &q); while (q--) { int x, y; char dir[5]; scanf("%d%d", &x, &y); scanf("%s", dir); if (u.count(x) || l.count(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
import java.util.Arrays; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashMap; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.text.DecimalFormat; import java.util.StringTokenizer; /** * Built using CHelp...
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 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> 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
import java.util.*; public class C { public C () { int N = sc.nextInt(); int Q = sc.nextInt(); int [] ZERO = { 0, 0 }; TreeMap<Integer, int[]> X = new TreeMap<>(); X.put(-1, ZERO); X.put(N+1, ZERO); for (int q : rep(Q)) { int x = sc.nextInt(), y = sc.nextInt(); char d = sc.nextChar(); if (X.c...
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 = 200009; int X[maxn << 2], Y[maxn << 2], lazyX[maxn << 2], lazyY[maxn << 2]; int x[maxn], y[maxn], m, n, p, a[maxn], b[maxn]; char dir[maxn]; void update(int T[], int lazy[], int o, int l, int r, int x, int y, int z) { if (l == x && y == r) { T[o] = ma...
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; set<int> U; map<int, int> mp; int main() { int n, q; scanf("%d%d", &n, &q); int i; map<int, int>::iterator it; for (i = 1; i <= q; i++) { int x, y; char s[2]; scanf("%d%d%s", &x, &y, s); int to; if (mp.find(x) != mp.end()) { printf("0\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.util.Arrays; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Random; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.StringTokenizer; public class Main { public static void main(String[] ar...
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 main() { long long n, q; while (cin >> n >> q) { map<int, pair<char, long long> > mp; mp[0] = make_pair('U', 0); mp[n + 1] = make_pair('L', 0); for (int i = 0; i < q; i++) { long long x, y; char c; scanf("%I64d%I64d %c", &x, &y, &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> int x4[4] = {0, 0, -1, 1}; int y4[4] = {-1, 1, 0, 0}; int x8[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; int y8[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; int xhorse[8] = {1, 2, 1, 2, -1, -2, -1, -2}; int yhorse[8] = {2, 1, -2, -1, 2, 1, -2, -1}; using namespace std; int n, q; map<int, pair<int, int> > mymap; set...
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, k, tmp; int x[1700007], y[1700007]; int R[1700007], C[1700007]; char dir[1700007]; map<int, int> M; set<pair<int, int> > seen; void upd(int san, int a, int b, int l, int r, int node, int *A) { if (a <= l && b >= r) { A[node] = max(A[node], san); return; ...
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 = 1000000; int n; int t1[2 * N], t2[2 * N]; vector<int> u, v; map<int, int> lin, linrev, col, colrev; int nlin, ncol; map<int, int> usedlin, usedcol; int bbeglin(int i) { int beg = 0, end = nlin; while (beg < end) { int mid = (beg + end) / 2; if (lin...
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 int mod = 1e9 + 7; int l[400200], r[400200], x1[400200], x2[400200], p[400200], du[400200], dl[400200]; bool in(char c) { if (c == 'U' || c == 'L') return true; return false; } int split(int t1, int t2) { if (t1 == 0) return t2; if (t2 == 0) return t1;...
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 = 1011110000; vector<int> ke; int n, m; struct Point { int x, y; char c; Point(int _x = 0, int _y = 0, char _c = 0) : x(_x), y(_y), c(_c) {} } pt[201111]; struct SegT { int n, num[3201111]; void init(int _n) { n = _n; fill(num, num + 4 * n, 0...
CPP