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 |
|---|---|---|---|---|---|
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct Node {
int l, r, m;
Node(int ip = 0, int is = 0, int im = 0) { l = ip, r = is, m = im; }
};
Node tr[1200005];
long long int a[300005];
int arr[300005];
void combine(int v, int l, int r) {
int v1 = 2 * v;
int v2 = v1 + 1;
int m = (l + r) / 2;
int s1 = m - ... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 3e5;
int A[N], n;
struct Node {
int L, R, ans, l, r, pl, pr;
long long num1, num2;
Node() { ans = -1; }
Node(int a) {
L = R = l = r = pl = pr = a;
ans = 1;
num1 = A[a];
num2 = A[a];
}
} T[4 * N];
long long flag[4 * N];
long long num1,... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 500000;
long long t[N * 4], tr[N * 4], tl[N * 4];
long long a[N], d[N];
inline long long zn(long long x) {
if (x < 0) return -1;
if (x == 0) return 0;
return 1;
}
void add(int v, int l, int r, int i, long long delt) {
if (l == r) {
d[i] += delt;
... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long inp[300009];
long long arr[300009];
struct node {
int si, ei;
int lf, md, rg;
node(int sii, int eii, int lff = 0, int mdd = 0, int rgg = 0) {
si = sii;
ei = eii;
lf = lff, rg = rgg, md = mdd;
}
node() { si = ei = lf = md = rg = 0; }
};
struct... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
void sync_stdio() {
cin.tie(NULL);
ios_base::sync_with_stdio(false);
}
struct Sync_stdio {
Sync_stdio() {
cin.tie(NULL);
ios_base::sync_with_stdio(false);
}
} _sync_stdio;
struct FAIL {
FAIL() {
cout << "CHANGE!!!"
... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, m, a[300010], l, r, addv;
long long del[300010];
int lx[300010 << 2], rx[300010 << 2], ans[300010 << 2];
bool con(long long x, long long y) {
if (!x || !y) return false;
if (x > 0) return true;
if (x < 0 && y < 0) return true;
return false;
}
void push_up(int... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long a[300010];
struct Node {
Node *lch, *rch;
long long add, lazy, lv, rv;
int rhill, lhill, rdec, ldec, maxhill;
Node() {
lch = rch = nullptr;
lv = rv = maxhill = rhill = lhill = rdec = ldec = add = lazy = 0;
}
inline void up(int l, int r) {
i... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long a[300005];
int sign(long long x) { return x > 0 ? 1 : -1; }
struct Node {
int l, r, lx, mx, rx;
void up(Node L, Node R) {
lx = L.lx;
rx = R.rx;
mx = max(L.mx, R.mx);
if (a[L.r] && a[R.l] && sign(a[L.r]) >= sign(a[R.l])) {
mx = max(mx, L.r... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int arr[maxn];
long long a[maxn];
int n, m;
int max_suf[4 * maxn], max_pre[4 * maxn], max_wid[4 * maxn];
int sign(long long x) { return x < 0 ? -1 : 1; }
int S(int i, int j) { return j - i + 1; }
int p;
int upd_wid(int o, int L, int R) {
int M =... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
inline void umax(int& m, int u) { u > m && (m = u); }
inline int max(int a, int b) { return a > b ? a : b; }
struct seg {
long long l, r, tag;
int ans, len, l0, l1, l2, r0, r1, r2;
void add(long long), init(int);
} s[1048576];
seg operator+(const seg& a, const seg& b) {
seg c;
c.len =... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
#pragma comment(linker, "/stack:20000000")
using namespace std;
template <class T>
int sign(T x) {
return x > 0 ? 1 : x < 0 ? -1 : 0;
}
struct Node {
int lval, mval, rval;
};
Node tr[2340400];
long long a[1010101];
inline void recalc(int cur, int l, int r) {
int m = (l + r) / 2;
int dcu... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 2;
int n, q, l, r, ar[N], x;
struct st {
long long pr, sf, prr, sff, mx, must, sl, pl, l;
st() { l = pr = sf = prr = sff = mx = must = sl = pl = 0; }
};
st t[N * 4];
inline st combine(st a, st b) {
st c;
c.pr = a.pr;
c.sf = b.sf;
if (a.l == 1... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct Node {
int pref, suf, pref_neg, suf_pos, ans, cant;
Node() {}
void init(long long v) {
if (v < 0) {
pref = 0;
suf = 0;
pref_neg = 1;
suf_pos = 0;
ans = 1;
cant = 1;
} else if (v > 0) {
pref = 0;
suf = 0;
... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> ll;
typedef vector<long long> vl;
typedef vector<ll> vll;
typedef vector<vl> vvl;
template <typename T>
ostream &operator<<(ostream &o, vector<T> v) {
if (v.size() > 0) o << v[0];
for (unsigned i = 1; i < v.size(); i++) o << " " << v[i... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct Tree {
int lx, mx, rx;
} tree[3000050];
long long a[300050];
int F(long long x) { return x > 0 ? 1 : -1; }
void Update(int root, int nowl, int nowr, int askl, int askr) {
int mid = (nowl + nowr) / 2;
if (nowr < askl || askr < nowl) return;
if (askl <= nowl &&... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MaxN = 300005;
int N, A[MaxN];
struct ST {
long long C[MaxN];
inline int lowbit(int x) { return x & (-x); }
inline void add(int x, long long d) {
for (; x <= N; x += lowbit(x)) C[x] += d;
}
inline void init() { memset(C, 0, sizeof(C)); }
inline voi... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* @author Don Li
*/
public class AlyonaTowers {
int N = Integer.highestOneBit((int) 3e5) << 2;
int n;
long[] b;
Node[] node = new No... | JAVA |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int a[maxn];
struct SegmentTree {
struct Node {
int Left, Both, Right;
} st[6 * maxn];
int L[6 * maxn], R[6 * maxn];
long long V[maxn];
void Build(int k, int x, int y) {
L[k] = x;
R[k] = y;
if (L[k] == R[k]) return;
B... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct treenode {
int max, L, R;
};
treenode tree[2000000];
long long g[500000];
int i, m, n, x, y, z;
inline void inserttree(int l, int r, int x, int node) {
if (l == r) {
if (g[l] < 0) tree[node] = (treenode){1, 1, 1};
if (g[l] > 0) tree[node] = (treenode){1, ... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const long long MXLL = 4611686018427387903;
const int Sz = 1110111;
using namespace std;
inline void Read_rap() {
ios_base ::sync_with_stdio(0);
cin.tie(0);
}
struct node {
int l, m, r;
} t[Sz];
int n;
long long a[Sz];
inline int si... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, m, a[300010], l, r, addv;
long long del[300010];
int lx[300010 << 2], rx[300010 << 2], ans[300010 << 2];
bool con(long long x, long long y) {
if (!x || !y) return false;
if (x > 0) return true;
if (x < 0 && y < 0) return true;
return false;
}
void push_up(int... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
char In[1 << 25], *ss = In, *tt = In;
inline long long read() {
register long long x = 0, f = 1;
register char ch =
(ss == tt && (tt = (ss = In) + fread(In, 1, 1 << 25, stdin), ss == tt)
? EOF
: *ss++);
while (ch < '0' || ch > '9')
f = ... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
void sync_stdio() {
cin.tie(NULL);
ios_base::sync_with_stdio(false);
}
struct Sync_stdio {
Sync_stdio() {
cin.tie(NULL);
ios_base::sync_with_stdio(false);
}
} _sync_stdio;
struct FAIL {
FAIL() {
cout << "CHANGE!!!"
... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline long long getnum() {
char c = getchar();
long long num, sign = 1;
for (; c < '0' || c > '9'; c = getchar())
if (c == '-') sign = -1;
for (num = 0; c >= '0' && c <= '9';) {
c -= '0';
num = num * 10 + c;
c = getchar();
}
return num * sign;
}... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct node {
int l, m, r;
};
node t[3000005];
int arr[300005], n, m;
long long a[300005];
int sign(long long x) {
if (x > 0) return 1;
if (x < 0) return -1;
return 0;
}
void cal(int x, int l, int r) {
int m = (l + r) / 2;
t[x].m = max(t[x * 2].m, t[x * 2 + 1].m... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct node {
int lb, rb, l_max, r_max, s_max;
};
int n, m, l, r, k, offset = 1 << 19, a[300004];
long long d[600004];
node trn[1100000];
int sgn(long long x) {
if (x > 0) return 1;
if (x < 0) return -1;
return 0;
}
void update(int pos) {
if (pos < 0) return;
if... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 300010;
const int INF = 0x3f3f3f3f;
void MOD(long long &a) {
if (a >= mod) a -= mod;
}
void MOD(long long &a, long long c) {
if (a >= c) a -= c;
}
void ADD(long long &a, long long b) {
a += b;
MOD(a);
}
void ADD(long long &a... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct treeLen {
int n;
vector<int> abest;
vector<int> al;
vector<int> ar;
treeLen() { n = 0; }
treeLen(vector<int> vec) {
n = 1;
while (n < vec.size()) {
n *= 2;
}
abest.resize(2 * n);
al.resize(2 * n);
ar.resize(2 * n);
for (i... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | import java.io.*;
import java.util.*;
public class CF740E {
static Random rand = new Random();
static class Skip<K,V> {
Comparator<K> comp;
static class Node<K,V> {
K k;
V v;
Node<K,V>[] next;
Node(int r, K k, V v) {
next = new Node[r]; // unchecked
this.k = k;
this.v = v;
}
}
Node... | JAVA |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
class Range {
public:
int l_inc, l_dec, r_inc, r_dec;
long long l, r;
int len_hill;
int l_hill, r_hill;
int len;
Range(){};
Range(int x)
: l_inc(1),
l_dec(1),
r_inc(1),
r_dec(1),
l(x),
r(x),
len_hill(1),
... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | import java.io.*;
import java.util.*;
public class CF740E {
static Random rand = new Random();
static class Skip<K,E> {
static class Entry<K,E> {
K k;
E e;
Entry(K k, E e) {
this.k = k;
this.e = e;
}
}
static class Item<K,E> {
Item<K,E> north, south, west, east;
Entry<K,E> ent;
};
... | JAVA |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | import java.io.*;
import java.util.*;
public class CF740E {
static Random rand = new Random();
static class Skip<K,V> {
Comparator<K> comp;
static class Node<K,V> {
K k;
V v;
Node<K,V>[] next;
Node(int r, K k, V v) {
next = new Node[r]; // unchecked
this.k = k;
this.v = v;
}
}
Node... | JAVA |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct data {
int ldown, rdown;
long long l, r;
int lhiint, rhiint;
int best, siz;
};
data merge(data a, data b) {
data ret;
ret.best = max(a.best, b.best);
ret.l = a.l, ret.r = b.r;
ret.siz = a.siz + b.siz;
ret.ldown = a.ldown, ret.rdown = b.rdown;
ret.... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n;
int arr[1001000];
long long a[1000100];
struct node {
int lhill, maxval, rhill;
} tree[6 * 500000];
int sig(long long x) { return x > 0 ? 1 : x < 0 ? -1 : 0; }
void calc(int cur, int l, int r) {
int m = (l + r) / 2;
int dc = cur * 2;
tree[cur].maxval = max(tr... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
int n, m, l, r;
long long a[maxn], d[maxn], v;
struct s {
int l, r, mm, lm, rm;
inline void get(int t) { mm = lm = rm = t; }
} seg[maxn << 2];
inline int sign(long long v) { return !v ? 0 : v > 0 ? 1 : -1; }
void pushup(int x) {
int l = seg[x]... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const long long MXLL = 4611686018427387903;
const int Sz = 1110111;
using namespace std;
inline void Read_rap() {
ios_base ::sync_with_stdio(0);
cin.tie(0);
}
struct node {
int l, m, r;
} t[Sz];
int n;
long long a[Sz];
inline int si... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | import java.io.*;
import java.util.*;
public class CF740E {
static Random rand = new Random();
static class Skip<K,V> {
Comparator<K> comp;
static class Node<K,V> {
K k;
V v;
Node<K,V>[] next;
Node(int r, K k, V v) {
next = new Node[r]; // unchecked
this.k = k;
this.v = v;
}
}
Node... | JAVA |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MAX = (int)3e5 + 10;
struct Node {
long long vl, vr;
int len;
int seg_l, seg_r;
int value_l, value_r, value;
bool cd_l, cd_r;
long long D;
bool emp;
};
int n;
int a[MAX];
Node T[2 * MAX];
int h;
void init() {
cin >> n;
for (int i = 1; i <= n; i++... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 300001;
struct segment {
long long tree[4 * N], lazy[4 * N];
int n;
void resize(int _n) { n = _n; }
void shift(int l, int r, int node) {
if (!lazy[node]) return;
tree[node] += (long long)(r - l + 1) * lazy[node];
if (l != r) {
lazy[no... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MX = 300005;
struct BIT {
long long ft[MX];
void init() { memset(ft, 0, sizeof(ft)); }
void update(int i, long long k) {
while (i < MX) {
ft[i] += k;
i += i & -i;
}
}
void update(int a, int b, long long k) {
update(a, k);
upda... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long n, m, ans, a[2000010], a0[2000010];
struct Node {
long long MaxL, MaxR, Max;
};
Node tree[2000010];
long long Sign(long long x) {
if (x > 0) {
return 1;
}
if (x == 0) {
return 0;
}
return -1;
}
void Merge(long long idx, long long l, long long r... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | import java.io.*;
import java.util.*;
public class CF740E {
static long[] aa;
static class H implements Comparable<H> {
int i, j, k; // [i, j) up [j, k) down
H(int i, int j, int k) {
this.i = i;
this.j = j;
this.k = k;
}
@Override public int compareTo(H h) {
return k - i != h.k - h.i ? (k - i) - ... | JAVA |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
int n, m, l, r;
long long v, a[maxn], d[maxn];
struct s {
int l, r, lm, mm, rm;
void get(int t) { lm = rm = mm = t; }
} seg[maxn << 2];
inline int sign(long long x) { return !x ? 0 : x > 0 ? 1 : -1; }
void pushup(int x) {
int l = seg[x].l, r =... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
const int MaxN = 300000;
using namespace std;
long long arr[MaxN + 5], a[MaxN + 5], n;
struct Segment {
int l, r, lx, mx, rx;
int Sign(long long x) { return x > 0 ? 1 : -1; }
void Update(Segment A, Segment B) {
lx = A.lx, rx = B.rx;
mx = max(A.mx, B.mx);
if (a[A.r] && a[B.l] &... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 300300;
struct Node {
int l, r, l_line, r_line, maxn;
long long lv, rv;
} node[MAXN << 2];
int a[MAXN];
void push_up(int rt) {
int lson = rt << 1, rson = rt << 1 | 1;
node[rt].maxn = node[lson].maxn;
node[rt].maxn = max(node[rt].maxn, node[rson].m... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
/*
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
... | JAVA |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 1 << 19;
struct Node {
int l, r;
long long val;
int lPos, lNeg, rPos, rNeg, inAns, lAns, rAns;
Node()
: l(-1),
r(-1),
val(),
lPos(),
lNeg(),
rPos(),
rNeg(),
inAns(),
lAns(),
... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct Node {
int pref, suf, pref_neg, suf_pos, ans, cant;
Node() {}
void init(long long v) {
if (v < 0) {
pref = 0;
suf = 0;
pref_neg = 1;
suf_pos = 0;
ans = 1;
cant = 1;
} else if (v > 0) {
pref = 0;
suf = 0;
... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 Γ 1 Γ 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline int readInt() {
static int n, ch;
n = 0, ch = getchar();
while (!isdigit(ch)) ch = getchar();
while (isdigit(ch)) n = n * 10 + ch - '0', ch = getchar();
return n;
}
const int MAX_N = 300000 + 3;
int n, m, a[MAX_N];
namespace segment_tree {
const int MAX_NOD... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at ... | JAVA |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
printf("YES\n");
for (int i = 0; i < n; i++) {
int arr[4];
for (int j = 0; j < 4; j++) {
scanf("%d", &arr[j]);
}
int x = arr[0] % 2;
if (x < 0) x = 1;
int y = arr[1] % 2;
if (y < 0) y = 1;
pr... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n, i, x, y, a, b;
int main() {
cout << "YES\n";
cin >> n;
for (i = 1; i <= n; i++) {
cin >> x >> y >> a >> b;
if (x % 2 == 0 and y % 2 == 0)
cout << "1\n";
else if (x % 2 == 0 and (y % 2 == 1 or y % 2 == -1))
cout << "2\n";
else if ((x ... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n;
int main() {
cin >> n;
cout << "YES\n";
int a, b, c;
while (n--) {
cin >> a >> b >> c >> c;
cout << (2 * (a & 1) + (b & 1) + 1) << "\n";
}
}
| CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long n;
void solve() {
cin >> n;
long long x, y, a, b;
cout << "YES\n";
for (long long i = 1; i <= (n); ++i) {
cin >> x >> y >> a >> b;
cout << 2 * (x & 1) + (y & 1) + 1;
cout << '\n';
}
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | '''plan
noticed that if both upperle
'''
from sys import stdin, stdout
# n = int(stdin.readline().rstrip())
# n = int(input())
all_lines = stdin.read().split('\n')
stdout.write('YES\n')
for line in all_lines[1:-1]:
x1, y1, x2, y2 = (int(x) % 2 for x in line.split())
num = 2 * x2 + y2 + 1
# stdout.write... | PYTHON3 |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
int i;
int x1, y1, x2, y2;
int x;
printf("YES\n");
for (i = 1; i <= n; i++) {
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
if (x1 % 2 == 0) {
if (y1 % 2 == 0)
x = 1;
else
x = 2;
} else {
... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
if (!b) return a;
return gcd(b, a % b);
}
int main() {
int n;
printf("YES\n");
scanf("%d", &n);
for (int i = 0; i < n; i++) {
int x1, y1, x2, y2;
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
printf("%d\n", ((4 + 2 * ... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, x1, x2, y1, y2;
scanf("%d", &n);
puts("YES");
for (int i = 0; i < n; i++) {
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
printf("%d\n", (((x1 & 1) << 1) + (y1 & 1) + 1));
}
}
| CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
int n;
cin >> n;
cout << "YES" << endl;
for (int x1, x2, y1, y2, i = 0; i < n; i++) {
cin >> x1 >> y1 >> x2 >> y2;
int x = min(x1, x2);
int y = min(y1, y2);
cout << 1 + abs(x) % 2 + 2 * (abs(y) % 2) <<... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int N = 1000000 + 100;
struct node {
int x1, y1, x2, y2;
} a[N];
int main() {
int n;
while (scanf("%d", &n) != EOF) {
cout << "YES" << endl;
for (int i = 1; i <= n... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long arr[1000009];
long long brr[1000009];
long long idx[1000009];
long long st[1000009];
int main() {
long long n;
cin >> n;
cout << "YES\n";
while (n--) {
int x1, x2, y1, y2;
cin >> x1 >> y1 >> x2 >> y2;
cout << 2 * (abs(x1) % 2) + (abs(y1) % 2) +... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i, a, b, x, y, ans = 0;
scanf("%d", &n);
printf("YES\n");
for (int i = 1; i <= n; i++) {
scanf("%d %d %d %d", &a, &b, &x, &y);
x = min(a, x);
y = min(y, b);
ans = abs(x) % 2;
ans = ans * 2 + (abs(y) % 2);
printf("%d\n", an... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int x1, y1, x2, y2;
int x;
cout << "YES" << endl;
for (int i = 0; i < n; i++) {
cin >> x1 >> y1 >> x2 >> y2;
if (x1 % 2 == 0) {
if (y1 % 2 == 0)
x = 1;
else
x = 2;
} else {
if (y1 % 2 ==... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Template implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
void init() throws FileNotFoundException {
try {
in = new BufferedReader(new FileReader... | JAVA |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
typedef struct Rect {
int x1, y1, x2, y2;
} Rect;
class TaskD {
private:
inline bool overlap(const Rect& A, const Rect& B) {
return (A.x1 <= B.x2 && A.x2 >= B.x1 && A.y1 < B.y2 && A.y2 > B.y1) ||
(A.x1 < B.x2 && A.x2 > B.x1 && A.y1 <= B.y2 && A.y2 >= B.y... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
int i, n;
cin >> n;
vector<int> A(n);
for (i = 0; i < n; ++i) {
int x1, x2, y1, y2;
cin >> x1 >> y1 >> x2 >> y2;
int X = abs(x1), Y = abs(y1);
A[i] = 2 * (X % 2) + Y % 2 + 1;
}
cout << "YES" << endl;
for (i = 0; i < n; ++i) cout <<... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
void RI() {}
template <... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int n;
cin >> n;
puts("YES");
for (int i = 1; i <= n; i++) {
int a, b, c, d;
cin >> a >> b >> c >> d;
c = abs(c);
d = abs(d);
printf("%d\n", 1 + d % 2 + 2 * (c % 2));
}
return 0;
}
| CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, x1, y1, x2, y2;
cout << "YES" << endl;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x1 >> y1 >> x2 >> y2;
if ((x1 % 2 + 2) % 2 == 0 && (y1 % 2 + 2) % 2 == 0) {
cout << "1" << endl;
} else if ((x1 % 2 + 2) % 2 == 0 && (y1... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e6 + 5;
const long long inf = 1e10;
const long long mod = 1e9 + 7;
long long n;
long long x[maxN], y[maxN], a, b;
int main() {
ios_base::sync_with_stdio(0);
cin >> n;
for (long long i = 1; i <= n; i++) {
cin >> x[i] >> y[i] >> a >> b;
}
... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | n = int(input())
print("YES")
for i in range(n):
x1, y1, x2, y2 = input().split()
x1 = int(x1)
y1 = int(y1)
print((x1 % 2) * 2 + (y1 % 2) + 1) | PYTHON3 |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n, x, y, k;
int main() {
cin >> n;
cout << "YES\n";
for (int i = 1; i <= n; ++i) {
cin >> x >> y;
x += 1e9;
y += 1e9;
if (x % 2 == 0 && y % 2 == 0)
cout << 1 << "\n";
else if (x % 2 == 0 && y % 2 == 1)
cout << 2 << "\n";
if (x %... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
void RI() {}
template <typename... T>
void RI(int& head, T&... tail) {
scanf("%d", &head);
RI(tail...);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
RI(n);
cout << "YES" << endl;
while (n--) {
int x1, y1, x2, y2;
RI(x1, y1, x2, y2);
... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
int n, col[500005];
int main() {
scanf("%d", &n);
for (int a, b, c, d, i = 1; i <= n; i++) {
scanf("%d %d %d %d", &a, &b, &c, &d);
if (a < 0) a = -a;
if (b < 0) b = -b;
if (c < 0) c = -c;
if (d < 0) d = -d;
int p = (a & 1);
int q = (b & 1);
p = p * 2 + q;
... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 1;
void solve() {
puts("YES");
int n;
scanf("%d", &n);
int x1, y1, x2, y2;
for (int i = 1; i <= n; i++) {
scanf("%d", &x1);
scanf("%d", &y1);
scanf("%d", &x2);
scanf("%d", &y2);
printf("%d\n", (2 * (abs(x1) % 2) + (abs(y1... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, i, x1, x2, y1, y2;
scanf("%lld", &n);
printf("YES\n");
while (n--) {
scanf("%lld%lld", &x1, &y1);
scanf("%lld%lld", &x2, &y2);
if (x1 < 0) x1 = -(x1);
if (y1 < 0) y1 = -(y1);
if (x1 % 2 == 0 && y1 % 2 == 0)
pri... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
printf("YES\n");
int n, a, b, c, d;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d%d%d%d", &a, &b, &c, &d);
if (!(a % 2) && !(b % 2))
printf("3\n");
else if (!(a % 2) && (b % 2))
printf("4\n");
else if ((a % 2) && ... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class C {
static ArrayList<Integer> [] adj;
public static void main(String[] ... | JAVA |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 500005;
int ans[MAXN];
int main() {
ios_base::sync_with_stdio(false);
long long n, x1, y1, x2, y2;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x1 >> y1 >> x2 >> y2;
x1 += (long long)(1e9);
y1 += (long long)(1e9);
ans[i] = ((x1 & 1... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, x1, y1, x2, y2;
scanf("%d", &n);
puts("YES");
for (int i = 0; i < n; i++) {
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
x1 %= 2, y1 %= 2;
if (x1 && y1) puts("1");
if (x1 && !y1) puts("2");
if (!x1 && y1) puts("3");
if (!x1 && !... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
int n;
cin >> n;
cout << "YES"
<< "\n";
for (int i = 1; i <= n; i++) {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
cout << (12 + 2 * (x1 % 2) + (y1 % 2)) % 4 + 1 << "\n";
}
return 0;
}
| CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n, x, y;
int main() {
cin >> n;
cout << "YES\n";
for (int i = 1; i <= n; i++) {
cin >> x >> y >> x >> y;
x += (int)(1e9 + 7);
y += (int)(1e9 + 7);
cout << 1 + x % 2 + 2 * (y % 2) << endl;
}
return 0;
}
| CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int x[N], y[N];
int main() {
int n, a, b;
while (scanf("%d", &n) != EOF) {
for (int i = 1; i <= n; ++i) scanf("%d %d %d %d", &x[i], &y[i], &a, &b);
puts("YES");
for (int i = 1; i <= n; ++i) {
if (x[i] & 1 && y[i] & 1)
put... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long binpow(long long a, long long m) {
long long product = 1;
long long mult = a;
while (m > 0) {
if (m % 2 == 1) {
product = (product % 1000000007 * mult % 1000000007) % 1000000007;
}
m = m / 2;
mult = (mult % 1000000007 * mult % 100000000... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
public static void solve(FastIO io) {
int N = io.nextInt();
io.println("YES");
for (int i = 0; i < N; ++i) {
int X = io.nextInt();
int Y = io.nextInt();
io.nextIntArray(2);
io.println(1 + (((X & 1) << 1) | (Y & 1)));
}... | JAVA |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | '''plan
noticed that if both upperle
'''
from sys import stdin, stdout
# n = int(stdin.readline().rstrip())
# n = int(input())
all_lines = stdin.read().split('\n')
stdout.write('YES\n')
for line in all_lines[1:-1]:
x1, y1, x2, y2 = (int(x) % 2 for x in line.split())
num = 2 * x2 + y2 + 1
# stdout.write... | PYTHON3 |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;
/**
* @author khokharnikunj8
*/
public class Main {
public static void main(String[] args) {
... | JAVA |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int i, x, y, j, n, k, m, t, f, l, r;
cin >> n;
cout << "YES" << endl;
for (l = (1); l <= (n); l++) {
cin >> x >> y >> i >> j;
if ((x & 1) && (y & 1))
... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int ans[500010] = {};
int n;
int a, b, c, d;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d%d%d%d", &a, &b, &c, &d);
a = abs(a);
b = abs(b);
if (a % 2 == 0 && b % 2 == 0) {
ans[i] = 1;
}
if (a % 2 == 0 && b % 2 == 1)... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
namespace INPUT {
const int L = 1 << 15;
char _buf[L], *S, *T, c;
char _gc() {
if (S == T) {
T = (S = _buf) + fread(_buf, 1, L, stdin);
if (S == T) return EOF;
}
return *S++;
}
void readi(int &X) {
for (c = _gc(); c < '0' || c > '9'; c = _gc())
;
X = c... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | import java.math.*;
import java.util.*;
public class itachi {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int maxn = 100005;
int n = in.nextInt();
System.out.println("YES");
for (int i = 1; i <= n; i++){
int x1 = in.nextInt(), y1 = in.nextInt(), x2 = in.nextInt(), y2 =... | JAVA |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | n = int (input())
print ('YES')
for i in range (0, n):
a, b, c, d = [int(x) for x in (input().split())]
print (1 + a%2 + (b%2) * 2) | PYTHON3 |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | from sys import stdin
t = int(stdin.readline())
print 'YES'
for _ in xrange(t):
x1,y1,x2,y2 = map(int,stdin.readline().split())
x = abs(min(x1,x2))
y = abs(min(y1,y2))
print 1 + 2*(x&1) + (y&1) | PYTHON |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitS... | JAVA |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7, mod = 1e9 + 7, inf = 1e5 + 7;
const long long linf = (long long)1e18 + 7;
const long double eps = 1e-15, pi = 3.141592;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1},
dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
int t;
inline int get(int x, int y) {
... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
return a < b ? (a = b, true) : false;
}
int main() {
int n;
printf("YES\n");
scanf("%d", &n);
for (int i = 0; i < n; i++) {
int x1, y1, ... | CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | p = int(input())
print("YES")
for i in range(p):
a, b, c, d = [abs(int(i)) for i in input().split()]
if a % 2 == 0:
print("1" if b % 2 == 0 else "2")
else:
print("3" if b % 2 == 0 else "4") | PYTHON3 |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, y, x1, y1;
cin >> n;
cout << "YES" << endl;
while (n--) {
cin >> x >> y >> x1 >> y1;
cout << (x & 1 ? 0 : 1) + (y & 1 ? 0 : 2) + 1 << endl;
}
}
| CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
cout << "YES" << endl;
for (int i = 0; i < n; i++) {
int x, y, xx, yy;
cin >> x >> y >> xx >> yy;
cout << (x & 1) + 2 * (y & 1) + 1 << endl;
}
}
| CPP |
764_D. Timofey and rectangles | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 different... | 2 | 10 | function main() {
var all = [[2,1], [3,4]]
var n = Number(readline());
print("YES");
for(var i=0;i<n;i++){
var line = readline().split(' ').map(Number);
var x = Math.abs(line[0]);
var y = Math.abs(line[1]);
print(all[x%2][y%2]);
}
}
main() | JAVA |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.