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 |
|---|---|---|---|---|---|
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long powMod(long long x, long long k) {
if (k == 0) return 1;
if (k % 2 == 0)
return powMod(x * x % 1000000009, k / 2);
else
return x * powMod(x, k - 1) % 1000000009;
}
long long addMod(long long x, long long y) {
return ((x % 1000000009) + (y % 1000000... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)2e5 + 7;
const int MOD = (int)1e9 + 9;
const int dx[] = {-1, 0, 1};
int n;
int sx[MAXN], sy[MAXN];
bool u[MAXN];
set<int> can;
map<pair<int, int>, int> pos;
bool onlyOne(int x, int y) {
if (!pos.count(make_pair(x, y))) return false;
int cid = pos[m... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
int m;
cin >> m;
set<pair<int, pair<int, int> > > S;
map<pair<int, int>, int> M;
const int dx[3] = {1, 0, -1};
vector<pair<int, int> > coor;
for (int t = 0; t < m; t++) {
int x, y;
cin >> x >> y;
M[make_pair(... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:102400000,102400000")
const double eps = 1e-9;
const long long mod = 1e9 + 9;
map<pair<int, int>, int> m;
struct node {
int x, y, id;
bool operator<(const node &I) const { return id < I.id; }
} p[200020];
s... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, pair<int, int> > a;
set<pair<int, pair<int, int> > > can_del;
void upd_del(int x, int y, int val) {
bool can = 1;
for (int(j) = (-1); j < (2); ++(j)) {
if (a.count({x + j, y + 1}) && a[{x + j, y + 1}].second == 1) can = 0;
}
if (can)
can_... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int mx = 1e5 + 5;
long long mod = 1e9 + 9;
struct EqualFunc {
bool operator()(const pair<long long, long long> &lhs,
const pair<long long, long long> &rhs) const {
return lhs.first == rhs.first && lhs.second == rhs.second;
}
};
struct HashFun... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000009;
int N;
map<pair<int, int>, int> all;
pair<int, int> points[100001];
set<pair<int, pair<int, int>>> good;
int ans;
bool isstable(int x, int y, int bx, int by) {
if (!all.count({x, y})) return true;
return y == 0 ||
(make_pair(x - 1, y... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
priority_queue<pair<int, pair<int, int> > > QMax;
priority_queue<pair<int, pair<int, int> > > QMin;
map<pair<int, int>, int> data;
int vis[100001];
int deg[100001];
int getM(int x, int y) { return data[make_pair(x, y)]... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
double eps = 1e-9;
const int INF = 1e9 + 7;
const int MAXN = int(2e5 + 7);
int n, k, ans, r, mod = INF + 2;
set<int> second, st;
map<pair<int, int>, int> m;
map<int, pair<int, int> > m1;
vector<int> v;
bool check(int x, int y) {
vector<pair<int, int> > v;
for (int i = x... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
long long M = 1e9 + 9;
map<pair<long long, long long>, long long> mp;
long long cnt[N];
long long pw(long long a, long long b) {
if (b == 0) return 1;
long long t = pw(a, b / 2);
t = (t * t) % M;
if (b % 2) t = (t * a) % M;
return t;
}
long ... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 9;
const int N = 1e5 + 5;
map<pair<int, int>, int> mp;
vector<int> g[N], rg[N];
int x[N], y[N];
bool cant[N], del[N];
set<int> now;
int out[N];
void Delete(int p) {
del[p] = 1;
now.erase(p);
for (int i = 0; i < (int)rg[p].size(); ++i) {
int u... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
map<pair<int, int>, int> m;
bool can(int x, int y) {
return y == 0 || m.count(make_pair(x - 1, y - 1)) ||
m.count(make_pair(x, y - 1)) || m.count(make_pair(x + 1, y - 1));
}
bool check(int x, int y) {
int pos = m[mak... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MAX_N = (int)(1e5) + 10;
const int MOD = (int)(1e9) + 9;
struct Point {
Point() {}
Point(int xx, int yy) : x(xx), y(yy) {}
int x, y;
bool operator<(const Point &a) const {
if (a.y == y) return x < a.x;
return y < a.y;
}
} point[MAX_N];
int n;
map... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.util.*;
import java.io.*;
public class D {
public static PrintStream out = System.out;
static class Node {
ArrayList<Node> above = new ArrayList<Node>();
ArrayList<Node> below = new ArrayList<Node>();
int x, y, i;
public Node (int xx, int yy, int ii) {
x =... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
vector<long long> v;
priority_queue<pair<long long, pair<long long, long long> > > mi, ma;
map<long long, map<long long, long long> > mp, mp1, f;
long long n, x, a[100005], b[100005], M1 = 1e9 + 9;
long long ans, res;
int tq(int x, int y) {
if (mp[x][y] == 0) return 1;
... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
public class CF295B {
int[] row;
int[] column;
TreeSet<Integer> removable = new TreeSet<>();
TreeMap<int[], Integer> position = new TreeMap<>(
... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int mod = 1000 * 1000 * 1000 + 9;
const int N = 1000 * 100 + 5;
int m, p[N], ans = 0;
set<pair<int, pair<int, int> > > s, stable;
set<pair<int, pair<int, int> > >::iterator it, it0, itg, itq;
map<pair<int, int>, int> num;
map<pair<int, int>, int>::iterator q;
int getN... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> pos;
map<int, pair<int, int> > top;
map<int, pair<int, int> > cubes;
int arr[100005];
long long mod = 1000000009;
bool checkleft(int x, int y) {
if (pos.find({x - 1, y + 1}) != pos.end() &&
pos.find({x - 2, y}) == pos.end() && pos.find({x - ... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
struct Node {
int x, y, num;
};
int i, j, k, w, v, s, flag, n, tmp, b[400005][5], c[400005][5], vis[400005],
pos[400005], L[400005], R[400005], sum[400005];
long long ans;
struct Node a[400005];
FILE *fp1 = fopen("CF521_B_1.txt", "r");
FILE *fp2 = fopen("CF521_B_5.txt... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long n;
set<long long> s;
long long a[100005];
long long b[100005];
map<long long, map<long long, long long> > k;
bool mark[100005];
long long x, y;
vector<long long> q;
long long mod = 1e9 + 9;
int pp(long long g, long long h) {
if (k[g][h + 1] != 0 && k[g - 1][h] =... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Set;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class Cubes {
stati... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
struct Node {
int x, y;
};
int n;
map<pair<int, int>, int> nodes;
Node data[100010];
set<int> preNodes;
int findNode(int x, int y) {
if (nodes.find(make_pair(x, y)) == nodes.end()) return -1;
return nodes[make_pair(x, y)];
}
bool moveTest(int id) {
int x = data[id].... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
return b ? gcd(b, a % b) : a;
}
template <class T>
void chmax(T& a, T b) {
a = max(a, b);
}
template <class T>
void chmin(T& a, T b) {
a = min(a, b);
}
#pragma comment(linker, "/STACK:36777216")
const int MOD = ((int)1e9) + 9;
vect... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.io.*;
import java.util.*;
import java.math.BigInteger;
import java.util.Map.Entry;
import static java.lang.Math.*;
public class B extends PrintWriter {
long point(long x, long y) {
return (x << 32) | (y);
}
boolean isStabel(int x, int y, Map<Long, Integer> p, int rx, int ry) {
if (y == 0 || !p.co... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int m;
int x[100000], y[100000];
map<pair<int, int>, int> ma;
int ans = 0;
vector<int> g[100000], rev[100000];
int indeg[100000] = {}, outdeg[100000] = {};
set<int> se;
int cnt[100000] = {};
bool used[100000] = {};
const int MOD = 1e9 + 9;
int main() {
scanf("%d", &m);
... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 9;
map<pair<int, int>, int> number;
struct cube {
int x;
int y;
int num;
cube() { x = y = num; }
cube(int _x, int _y, int _num) {
x = _x;
y = _y;
num = _num;
}
};
bool operator<(const cube &left, const cube &rig... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 100 + 10;
const long long MOD = 1000000009;
long long pw[maxn];
pair<int, int> p[maxn];
map<pair<int, int>, int> mp;
pair<int, int> moveU[] = {make_pair(-1, 1), make_pair(0, 1), make_pair(1, 1)};
pair<int, int> moveD[] = {make_pair(-1, -1), make_pair... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using i32 = int32_t;
using ui32 = uint32_t;
using i64 = int64_t;
using ui64 = uint64_t;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T>
T gc... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
typedef struct {
int n;
int arr[100000];
int val[100000];
int pos[100000];
void makeswap(int a, int b) {
swap(arr[a], arr[b]);
swap(pos[arr[a]], pos[arr[b]]);
}
int up(int a... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x37373737;
const long long mod = 1e9 + 9;
const int maxn = 1e5 + 5;
int N;
map<pair<int, int>, int> M;
int ans[maxn];
int input[maxn][2];
struct node {
int x, y, m;
node() {}
node(int x, int y, int m) : x(x), y(y), m(m) {}
bool operator<(const node&... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
const int output_precision = 15;
const long double pi = acos(-1);
const bool debug = true;
const long long M = 1e5 + 5;
const long long MOD = 1e9 + 9;
map<pair<long long, long long>, long long> mm;
long long x[M], y... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> book;
inline int read() {
int x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
ret... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.io.*;
import java.util.*;
public class B{
public static boolean DEBUG = false;
public static int MOD = 1000000009;
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
i... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
using namespace std;
int n;
int x[123456], y[123456];
map<pair<int, int>, int> id;
int get(int x, int y) {
if (id.find({x, y}) == id.end()) return -1;
return id[{x, y}];
}
set<int> up[123456], down[123456];
set<int> stable;
void del(int ... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int mod = 1e9 + 9;
map<pair<int, int>, int> mp;
map<pair<int, int>, int>::iterator it;
int x[maxn], y[maxn];
set<int> s;
bool down(int x, int y, int xx, int yy) {
for (int i = -1; i <= 1; i++) {
if (xx == x + i && yy == y - 1) continue... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 9;
map<pair<long long, long long>, long long> mp;
long long m, x, y, pos, ans, p;
pair<long long, long long> a[111111];
set<long long> s;
long long finddown(long long x, long long y, pair<long long, long long> &p) {
long long res = 0;
if (mp[... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.util.Map;
import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Tre... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ull = unsigned long long;
int m;
struct point {
int x, y;
} cube[200005];
map<pii, int> mp;
set<int> st;
int tans[200005];
int up[3][2] = {{0, 1}, {-1, 1}, {1, 1}};
int down[3][2] = {{0, -1}, {-1, -1}, {1, -1}};
int CountDown(const pii &t... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MAX = 100005, mod = 1e9 + 9;
struct cube {
int x, y, id;
bool operator<(const cube &a) const {
if (x == a.x) return y < a.y;
return x < a.x;
}
} p[MAX];
int n, perm[MAX], in[MAX], out[MAX];
bool used[MAX];
int G[MAX][3], rG[MAX][3];
set<int> que;
voi... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;
public final class CF_Cubes_v4{
void log(int[] X){... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class ProblemB {
private static final long B = (long)1e9+9;
BufferedReader rd;
Map<Pair, Integer> active = new HashMap<>();
Set<Pair> removed = new HashSet<>();
private ProblemB(... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 9;
const int MAXN = 200 * 1000;
int x[MAXN], y[MAXN];
bool del[MAXN];
set<int> may;
map<pair<int, int>, int> is;
vector<int> ans;
int n;
int cnt(int x, int y) {
int ans = 0;
for (int i = -1; i < 2; i++) ans += (int)is.count(make_pair(x + i, y ... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class B extends PrintWriter {
long point(long x, long y) {
return (x << 32) | (y);
}
boolean isStabel(int x, int y, EzLongIntHashMap p, int rx, int ry) {
if (y == 0 || !p.containsKey(point(x, y))) {
return true;
}
for (int dy = -... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
namespace std {
template <typename _Key, typename _Hash = std::hash<_Key>>
using hash_set = std::unordered_set<_Key, _Hash>;
template <typename _Key, typename _Hash = std::hash<_Key>>
using hash_mset = std::unordered_multiset<_Key, _Hash>;
template <typename _Key, typename _Val, typename _Hash ... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;
/**
* @author Don Li
*/
public class Cubes {
static final int MOD = (int) (1e9 + 9)... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 |
import java.io.*;
import java.util.*;
public class B extends PrintWriter {
long point(long x, long y) {
return (x << 32) | (y);
}
boolean isStabel(int x, int y, EzLongIntTreeMap p, int rx, int ry) {
if (y == 0 || !p.containsKey(point(x, y))) {
return true;
}
for (int dy = -1, dx = -1; dx <= 1; dx++) {... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int x[100000], y[100000];
set<int> s;
map<pair<int, int>, int> m;
bool mark[100000];
bool slobo(int t) {
for (int i = 0; i < 3; i++) {
int h = m[make_pair(x[t] + i - 1, y[t] + 1)] - 1;
if (h >= 0 && !mark[h]) {
int ret = 0;
for (int j = 0; j < 3; j++) ... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long rdtsc() {
long long tmp;
asm("rdtsc" : "=A"(tmp));
return tmp;
}
inline int myrand() { return abs((rand() << 15) ^ rand()); }
inline int rnd(int x) { return myrand() % x; }
const int INF = (int)1e9 + 1;
const long double EPS = 1e-9;
const int MOD = (int)1e9 ... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.TreeSet;
import java.io.Writer;
import ja... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000009;
long long powmod(long long a, long long b) {
long long res = 1;
a %= mod;
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res;
}
const int N = 101000;
map<pair<int, int>, int> hs;
set<int> st... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 9;
const int N = 1e5 + 5;
map<pair<int, int>, int> mp;
int near[N][6];
struct node {
int x, y;
long long id;
bool operator<(const node& a) const { return id < a.id; }
} a[N];
long long p[N];
int vis[N];
set<int> s;
int judge(int id) {
if ... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5;
const int MOD = 1e9 + 9;
int A[MAXN + 10], X[MAXN + 10], Y[MAXN + 10];
int n, ncnt = 0;
set<pair<int, int> > S;
map<pair<int, int>, int> M;
inline bool is_exist(int x, int y) { return M.count(make_pair(x, y)); }
inline int count_pillar(int x, int y) {
... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e5 + 10;
const int MaxM = 3e5 + 10;
const long long mod = 1e9 + 9;
bool vis[MaxN], able[MaxN];
int xx[MaxN], yy[MaxN], n;
int need[MaxN][3], sup[MaxN][3];
int cntSup[MaxN], cntNeed[MaxN];
priority_queue<int> big;
priority_queue<int, vector<int>, greater<in... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const long long LINF = (long long)1e18;
const int INF = (int)1e9 + 7;
const int N = (int)1e6 + 7;
const double EPS = (double)1e-9;
const double PI = (double)3.14159265359;
const int MODULO[6] = {INF, 1000019677, 1000019393,
1000007521, 10000240... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.util.List;
import java.io.IOException;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.TreeSet;
import java.io.InputStream;
/**
* Built using CHelper plug-i... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
map<pair<int, int>, int> M;
int m;
const int MAXN = 1e5 + 20;
int x[MAXN], y[MAXN];
vector<int> v[MAXN], up[MAXN];
int oc[MAXN];
set<int> can;
const int MOD = 1e9 + 9;
int stand[MAXN];
void erase(int x) {
can.erase(x);
for (auto it : up[x]) {... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 9;
int n, x[100005], y[100005];
long long ans;
vector<int> bt[100005], tp[100005];
set<int> s;
map<pair<int, int>, int> g;
inline bool isf(const int& x) {
bool f = true;
for (const int& y : tp[x])
if (bt[y].size() == 1) f = false;
return f;
}... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int mod = 1000000009;
priority_queue<int> heap_min;
priority_queue<int, vector<int>, greater<int> > heap_max;
struct point {
int x, y, id;
} x[100005];
inline bool operator<(point a, point b) {
return (a.x == b.x) ? (a.y < b.y) : (a.x < b.x);
}
set<point> s;
int n... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
struct cube {
long long int x, y;
};
long long int N, od[100050], sol[100050], K;
vector<int> graf[100050], to[100050];
cube a[100050];
bool rv[100050];
map<pair<long long int, long long int>, int> mp;
set<int> st;
int main() {
cin >> N;
int i, j, nod;
for (i = 1; i... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, laided[100001];
long long xx[100001], yy[100001];
struct Point2DbyXY {
long long x, y;
Point2DbyXY(){};
Point2DbyXY(long long a, long long b) { x = a, y = b; };
bool operator<(const Point2DbyXY &P) const {
if (x < P.x) return true;
if (x > P.x) return... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
const long long INF = 1e9;
const long long lINF = 1e18;
const double EPS = 1e-12;
const int MOD = 1e9 + 9;
using namespace std;
pair<int, int> v[111111];
map<pair<int, int>, int> num;
set<pair<int, int> > all;
map<int, set<int> > sup, dep;
int n;
set<pair<int, int> > cur;
bool check(int p) {
... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9;
const long long INFL = (long long)9e18;
const int MAXINT = ((~0) ^ (1 << 31));
const long long MAXLL = ((~0) ^ ((long long)1 << 63));
template <class T>
inline T pow2(T a) {
return a * a;
}
template <class T>
inline bool mineq(T& a, T b) {
retu... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int MOD = 1e9 + 9;
vector<int> v;
int X[N], Y[N];
map<pair<int, int>, int> M;
set<int> S;
int stability(int x, int y) {
int i = M[make_pair(x, y)];
if (i == 0) return 3;
int ans = 0;
if (M[make_pair(x - 1, y - 1)]) ans++;
if (M[make_pa... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int const N = 1e5 + 123;
int const MOD = 1e9 + 9;
struct cubic {
int x, y, v;
cubic(){};
cubic(int x, int y, int v) : x(x), y(y), v(v){};
};
bool compY(cubic a, cubic b) {
if (a.y < b.y) return true;
if (a.y > b.y) return false;
return (a.x < b.x);
}
vector<cubi... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.util.*;
import java.io.*;
public class Cubes
{
public static final long MOD = 1000000009;
public static TreeMap<Pair, Integer> map;
public static void main(String[] args) throws Exception
{
FastScanner in = new FastScanner(System.in);
int m = in.nextInt();
map = new TreeMap<Pair, Integer... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int x[100000], y[100000];
vector<int> under[100000], over[100000];
int cnt[100000], cntu[100000];
bool used[100000];
bool pode(int i) {
bool ok = !used[i];
for (int j = 0; j < over[i].size(); j++) {
int next = over[i][j];
if (!used[next] && cntu[next] < 2) ok = ... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
static int MOD = 1000000009;
// After writing solution, quick scan for:
// array out of bounds
// special cases e.g. n=1?
//
// Big numbers arithmetic bugs:
// int overflow
// sorting, or tak... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.io.InputStream;
import java.util.AbstractQueue;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.io.IOException;
import java.util.Abs... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const long long mod = 1e9 + 9;
int x[maxn], y[maxn];
bool vis[maxn];
int n;
set<int> S;
vector<int> ans;
unordered_map<long long, int> id;
inline long long key(int a, int b) { return (long long)(a)*mod + (long long)b; }
int arr[maxn][6];
void init(... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.io.*;
import java.util.*;
public class CF {
FastScanner in;
PrintWriter out;
class Pos {
int x, y;
public Pos(int x, int y) {
super();
this.x = x;
this.y = y;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + getOuterType()... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> H;
int n, i, j, k, l, p, q;
int x[100005], y[100005];
int son[100005][5], fa[100005][5];
int ns[100005], nf[100005];
int Min[400005], Max[400005];
int ans[100005];
long long Ans;
bool del[100005];
void work(int x) {
int i;
for (i = l + x - 1 >> ... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000 * 1000 * 1000 + 9;
const long long int N = 1e5 + 10;
map<pair<long long int, long long int>, pair<long long int, long long int> > m;
long long int n;
set<long long int> st;
long long int dx[3] = {-1, 0, 1};
long long int x[N], y[N];
int main()... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
struct edge {
int u, v;
long long w;
};
long long MOD = 1000000007;
long long _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 3;
int main() {
int m;
cin >> m;
map<pair<int, int>, int> mp;
priority_queue<int> pq;
priority_queue<int, vector<int>, grea... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int mod = 1000000009;
const int MAXN = 1000006;
map<pair<int, int>, int> M;
pair<int, int> P[MAXN];
vector<int> V[MAXN], VT[MAXN];
int deg[MAXN], ans[MAXN];
int forb[MAXN], zazn[MAXN];
void solve() {
int n;
scanf("%d", &n);
for (int i = 0; i < (n); ++i) {
in... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;
public final class CF_Cubes_v4{
void log(int[] X){... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000009;
int N;
int X[100002], Y[100002];
map<pair<int, int>, int> M;
set<int> S, T;
int result;
int stably(int i) {
int x = X[i], y = Y[i];
int num = 0;
if (M.find(make_pair(x - 1, y - 1)) != M.end() &&
T.find(M[make_pair(x - 1, y - 1)]) != T... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 9;
const int maxn = 100100;
struct BOX {
int x, y, id;
} box[maxn];
int n;
map<pair<int, int>, int> mPI;
set<pair<int, int> > Pt;
set<int> St;
bool isST(int id) {
int x = box[id].x;
int y = box[id].y;
pair<int, int> tp;
tp = make_pa... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int N, MOD = 1e9 + 9;
int x[MAXN], y[MAXN], toca[MAXN];
map<pair<int, int>, int> mapa;
set<int> segura[MAXN], segurado[MAXN], livres;
int simulate() {
long long vez = 0, ans = 0;
while (livres.size() > 0) {
long long ele;
if (!vez)
... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;
import java.io.BufferedReader;
import java.util.Map;
import java.util.List;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.HashMap;
import java.io.... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const int mod = 1e9 + 9;
int dx[3][2] = {1, 1, 0, 1, -1, 1};
const int N = 110000;
struct node {
int x, y;
int fen;
int ch, xia;
bool operator<(const node &b) const { return fen < b.fen; }
} b[N];
struct comp {
bool operator()(node ... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000009;
map<int, std::pair<int, int> > all;
map<std::pair<int, int>, int> all1;
set<int> allowed;
bool isSafe(int idx) {
assert(all.find(idx) != all.end());
std::pair<int, int> cord = all[idx];
int x = cord.first, y = cord.second;
if (y == 0) ret... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.io.*;
import java.util.*;
public class B {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
static final long P = 1_000_000_009;
static class Coord {
int x, y;
public Coord(int x, int y) {
this.x = x;
this.y = y;
}
@Override
public int hashCode() {
return ... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int MAX = 1e9 + 5;
int out[N], n, asdasdasd, h[N], in[N], POW[N], x, y, a[N][2], ans1, ans2, P[N];
vector<int> v[N], v2[N];
map<pair<int, int>, int> H;
priority_queue<int> qmax;
priority_queue<int, vector<int>, greater<int> > qmin;
bool ctr(int ... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 9;
const int INF = 0x3f3f3f3f;
const double eqs = 1e-9;
struct node {
int x, y;
} fei[110000];
priority_queue<int, vector<int>, greater<int> > q1;
priority_queue<int, vector<int>, less<int> > q2;
map<pair<int, int>, int> mp;
int vis[110000];
bool che... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long ans;
int m, x[100010], y[100010], cannot[100010];
map<pair<int, int>, int> pos;
set<int> couldbe;
void update(int x, int y, int add) {
if (y == 0) return;
vector<int> below;
for (int dx = -1; dx <= 1; dx++)
if (pos.count({x + dx, y - 1})) below.push_back... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.util.Map;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeMap;
import java.util.HashMap;
import java.util.SortedSet;
import java.util.Set;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.TreeSet;
import java.util.Str... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.AbstractQueue;
import java.util.InputMismatchException;
import java.io.IOException;
... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class B {
final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
inline int rint() {
int a;
scanf("%d", &a);
return a;
}
inline long long rll() {
long long a;
scanf("%lld", &a);
return a;
}
inline double rdouble() {
double a;
scanf("%lf", &a);
return a;
}
long long gcd(long long a, long long b) { return (b) ? gcd(b, a %... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000009;
const int N = 100001;
int x[N];
int y[N];
map<long long, int> m;
set<int> yes;
set<int> no;
vector<int> sol;
long long hsh(int x, int y) { return 2e9 * x + y; }
vector<int> getIn(int v) {
vector<int> in;
for (int i = -1; i <= 1; ++i) {
lo... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.SortedSet;
import java.util.AbstractSet;
import java.util.InputMismatchException;
import java.util.Random;
import java.util.TreeSet;
import java.util.ArrayList;
import java.util.Map;
import jav... | JAVA |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
priority_queue<int> large;
priority_queue<int> small;
map<pair<int, int>, bool> freez;
map<pair<int, int>, bool> ex;
map<pair<int, int>, int> val;
pair<int, int> a[100005];
int m;
bool relyOnMaxOne(pair<int, int> s) {
int cnt = 0;
pair<int, int> t1, t2, t3;
t1.first =... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const long long MOD = 1e9 + 9;
int n;
long long ans[MAXN];
struct Node {
int x, y;
int up[4], down[4];
Node() {
memset(up, -1, sizeof(up));
memset(down, -1, sizeof(down));
}
Node(int _x, int _y) : x(_x), y(_y) {}
int getdown() ... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int m;
int x[100100], y[100100];
int dx[3] = {-1, 0, 1};
int only[100100];
bool used[100100];
map<pair<int, int>, int> M;
struct cube {
int x, y, id;
cube(int x, int y, int id) : x(x), y(y), id(id) {}
bool operator<(const cube& a) const { return y > a.y; }
};
set<int>... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
struct less_key {
bool operator()(const pair<uint32_t, uint32_t>& p1,
const pair<uint32_t, uint32_t>& p2) {
return p1.first < p2.first ||
(p1.first == p2.first && p1.second < p2.second);
}
};
uint32_t m;
pair<int32_t, int32_t> a[100002];... | CPP |
521_B. Cubes | Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le... | 2 | 8 | #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.push_back(x);
return v;
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) { return a > b ? a : b; }
long long min(long long a, long long b) { return a < b ? a : b; }
void fun(int arr[], int n) {
stack<int> s;
int left[n + 1];
int right[n + 1];
for (int i = 0; i < n; i++) {
left[i] = -1;
righ... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int debug = 0;
int const MAXN = 2e5 + 10;
int a[MAXN], n;
int L[MAXN], R[MAXN];
int ans[MAXN];
void solve() {
cin >> n;
for (int i = (1); i <= (n); ++i) cin >> a[i];
stack<int> s;
s.push(0);
a[0] = a[n + 1] = 0;
for (int i = (1); i <= (n + 1); ++i) {
while (... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Stack;
public class CF_305_D {
public static void main(String[] args) throws IOException{
PrintWriter pw = new PrintWriter(System.out, true);
BufferedReader inp... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.util.*;
import java.io.*;
public class MIKE_AND_FEET {
public static void main (String[] args) throws IOException{
// Scanner sc=new Scanner(System.in);
// int n=sc.nextInt();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(br.readLine().t... | JAVA |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.