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>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long N = 2e5 + 36;
const long long INF = 1e9 + 7;
const long long X[8] = {1, 1, -1, -1, 2, 2, -2, -2};
const long long Y[8] = {2, -2, 2, -2, 1, -1, 1, -1};
pair<pair<int, int>, int> a[N];
set<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;
class sgt {
private:
vector<int> Max;
vector<int> Lc;
vector<int> Rc;
int Pool = 0;
public:
sgt() {}
sgt(int N) : Lc(N * 50), Rc(N * 50), Max(N * 50, -1) {}
void update(int L, int R, int &X, int A, int B, int V) {
if (L > B || R < A) {
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 | 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.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
/**
* Built using CHelper plug-i... | 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.*;
import java.io.*;
public class CaseOfChocolate555C_TreeMap {
static class Border {
int upper, left;
public Border(int a, int b) {
this.upper = a;
this.left = b;
}
}
static void go() {
int n = in.nextInt();
int q = in.nex... | 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(false);
int n, m;
cin >> n >> m;
map<int, pair<int, int>> mp;
mp[0] = make_pair(n + 1, 0);
while (m--) {
int x, y, ans;
char dir;
cin >> x >> y >> dir;
if (mp.count(x)) {
cout << 0 << '\n';
conti... | 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 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 1000000005;
int n, q, l, r;
struct node {
int seg, lz;
node *left, *right;
node() {
left = right = NULL;
seg = lz = 0;
}
} * root[2];
void fix(node *cur, int 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;
const int N = 200000 + 10;
const int inf = (int)(1e9) * 2;
struct segment_tree {
int limit[N * 4], tag[N * 4];
void buildtree(int u, int l, int r) {
tag[u] = -1, limit[u] = inf;
if (l == r) return;
int mid = l + r >> 1;
buildtree((u << 1), l, mid), build... | 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 r, c;
int last;
char ty;
node() {}
node(int a, int b, int cc, char t) {
r = a;
c = b;
last = cc;
ty = t;
}
bool operator<(const node& b) const { return r < b.r; }
bool operator==(const node& b) const { return r == b.r && 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 | import java.io.*;
import java.util.*;
public class C_new {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
static class Node {
int l, r;
Node left, right;
int val;
public Node(int l, int r) {
this.l = l;
this.r = r;
if (r - l > 1) {
int mid = (l + r) >> 1;
left = ... | 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> ren;
char buf[100];
const int MAXTSZ = int(2e5 + 100) * 2 * 4;
struct query {
int x, y;
char dir;
};
int get_name(int x) {
int sz = ren.size();
return ren.insert(make_pair(x, sz)).first->second;
}
set<int> t_up[MAXTSZ], t_left[MAXTSZ];
typedef set<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 | 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()
sz =... | 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 | 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;
const int treesize = 1 << 30;
struct tnode {
tnode *l, *r;
int max;
tnode() {
l = NULL;
r = NULL;
max = 0;
}
};
typedef tnode* pnode;
pnode sett(pnode cur, int cl, int cr, int l, int r, int t) {
if (cl > r || cr < l) return cur;
if (cur == NULL) cur ... | 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> up, lft;
set<int> used;
int main() {
int N, Q;
scanf("%d %d ", &N, &Q);
;
up.insert(make_pair(0, 0));
lft.insert(make_pair(0, 0));
for (int i = (0); i < (Q); i++) {
int c, r;
scanf("%d %d ", &c, &r);
;
string s;
cin >> s;
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;
set<pair<int, int> > s;
map<int, int> mp;
int n, q, x, y;
char ss[10];
int main() {
scanf("%d%d", &n, &q);
s.insert(make_pair(0, 1));
s.insert(make_pair(n + 1, 0));
mp.clear();
while (q--) {
scanf("%d%d%s", &x, &y, ss);
if (mp.count(x) != 0) {
printf... | 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<pair<int, int> > st;
set<pair<int, int> >::iterator it;
int X[200005], Y[200005], n, m;
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++) {
char o;
scanf("%d %d %c", &X[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>
#pragma comment(linker, "/STACK:67108864")
using namespace std;
const int MX = 200005;
const int MOD = 1000000007;
set<int> L, U;
struct node {
node(int nw) : nw(nw) { left = right = NULL; }
int nw;
node *left, *right;
};
struct segtree {
node* root;
int S = 0, E = 1000000000;
segtr... | 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 modulo(long long x, long long y) { return ((x % y) + y) % y; }
struct SegmentMaxTree {
SegmentMaxTree(int default_value, int n) : default_value(default_value) {
sz = 1;
while (sz < n) {
sz = sz << 1;
}
items.resize(2 * sz - 1);
fill(ite... | 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, q;
std::map<int, int> u, l;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
while (isdigit(ch)) x = x * 10 + (ch - '0'), ch = getchar();
return x * f;
}
int main() {
int x, y;
char op;
n = read(), 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, m, cnt, rt, L[8000100], R[8000100], mx[2][8000100];
map<int, int> t[2];
inline int gi() {
int s = 0;
char c = getchar();
while (c < '0' || c > '9') c = getchar();
while (c >= '0' && c <= '9') s = s * 10 + c - '0', c = getchar();
return s;
}
void updata(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;
int n, q, x, y, ans;
char ch[2];
map<int, int> Left, Up;
map<int, int>::iterator it;
int main() {
ios::sync_with_stdio(false);
while (scanf("%d%d", &n, &q) != EOF) {
Left.clear();
Up.clear();
while (q--) {
scanf("%d%d%s", &x, &y, ch);
if (Up.find... | 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 | import java.util.Scanner;
import java.util.TreeSet;
public class Main
{
static private int n;
static private int q;
static private TreeSet<Area> set = new TreeSet<Area>();
static private TreeSet<Integer> used = new TreeSet<Integer>();
private static class Area implements Comparable<Area>, Cloneable
{
publi... | 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 int mod = 1000000007;
const int gmod = 5;
const int inf = 1039074182;
const double eps = 1e-9;
const long long llinf = 1LL * inf * inf;
template <typename T1, typename T2>
inline void chmin(T1 &x, T2 b) {
if (b < x) x = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &x, 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;
int n, m;
map<int, int> u, l;
int update_u(int x, int y) {
int ans = y;
auto it = u.lower_bound(x);
if (it->first == x) {
return 0;
}
ans = min(ans, it->second + it->first - x);
auto it2 = l.lower_bound(x);
if (it2->first < it->first) ans = min(ans, it2->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 | #include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int infint = (long long)1e9 + 7;
const long long inf = (long long)1e18;
const int MAXN = (int)2e5 + 3;
int n, q;
set<int> S;
unordered_map<int, char> C;
unordered_map<int, int> ans;
int main() {
ios::sync_with_stdio(false);
cin.tie(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 | 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()
V = ... | PYTHON |
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;
using pii = pair<int, int>;
int n, q;
set<pii> sv[2];
set<int> cor[2];
int main() {
ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
cin >> n >> q;
int x, y;
char c;
while (q--) {
int res;
cin >> x >> y >> c;
bool b = c == 'U';
if (!b) 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;
long long n;
long long x, y;
int q;
string ss;
map<long long, long long> shang;
map<long long, long long> zuo;
int main() {
scanf("%lld %d", &n, &q);
for (int i = 1; i <= q; i++) {
cin >> x >> y >> ss;
if (ss[0] == 'U') {
map<long long, long long>::iterato... | 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 = 2 * 1000 * 100 + 10;
vector<int> X, Y;
struct Que {
int x, y;
char ch;
};
Que a[maxN];
typedef int Seg[4 * maxN];
Seg seg[2];
int gg(int p, Seg seg, int xl, int xr, int ind = 1) {
if (xr - xl == 1) return seg[ind];
int xm = (xl + xr) >> 1;
seg[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 | #include <bits/stdc++.h>
using namespace std;
const int TREE = 1002000;
vector<int> xx;
vector<int> yy;
int n, m;
int x[TREE], y[TREE];
char o[TREE];
map<int, bool> ux;
map<int, bool> uy;
int tx[TREE * 5], ty[TREE * 5];
map<int, int> mx;
map<int, int> my;
int getx(int v, int l, int r, int pos) {
if (pos > r || pos < ... | 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 EXP = 2.7182818284590452;
const double Pi = 3.14159265;
const double EPS = 1e-13;
const int INF = 1000 * 1000 * 1000;
const long long INFL = (long long)INF * (long long)INF;
int gcd(int a, int b) {
if (a < b) swap(a, b);
while (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.io.*;
import java.util.*;
public class Solve {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
Task solver = new Task();
solver.... | 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;
int n, q;
map<int, int> u;
map<int, int> l;
int main() {
int x, y;
char op[5];
cin >> n >> q;
while (q--) {
scanf("%d%d%s", &x, &y, op);
map<int, int>::iterator p;
if (op[0] == 'U') {
int ans = 0;
p = u.lower_bound(x);
if (u.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 | import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
/**
*
* @author Saju
*
*/
public class Main {
static int[] dx = { 0, 1, 0, -1 };
static int[] dy = {... | 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 = 400010;
struct TREE {
int l, r;
int val, mark;
int mid() { return (l + r) >> 1; }
} tree[2][MAXN << 2];
void pushdown(int k, int op) {
if (tree[op][k].mark) {
tree[op][(k << 1)].val = max(tree[op][(k << 1)].val, tree[op][k].mark);
tree[op][(... | 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, i, j, x, y, s[5], an[200010];
set<pair<int, int> > st1, st2;
set<pair<int, int> >::iterator it, it1;
int main() {
scanf("%d%d", &n, &m);
st1.insert(make_pair(0, 0));
st2.insert(make_pair(0, 0));
st1.insert(make_pair(n + 1, m + 1));
st2.insert(make_pair(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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;
/**
* Created by David Zeng on 9/13/2015.
*/
public class Problem555C {
public static void main(String[] args) throws IOException {
... | 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 = 1e6 + 69, MOD = 1e9 + 7;
int n, q, ans;
unordered_map<int, bool> mark;
map<int, pair<int, int>> aXis;
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> q;
int l, r, type;
char ip;
aXis[0] = {-1, 0}, aXis[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;
inline void rd(int &x) {
x = 0;
char f = 1, o;
while (o = getchar(), o < 48)
if (o == 45) f = -f;
do x = (x << 3) + (x << 1) + (o ^ 48);
while (o = getchar(), o > 47);
x *= f;
}
char R[200005];
int X[200005], Y[200005], n, m, Q;
int A[200005], Tx[200005], Ty... | 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;
vector<int> pts;
template <int N>
struct stree {
int data[N];
int lazy[N];
int BVAL;
function<int(int, int)> op;
void getVals(int& pos, int& lchild, int& rchild, int& lnode, int& rnode,
int& len, int& lb, int& rb) {
len = (pos & -pos);
lchil... | 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 *r, *l;
int v;
node() {
l = NULL;
r = NULL;
v = 0;
}
};
inline void update(node*& cur, int b, int e, int l, int r, int val);
inline int query(node*& cur, int b, int e, int id);
constexpr int MAXN = 1 << 30;
node* root[2];
int n, q;
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 | //package acm;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
InputR... | 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, bool> check;
set<pair<int, pair<char, int> > > s;
int main() {
ios_base ::sync_with_stdio(false);
cin.tie(0);
int n, q;
cin >> n >> q;
s.insert(make_pair(n + 1, make_pair('L', n)));
s.insert(make_pair(0, make_pair('U', 1)));
while (q--) {
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 | 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;
//Out... | 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 debugger {
template <typename T>
debugger& operator,(const T& v) {
cerr << v << " ";
return *this;
}
} dbg;
struct info {
map<long long, long long> same;
set<long long> other;
};
int main() {
std::ios_base::sync_with_stdio(false);
enum direction... | 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.*;
import java.math.*;
import java.text.*;
public class Main
{
static FastScanner in = new FastScanner(System.in);
static StringBuilder sb = new StringBuilder();
static DecimalFormat df = new DecimalFormat();
public static void main(String[] args)
{
df.setMaximumFractio... | 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 |
// Problem : C. Case of Chocolate
// Contest : Codeforces - Codeforces Round #310 (Div. 1)
// URL : https://codeforces.com/contest/555/problem/C
// Memory Limit : 256 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
import java.io.*;
import java.util.*;
import java.util.stream... | 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 {
Node(int s = 0, Node* left = nullptr, Node* right = nullptr)
: val(s), L(left), R(right), lazy(0) {}
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>
using namespace std;
template <typename T>
struct Segtree {
int N;
vector<T> seg, lazy;
Segtree(int _n) : N(_n) {
seg.resize(4 * N, 0);
lazy.resize(4 * N, 0);
}
T join(T x, T y) { return max(x, y); }
void push(int x, int s, int e) {
if (!lazy[x]) return;
seg[x] = max... | 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 = 12000003;
int mx[maxn], z[maxn], L[maxn], R[maxn], cnt, n, Q;
struct SEG {
int root;
void change(int &p, int l, int r, int seg_l, int seg_r, int k) {
if (!p) p = ++cnt;
if (seg_l <= l && r <= seg_r) {
z[p] = max(z[p], k);
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;
int x, y;
char op[5];
map<int, int> u;
map<int, int> l;
int n, q;
int main() {
scanf("%d %d", &n, &q);
while (q--) {
scanf("%d%d%s", &x, &y, op);
map<int, int>::iterator p;
if (op[0] == 'U') {
p = u.lower_bound(x);
int ans = 0;
if (u.count(... | 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 n, q;
map<int, int> mp;
char way[200005];
int res[200005];
std::ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> q;
way[0] = 'U', way[q + 1] = 'L';
mp[0] = 0;
mp[n + 1] = q + 1;
res[0] = res[q + 1] = 0;
for (int i = 1; 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;
set<pair<pair<int, int>, int> > pcs;
int l[1010101];
int u[1010101];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, q;
cin >> n >> q;
int i2 = 2;
pcs.insert({{1, n}, 1});
pcs.insert({{n + 1, n + 2}, 1});
for (int i = 0; i < q; i++) {
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>
using namespace std;
struct qry {
int x, y;
char op;
};
bool hc[2][800010];
int c[2][800010];
int N, st;
int query(int x, int n = 1, int l = 0, int r = N) {
if (l == r)
return c[st][n];
else {
if (hc[st][n]) {
c[st][2 * n] = max(c[st][2 * n], c[st][n]);
c[st][2 * 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;
vector<string> split(const string& s, char c) {
vector<string> v;
stringstream ss(s);
string x;
while (getline(ss, x, c)) v.emplace_back(x);
return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>:... | 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<pair<int, int>> S;
map<pair<int, int>, pair<int, int>> M;
set<int> bio;
int main(void) {
int n, q;
scanf("%d %d", &n, &q);
S.insert({0, n - 1});
M[{0, n - 1}] = {-1, -1};
for (int i = (0); i < (q); ++i) {
int x, y;
char d[11];
scanf("%d %d %s", &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;
int n, q;
set<pair<int, pair<int, int> > > s;
set<pair<int, pair<int, int> > >::iterator t;
map<int, bool> c, r;
string S;
int main() {
cin >> n >> q;
s.insert(make_pair(0, make_pair(0, 1)));
s.insert(make_pair(n + 1, make_pair(0, 0)));
for (int x, y, ans, k, a, 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;
using LL = long long;
using pii = pair<LL, LL>;
const LL INF = 9223372036854775807LL;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, q;
cin >> n >> q;
map<int, pii> fields;
fields[0] = make_pair(0, n);
fields[n] = make_pair(-1, -1);
map... | 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 c {
public static void main(String[] args) throws IOException
{
input.init(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = input.nextInt(), m = input.nextInt();
int[] rs = new int[m], cs = new int[m];
char[] types = new char[m];
TreeSet<I... | 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, char> direction;
map<int, int> answer;
map<int, int> row;
int main() {
scanf("%d%d", &n, &q);
long long ret = 0;
int x, y;
char dir[3];
set<int> event;
for (int i = 0; i < q; i++) {
scanf("%d%d%s", &y, &x, dir);
if (direction.find(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>
#pragma comment(linker, "/STACK:134217728")
using namespace std;
int n, m;
struct R {
int x1, y1, x2, y2;
R() {}
R(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};
bool operator<(const R& a, const R& b) {
return max(a.x1, a.y1) < max(b.x1, b.y1);
}
char buf[2];
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;
set<pair<int, int> > con;
set<pair<int, int> >::iterator it;
int n, m;
char s[50];
int x[200007], y[200007];
int main() {
while (~scanf("%d%d", &n, &m)) {
con.clear();
x[0] = y[0] = 0;
x[m + 1] = y[m + 1] = 0;
con.insert(make_pair(0, m + 1));
con.inser... | 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.StringTokenizer;
import java.util.TreeSet;
public class T310E {
public static void main(String[] args) throws IOExceptio... | 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 N = 800010;
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;
const int maxn = 2e5 + 5;
map<int, pair<char, int> > m;
int main() {
long long n, q;
scanf("%lld%lld", &n, &q);
m[0] = make_pair('U', 0);
m[n + 1] = make_pair('L', 0);
while (q--) {
long long x, y;
string s;
scanf("%lld%lld", &x, &y);
cin >> 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;
const int maxn = 200010;
int X[maxn];
int N, M;
struct node {
int x, y;
char d[5];
} op[maxn];
bool vis[maxn];
struct IntervalTree {
int up[maxn << 2];
int down[maxn << 2];
int set1[maxn << 2];
int set2[maxn << 2];
void build(int o, int l, int r) {
up[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;
struct Comp {
long long left, right, leftBorder, upBorder;
bool isLeftVertical, isRightVertical;
};
class Solution {
public:
void solve(std::istream& in, std::ostream& out) {
long long n;
int q;
in >> n >> q;
map<int, Comp> components;
set<int> ea... | 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 IINF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const double EPS = 1e-8;
const int DX[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int DY[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int N = 1 << 18;
clas... | 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.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
public class Main
{
public static... | 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;
using pii = pair<int, int>;
int n, q;
set<pii> sv[2];
set<int> X, Y;
int main() {
ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
cin >> n >> q;
int x, y;
char c;
while (q--) {
int res;
cin >> x >> y >> c;
if (c == 'U') {
if (X.count(... | 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 = 200010;
vector<int> x, y;
map<int, int> mx, my;
int pass[maxn];
int seg[2][4 * maxn];
int lazy[2][4 * maxn];
void refresh(int t, int idx, int st, int ed) {
int l = 2 * idx, r = l + 1;
if (lazy[t][idx] == 0) return;
seg[t][idx] = max(seg[t][idx], 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;
int n, nrq, ny, nx, aix[8 * 200005], aiy[8 * 200005], ixx[200005], iyy[200005];
set<int> yu, xl, copies;
set<int>::iterator it;
map<int, int> xx, yy;
pair<pair<int, int>, char> q[200005];
void build_ai(int ai[], int node, int l, int r) {
ai[node] = 2000000000;
if (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;
void read(bool out = 0) {}
int seg[2][8 * 500009] = {};
int from, to;
void insert(int x, int y, int value, int type = 0, int second = from,
int e = to, int p = 1) {
if (x <= second && y >= e) {
seg[type][p] = max(seg[type][p], value);
return;
}
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 {
int S;
vector<int> arr;
seg_tree(int _S) {
S = _S;
arr = vector<int>(2 * S, INF);
}
void upd(int i, int v)... | 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.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
*/
public cl... | 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.*;
import java.io.*;
import java.math.*;
public class Main {
static BufferedReader in;
static StringTokenizer stk;
static boolean[] isPrime = new boolean[5000];
public static void main(String[] args) throws Exception {
in = new BufferedReader(new InputStreamReader(System.in)... | 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 N = 300010;
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;
template <class T>
bool umin(T& a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T>
bool umax(T& a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
map<long long, long long> mk;
long long a, uy, b, c, n, m, T[2][100007 * 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;
const int N = 2e5 + 100;
struct T {
int node[N << 2], lazy[N << 2];
void up(int pos, int value) {
node[pos] = max(node[pos], value);
lazy[pos] = max(lazy[pos], value);
}
void push_down(int pos) {
up(pos << 1, lazy[pos]);
up(pos << 1 | 1, lazy[pos]);
... | 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<pair<int, int>, pair<int, int> > mp;
map<pair<int, int>, int> done;
map<int, int> up, leftMap;
int main() {
int N, Q;
int r, c;
char dir;
scanf("%d%d", &N, &Q);
up[0] = leftMap[0] = 1;
mp[pair<int, int>(1, N)] = pair<int, int>(0, 0);
map<pair<int, int>, 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 MAXN = 2 * 2 * 200010;
int tree[2][4 * MAXN];
int lazy[2][4 * MAXN];
int coords[MAXN];
int X[MAXN], Y[MAXN];
char OP[MAXN];
void go(int idx, int l, int r, int tree[], int lazy[]) {
if (lazy[idx] != 0) {
tree[idx] = max(tree[idx], lazy[idx]);
if (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;
int n, q, x, y;
int inf = int(2e9);
char c;
map<pair<int, int>, pair<int, int> > M;
map<pair<int, int>, pair<int, int> >::iterator it;
int main() {
ios_base::sync_with_stdio(false);
cin >> n >> q;
M[make_pair(0, n - 1)] = make_pair(n, n);
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, m, ans;
struct node {
int l, r, x, y;
};
bool operator<(node p, node q) {
return (p.l == q.l) ? (p.r < q.r) : (p.l < q.l);
}
set<node> S;
int main() {
scanf("%d%d", &n, &m);
S.insert((node){0, 0, 1, 1});
S.insert((node){1, n, 1, 1});
for (int i = 1; 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.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 Block {
int l, r, h, w;
Block() : l(), r(), h(), w() {}
Block(int L, int R, int H, int W) : l(L), r(R), h(H), w(W) {}
bool operator<(const Block &p) const { return r <= p.r; }
};
set<Block> skup;
int n, q;
int row, col;
char c[2];
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 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.SortedMap;
import java.util.TreeMap;
public class P556E {
private final long n;
private final SortedMap<Long, Long> map = new TreeMap<>();
public P556E(long n) {
this.n = n;
map.p... | 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 Segment_Tree {
struct tree {
int l, r, tag, v;
} t[200005 << 3];
void Down_date(int k) {
if (t[k].tag == 0) return;
if (t[k].l != t[k].r) {
t[(k << 1)].tag = max(t[(k << 1)].tag, t[k].tag);
t[(k << 1 | 1)].tag = max(t[(k << 1 | 1)].tag, ... | 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 | import java.io.*;
import java.util.*;
public class CF {
FastScanner in;
PrintWriter out;
class Segment implements Comparable<Segment> {
int from, to, value;
public Segment(int from, int to, int value) {
super();
this.from = from;
this.to = to;
this.value = value;
}
@Override
public int comp... | 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> > up, ho;
set<pair<int, int> >::iterator it;
int main(void) {
ios::sync_with_stdio(false), cin.tie(0);
int n, m;
cin >> n >> m;
for (int i = 0; i < m; ++i) {
int x, y;
char op;
cin >> y >> x >> op;
if (op == 'U') {
it = up.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 | import java.io.*;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class Main {
static final int INF = (int) 1e9;
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(Syst... | 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 = 2e5 + 7;
int n, q;
map<int, pair<char, int> > mp;
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> n >> q;
mp[0] = make_pair('U', 0), mp[n + 1] = make_pair('L', 0);
for (int i = 0, x, y; i < q; i++) {
char c;
cin >> ... | 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;
const int MOD = 1000000007;
const int TN = 400109;
struct tree {
int mx[TN * 4 + 1];
void upd(int v, int l, int r, int from, int to, int nv) {
if (from > to || from > r || l > to) return;
if (l == from && r == to) {
mx[v] = max(... | 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<int, int> > u, l;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
u[0] = {0, 0};
l[0] = {0, 0};
int n, q, x, y, ans, buf;
pair<int, int> p, p1;
char c;
cin >> n >> q;
while (q--) {
cin >> x >> y >> c;
ans = 0;
if (c == 'U')... | 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 | 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;
/**
* Built using CHelper plug-in
* Actual solution is ... | 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 = 0x3fffffff;
struct Data {
int r, cnt;
bool w;
};
struct Node {
Data dat;
int pri;
Node *ls, *rs;
} * rt;
void zig(Node *&p) {
Node *tmp = p->rs;
p->rs = tmp->ls;
tmp->ls = p;
p = tmp;
}
void zag(Node *&p) {
Node *tmp = p->ls;
p->ls = tm... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.