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 |
|---|---|---|---|---|---|
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << '{';
string sep;
for (const auto &x : v) os << sep << x, sep = ", ";
return os << '}';
}
template <typename T, size_t size>
ostream &operator<<(ostream &os, const array<T, size> &arr)... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int N = 203, M = N * N, K = M << 3;
template <typename T>
void read(T &x) {
int ch = getchar();
x = 0;
bool f = false;
for (; ch < '0' || ch > '9'; ch = getchar()) f |= ch == '-';
for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
if (f)... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int Maxx = 100005, INF = 0x3f3f3f3f;
inline int read() {
int res = 0, bj = 0;
char ch = getchar();
while (ch < '0' || ch > '9') bj |= (ch == '-'), ch = getchar();
while (ch >= '0' && ch <= '9')
res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
r... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << '{';
string sep;
for (const auto &x : v) os << sep << x, sep = ", ";
return os << '}';
}
template <typename T, size_t size>
ostream &operator<<(ostream &os, const array<T, size> &arr)... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int Maxn = (1 << 16);
const int Block = (1 << 8) - 1;
const int d[4] = {1, 256, -1, -256};
int n;
int a[Maxn];
bool mp[4][Maxn];
int lis[1024], len;
bool vis[Maxn];
bool S[Maxn], T[Maxn];
bool dfs(const int &u, const bool *g) {
vis[u] = 1;
if (g[u]) {
return 1... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
int head[40010], nxt[1000001], b[1000001], v[1000001], c[1000001],
k = 1, pre[1000010], S, T;
long long dis[1000001];
int map[201][201], n, m;
void push(int s, int t, int val, int cost) {
nxt[++k] = head[s];
head[s] = k;
b[k] = t;
v[k] = val;
c[k] = cost;
}
void link(int s, int t,... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int inf = 1e9;
int to[N], ww[N], nxt[N], tt = 1, a[210][210], h[N], dep[N], s, t, cur[N], n,
id[210][210], dx[4] = {1, 0, 0, -1},
dy[4] = {0, 1, -1, 0}, st[N], tp;
bool vis[N];
void adde(int u... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using std::max;
using std::min;
const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const long long INF = 0x3f3f3f3f3f3f3f3f;
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
template <typename _Tp>
_Tp gcd(const _Tp &a, const _Tp &b) {
return !b ? a : gcd(b, a % b);
}... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
namespace FLOW {
const int maxn = 40010;
int V, cnt, head[maxn], lev[maxn];
struct edge {
int to, cap, nxt;
} e[maxn * 10];
void init(int _V) {
V = _V, cnt = 0;
fill(head, head + V + 1, -1);
}
void add_edge(int u, int v, int cap, bool dir = 0) {
e[cnt] = (edge){v, c... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
unsigned X(unsigned xy) { return xy >> 8; }
unsigned Y(unsigned xy) { return xy & 255; }
unsigned XY(unsigned x, unsigned y) { return (x << 8) | y; }
int vals[65536];
int available[65536][4];
int dt[4] = {1, 256, -1, -256};
unsigned N;
bool sources[65536];
bool sinks[65536]... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int read() {
int t;
scanf("%d", &t);
return t;
}
int n;
struct wangluoliu {
int head[40010], last[800000], val[800000], v[800000], p = 1;
int dep[40010], cur[40010];
bool ex[40010];
void add(int a, int b, int c) {
v[++p] = b;
... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
inline int read() {
int x = 0, f = 1;
char c = getchar();
while (!isdigit(c)) {
if (c == '-') f = -1;
c = getchar();
}
while (isdigit(c)) {
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return f == 1 ? x : ~x + 1;... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
int read() {
int x = 0;
bool flg = false;
char ch = getchar();
for (; !isdigit(ch); ch = getchar())
if (ch == '-') flg = true;
for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch ^ 48);
return flg ? -x : x;
}
const int INF = 1e9;
int n;
int a[2... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int N = 205, M = 40010, INF = 2147483647;
int n, a[N][N], tot, head[M];
int is[M], it[M], vis[M];
long long ans;
vector<pair<int, int> > vi;
struct PP {
int id, c, nxt;
} edge[M << 2];
inline int read() {
int x = 0, f = 1;
char c = getchar();
for (; c > '9' ||... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
int v = 0, f = 1;
char c = getchar();
while (!isdigit(c) && c != '-') c = getchar();
if (c == '-')
f = -1;
else
v = (c & 15);
while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
x = v * f;
}
inline void read(lo... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using std::min;
using std::sort;
using std::vector;
const int inf = 0x3f3f3f3f;
namespace mf {
const int N = 1e5 + 5;
int n, s, t, ans;
struct edge {
int v, w, inv;
bool ex;
};
vector<edge> e[N];
bool bk[N];
inline edge& inv(edge ed) { return e[ed.v][ed.inv]; }
inline void add_edge(int u, i... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
namespace FLOW {
const int maxn = 40010;
int V, cnt, head[maxn], lev[maxn];
struct edge {
int to, cap, nxt;
} e[maxn * 10];
void init(int _V) {
V = _V, cnt = 0;
fill(head, head + V + 1, -1);
}
void add_edge(int u, int v, int cap, bool dir... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int N = 222;
const int M = N * N;
const int inf = 1e9;
struct edge {
int pr;
int to;
int cap;
} e[222222];
int tot = 1, la[M];
void clr() {
tot = 1;
memset(la, 0, sizeof(la));
}
void adde(int x, int y, int z) {
e[++tot].pr = la[x];
la[x] = tot;
e[tot].... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
const int P = 998244353;
using namespace std;
template <typename T>
inline void ckmax(T &a, T b) {
(a < b) && (a = b);
}
template <typename T>
inline void ckmin(T &a, T b) {
(a > b) && (a = b);
}
inline int mul(int a, int b) { return 1ll * a * b % P; }
inline int add(int a, int b) { return ... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template <typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const long long N = 205, M = N * N;
long long n, m, a[N][N], tot = 1, ver[M << 2], nxt[M << 2], edge[M << 2], h[M],
iS[M], iT[M], flow, s, t, vis[M];
inline void add(long long x, long long y) {
ver[++tot] = y, edge[tot] = 0, nxt[tot] = h[x], h[x] ... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class t, class u>
void chmax(t& first, u second) {
if (first < second) first = second;
}
template <class t, class u>
void chmin(t& first, u second) {
if (second < first) first = second;
}
template <class t>
using vc = vector<t>;
template ... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
namespace FLOW {
const int maxn = 40010;
int V, cnt, head[maxn], lev[maxn];
struct edge {
int to, cap, nxt;
} e[maxn * 10];
void init(int _V) {
V = _V, cnt = 0;
fill(head, head + V + 1, -1);
}
void add_edge(int u, int v, int cap, bool dir = 0) {
e[cnt] = (edge){v, c... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
long long res = 1;
a %= mod;
assert(b >= 0);
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res;
}
long long gcd(long long a, long long b) { re... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') f = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = (x << 1) + (x << 3) + ch - '0';
ch = getchar();
}
return x * f;
}
namespa... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
template <typename _T>
inline void read(_T &f) {
f = 0;
_T fu = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') {
fu = -1;
}
c = getchar();
}
while (c >= '0' && c <= '9') {
f = (f << 3) + (f << 1) + (c & 15);
c = getch... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
std::mt19937 rnd(
(int)std::chrono::steady_clock::now().time_since_epoch().count());
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
struct MaxFlow {
int n;
vector<int> ghead, gnxt, gto;
vector<long long> gcap;
vector<int> d;
que... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
using namespace std;
template <typename T1, typename T2>
void ckmin(T1 &a, T2 b) {
if (a > b) a = b;
}
template <typename T1, typename T2>
void ckmax(T1 &a, T2 b) {
if (a < b) a = b;
}
int read() {
int x = 0, f ... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
template <class T>
T gi() {
T x = 0;
bool f = 0;
char c = getchar();
while (c != '-' && (c < '0' || c > '9')) c = getchar();
if (c == '-') f = 1, c = getchar();
while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return f ? -x : x;
}
const int N ... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
int cnt2 = 0;
int en = 0;
struct Dinic {
static const int MXN = 100000;
struct Edge {
int v, f, re;
Edge(int a, int b, int c) : v(a), f(b), re(c) {}
};
int n, s, t, level[MXN];
vector<Edge> E[MXN];
void init(int _n, int _s, int _t) {
n = _n;
s = ... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using std::max;
using std::min;
const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const long long INF = 0x3f3f3f3f3f3f3f3f;
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
template <typename _Tp>
_Tp gcd(const _Tp &a, const _Tp &b) {
return !b ? a : gcd(b, a % b);
}... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int N = 205, M = N * N;
using ll = long long;
int n, a[N][N];
struct Edge {
int v, nxt;
ll w, cw;
} e[M << 2];
int head[M], ptr;
void add_edge(int uu, int vv) {
e[ptr] = {vv, head[uu], 1, 0};
head[uu] = ptr++;
e[ptr] = {uu, head[vv], 1, 0};
head[vv] = ptr+... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
template <int N, int Ne>
struct flow {
using F = int;
F inf = 1e9;
int n, s, t;
int ehd[N], cur[N], ev[Ne << 1], enx[Ne << 1], eid = 1;
void clear() { eid = 1, memset(ehd, 0, sizeof(ehd)); }
F ew[Ne << 1], dis[N];
void Eadd(int u, int v, F w) {
++eid, enx[... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
template <class T>
T gi() {
T x = 0;
bool f = 0;
char c = getchar();
while (c != '-' && (c < '0' || c > '9')) c = getchar();
if (c == '-') f = 1, c = getchar();
while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return f ? -x : x;
}
const int N ... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
int read() {
int x = 0, sgn = 1;
char ch = getchar();
for (; !isdigit(ch); ch = getchar())
if (ch == '-') sgn = -1;
for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
return x * sgn;
}
const int N = 40010;
const int inf = 0x3f3f3f3f;
int ... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using db = double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
namespace FLOW {
const int maxn = 40010;
int V, cnt, head[maxn], lev[maxn];
struct edge {
int to, cap, nxt;
} e[maxn * 10];
void init(int _V) {
V = _V, cnt = 0;
fill(head, head + V + 1, -1);
}
void add_edge(int u, int v, int cap, bool dir... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
long long res = 1;
a %= mod;
assert(b >= 0);
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res;
}
long long gcd(long long a, long long b) { re... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const double pi = acos(0.0) * 2.0;
const long double eps = 1e-10;
const int step[8][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1},
{-1, 1}, {1, 1}, {1, -1}, {-1, -1}};
template <class T>
inline T abs1(T a) {
return a < 0 ? -a : a;
}
template <typename t,... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int N = 205, M = N * N;
using ll = long long;
int n, m, a[N][N];
struct Edge {
int v, nxt;
ll w, cw;
} e[M << 2];
int head[M], ptr;
void add_edge(int uu, int vv) {
e[ptr] = {vv, head[uu], 1, 0};
head[uu] = ptr++;
e[ptr] = {uu, head[vv], 1, 0};
head[vv] = p... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using ll = long long;
const int MN = 2e2 + 10;
const int MX = MN * MN;
const int MM = MX * 4;
int N, a[MN][MN];
ll ans;
struct Event {
public:
int v, n;
bool operator<(const Event &o) const {
return v < o.v || !(o.v < v) && n < o.n;
}
};
std::vector<Event> evt;
int hd[MX], flow[MM * ... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using std::max;
using std::min;
const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const long long INF = 0x3f3f3f3f3f3f3f3f;
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
template <typename _Tp>
_Tp gcd(const _Tp &a, const _Tp &b) {
return !b ? a : gcd(b, a % b);
}... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int N = 205;
int n, nd;
int a[N][N];
int id[N][N];
int S, T, tot = 1;
struct edge {
int to, next, f;
} e[N * N * 4];
int head[N * N];
int dis[N * N], q[N * N], from[N * N];
void add(int x, int y, int f1, int f2) {
e[++tot] = (edge){y, head[x], f1};
head[x] = tot... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int N = 205, INF = 0X3F3F3F3F;
int n, a[N][N];
int res;
int zip(int x, int y) { return (x - 1) * n + y; }
bool IN(int x, int y) { return 1 <= x && x <= n && 1 <= y && y <= n; }
struct MaxFlow {
static const int N = ::N * ::N, M = N * 8;
int S, T;
int dep[N], q[N... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
struct Edge {
int from;
int to;
int cap;
int flo;
int cost;
int rev;
};
int nv;
vector<Edge> graf;
vector<int> incid[44444];
void rename_edges() {
vector<int> newname(graf.size());
int nextname = 0;
for (int i = 0; i < (nv); i++)
for (int e : incid[i])... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const uint64_t seed =
std::chrono::system_clock::now().time_since_epoch().count();
mt19937_64 rnd(seed);
const int MOD = 998244353;
struct Dinic {
struct Edge {
int from, to;
long long cap, flow;
Edge(int u, int v, long long c) : from(u), to(v), cap(c), fl... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void rd(T &x) {
x = 0;
bool f = 0;
char c = getchar();
while (!isdigit(c)) {
if (c == '-') f = 1;
c = getchar();
}
while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
if (f) x = -x;
}
template <typename T>... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int M = 100005;
int read() {
int x = 0, f = 1;
char c;
while ((c = getchar()) < '0' || c > '9') {
if (c == '-') f = -1;
}
while (c >= '0' && c <= '9') {
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x * f;
}
int n, tot, f[M], a[... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
long long res = 1;
a %= mod;
assert(b >= 0);
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res;
}
long long gcd(long long a, long long b) { re... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
int a[200][200];
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
int vs = 0;
int id[200][200];
const int N = 4e5 + 10;
struct edge {
int a, b, cap, flow;
};
vector<int> g[N], gr[N];
vector<i... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class t, class u>
void chmax(t& first, u second) {
if (first < second) first = second;
}
template <class t, class u>
void chmin(t& first, u second) {
if (second < first) first = second;
}
template <class t>
using vc = vector<t>;
template ... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
constexpr int maxn = 201;
int read() {
int x = 0, f = 0;
char c = getchar();
while (!isdigit(c)) f = c == '-' ? 1 : f, c = getchar();
while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
return f ? -x : x;
}
namespace mcmf {
conste... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int N = 40003, dir[2][2] = {{1, 0}, {0, 1}};
const int inf = 803;
int n, cnode, a[203][203], id[203][203];
long long ans, mincost, dis[N];
int S, T, vis[N], inq[N], head[N], cur[N], ce = 1;
struct edge {
int to, nxt, cap, flow, w;
} e[2000003];
void lnk(int a, int b... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
const int inf = 2e9;
const int N = 205, V = 4e4 + 5, E = 1e6 + 5;
int n, m, s, t, ban, a[N][N], b[V], num, tb[V], dis[V], cur[V];
long long ans, nowf;
bool vis[V];
std::vector<int> pi[V], pj[V];
struct List {
int tot, fst[V], nxt[E], to[E], val[E], flw[E];
List() { memset(fst, -1, sizeof(fs... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const long long N = 205, M = N * N, inf = 0x7fffffff;
long long n, m, a[N][N], tot = 1, ver[M << 3], nxt[M << 3], edge[M << 3], h[M],
d[M], mxflow;
inline void add(long long x, long long y, long long z) {
ver[++tot] = y, edge[tot] = z, nxt[tot] = ... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using ll = long long;
using pii = std::pair<int, int>;
const int maxn = 205 * 205;
const int inf = 1e8;
int n, a[205][205], P[maxn];
ll ans;
std::vector<pii> v;
int id(int x, int y) { return (x - 1) * n + y; }
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
struct edge {
int v, c, nxt;
} ... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const long long M = 205;
long long read() {
long long x = 0, y = 1;
char ch = getchar();
while (ch < '0' || ch > '9') y = (ch == '-') ? -1 : 1, ch = getchar();
while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
return x * y;
}
long long n, a[M][... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const long long MAX_LIGNES = 200;
const long long NB_DEPLACEMENTS = 4;
const long long PUIT = 2;
const long long SOURCE = 1;
long long Deplacements[NB_DEPLACEMENTS][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
struct arete {
long long ligDest, colDest;
long long flot;
};
ar... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
const long long INF = LLONG_MAX / 4;
template <class Cap, class Cost>
struct MCMF {
public:
MCMF() {}
MCMF(int n) : _n(n), g(n) {}
int add_edge(int from, int to, Cap cap, Cost cost) {
a... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int MX = 202 * 202, ME = 8 * MX;
int n, m, e, S, T, it, i, ii, j, jj, x, fi, fr, cur, a[MX], k[MX], q[MX],
pe[MX], u[MX], t[ME], f[ME], c[ME];
vector<int> g[ME];
long long val, flow, r;
bool act[ME];
bool cmp(int x, int y) { return a[x] < a[y]; }
void addedge(int ... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
template <class Type>
long long quick_pow(Type x, Type y, Type Mod) {
long long res = 1;
while (y) {
if (y & 1) res = res * x % Mod;
x = x * x % Mod, y >>= 1;
}
return res;
}
template <class Type>
long long inv(Type x, Type Mod) {
return quick_pow(x, Mod -... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
int read() {
int t;
scanf("%d", &t);
return t;
}
int n;
struct wangluoliu {
int head[40010], last[800000], val[800000], v[800000], p = 1;
int dep[40010], cur[40010];
void add(int a, int b, int c) {
v[++p] = b;
last[p] = head[a];
head[a] = p;
val[... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using std::max;
using std::min;
const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const long long INF = 0x3f3f3f3f3f3f3f3f;
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
template <typename _Tp>
_Tp gcd(const _Tp &a, const _Tp &b) {
return !b ? a : gcd(b, a % b);
}... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
int a[210][210];
int iS[40010], iT[40010], vis[40010];
int hed[40010], tot = 1, mxfl;
long long ans;
int n;
vector<pair<int, int>> v;
inline int idx(int x, int y) { return (x - 1) * n + y; }
struct edg {
int to, nxt, fl;
} e[40010 << 2];
void adde(int x, int y) {
e[++to... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char c = getchar();
while (!isdigit(c)) {
if (c == '-') f = -1;
c = getchar();
}
while (isdigit(c)) {
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return f == 1 ? x : ~x + 1;
}
int n, m;
int a[210][... | CPP |
1427_G. One Billion Shades of Grey | You have to paint with shades of grey the tiles of an n× n wall. The wall has n rows of tiles, each with n tiles.
The tiles on the boundary of the wall (i.e., on the first row, last row, first column and last column) are already painted and you shall not change their color. All the other tiles are not painted. Some of... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
std::mt19937 rnd(
(int)std::chrono::steady_clock::now().time_since_epoch().count());
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
struct MaxFlow {
int n;
vector<int> ghead, gnxt, gto;
vector<long long> gcap;
vector<int> d;
que... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
#define N 100100
int id[300], x[N], fst[30], lst[30], cnt[30];
int n, a, b;
bool dp[1<<20];
char ch[30], s[N];
inline bool good(int y) {
int l = n, r = 0, tot = 0;
for (int i = 0; i < 20; i ++) if (y >> i & 1) {
if (cnt[i]) {
tot += cnt[i];... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int MX=1100100;
int n,m,A,B,MSK,msk,ii,i,j,cur,lst,le[28],ri[28],cnt[28],k[28],lft[MX],rgh[MX],c[MX],f[MX];
char s[5005],rev[22];
bool cmp(int i, int j) { return le[rev[i]-'a']<le[rev[j]-'a']; }
int main() {
scanf("%d%d%d",&n,&A,&B);
scanf("%s",s+1);
for (i=1; i... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const s... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <cstdio>
#include <cstring>
#include <algorithm>
#include <numeric>
template<typename T> bool ckmax(T& a, const T& b) {return b>a?a=b,1:0;}
template<typename T> bool ckmin(T& a, const T& b) {return b<a?a=b,1:0;}
const int MN = 5e3+10;
const int K = 20; // exact
char bad[]="trygub";
int N, A, B, l[K], r[K],... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
t=0; char ch=getchar(); int f=1;
while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int INF=0x7f7f7f7f;
int n,a,b,cnt,l[1<<20],r[1<<20];
char s[... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include<bits/stdc++.h>
#define L(i, j, k) for(int i = j, i##E = k; i <= i##E; i++)
#define R(i, j, k) for(int i = j, i##E = k; i >= i##E; i--)
#define ll long long
#define ull unsigned long long
#define db long double
#define pii pair<int, int>
#define mkp make_pair
using namespace std;
const int N = 5007;
const int... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" <... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include<bits/stdc++.h>
using namespace std;
int read(){
int a = 0; char c = getchar(); bool f = 0; while(!isdigit(c)){f = c == '-'; c = getchar();}
while(isdigit(c)){a = a * 10 + c - 48; c = getchar();} return f ? -a : a;
}
int cnt[23] , l[23] , r[23] , T , N , A , B , pos[23];
string s , alphabet = "acdefhijklmno... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | //starusc
#include<bits/stdc++.h>
using namespace std;
inline int read(){
int x=0,f=1,c=getchar();
while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
return f==1?x:-x;
}
const int N=20,M=5004,K=1<<20;
int n,A,B,tot,S,idx[N],c[N],L[K],R[K],cou[K],f[K];
char s[M];
v... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int n,a,b,id[26],idx,l[20],r[20],cnt[20];
char s[N];bitset<1 << 20> dp,ok;
int main ()
{
ios::sync_with_stdio(false);
cin >> n >> a >> b >> (s + 1);
memset(id,-1,sizeof(id));memset(l,63,sizeof(l));
for (int i = 1;i <= n;i++)
{
... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
bool computed[1 << 20], res[1 << 20];
int main(){
cin.tie(0);
ios_base::sync_with_stdio(0);
int n, a, b;
cin >> n >> a >> b;
string s; cin >> s;
vector<int> minPos(30, n), maxPos(30, -1), cnt(30);
vector<int> chars;
for(int i = n - 1; i >... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | # include <algorithm>
# include <iostream>
# include <numeric>
# include <vector>
# include <set>
using namespace std;
int main() {
int n, a, b;
while (cin >> n >> a >> b) {
string s;
cin >> s;
set<char> chars_set;
for (char c : s) {
chars_set.insert(c);
}
vector<char> chars(chars_se... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define R register int
#define N 1048576
struct Character{
char c;
int lf,rt;
inline friend bool operator<(Character A,Character B){
return A.lf<B.lf;
}
};
int l[N],r[N],ct[N],pos[26];
bool f[N];
int main(){
int n,a,b;
cin>>n>>a>>b;
s... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
typedef int int2;
#define int long long
#define pi pair<int, int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define INF 1e18
string printed(int mask) {
string res;
for (int i = 0; i < 26; i++) {
if... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | //#pragma GCC target("avx,avx2")
#include<bits/stdc++.h>
//#include<immintrin.h>
using namespace std;
template <typename T> void chmin(T&x,const T &y)
{
if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
if(x<y)x=y;
}
typedef int64_t s64;
typedef uint64_t u64;
typedef uint32_t u32;
typedef pair<int,i... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
#ifdef local
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define f(i, l, r) for (int i = l; i <= r; ++i)
#define rf(i, r, ... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 9982... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <cstdio>
#include <cassert>
#include <algorithm>
#include <numeric>
using namespace std;
const int N = 5005;
char s[N];
int a[N];
char alpha[26];
int acnt = 0;
bool vis[26];
int L[26], R[26], cnt[26];
bool f[1 << 20 | 5];
int main() {
int n, A, B;
scanf("%d%d%d", &n, &A, &B);
scanf("%s", s);
for (int... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
int n, a, b;
int toind[26];
int toch... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
/* * * * * * * * * * */
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
/* * * * * * * * * * */
/* *
*
* Too many mind, no mind.
*
* */
int main(){
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//freopen("input.txt", "r", stdi... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
typedef int int2;
#define int long long
#define pi pair<int, int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define INF 1e18
string printed(int mask) {
string res;
for (int i = 0; i < 26; i++) {
if... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using db = double;
using str = string; // yay python!
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>; ... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <iostream>
#include <cstdio>
#include <set>
int n, a, b, f[1 << 20 | 5];
int id[26], l[1 << 20 | 5], r[1 << 20 | 5], cnt[1 << 20 | 5];
char s[5005], rec[26];
int main() {
scanf("%d %d %d %s", &n, &a, &b, s + 1);
int p = 0;
for (int i = 0; i < 26; i++)
id[i] = -1;
for (int i = 1; i <= n; ++i) {
int c = ... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include "assert.h"
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <bitset>
using namespace std;
typedef long long ll;
char input[5005];
int lower[20];
int upper[20];
int counts[20];
pair<int, int> upperx[20];
int bitsets[21];
bitset<1050000> present;
int chartoidx(char c) {
in... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
int n, a, b, tot, mp[26], L[20], R[20], cnt[20];
bool f[1 << 20];
char s[5010];
int main() {
scanf("%d %d %d %s", &n, &a, &b, s + 1);
memset(mp, -1, sizeof(mp));
memset(L, 0x3f, sizeof(L));
for (int i = 1; i <= n; i++) {
if (!~mp[s[i] - 'a']) mp[s[... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int MX=1100100;
int n,m,A,B,MSK,msk,ii,i,j,cur,lst,le[28],ri[28],cnt[28],k[28],w[28],lft[MX],rgh[MX],c[MX];
bool f[MX];
char s[5005],rev[22];
bool cmp(int i, int j) { return le[w[i]]<le[w[j]]; }
int main() {
scanf("%d%d%d",&n,&A,&B);
scanf("%s",s+1);
for (i=1; i... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #define DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printA... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <algorithm>
#include <array>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;
template<typename A, typ... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
int main()
{
int n,a,b;
string s;
cin>>n>>a>>b>>s;
vector<char> aa(n);
for(int i=0;i<n;i++)
aa[i]=s[i];
sort(aa.begin(),aa.end());
aa.erase(unique(aa.begin(),aa.end()),aa.end());
int m=aa.size();
vector<int> v(n);
for(int i=0;i<n;... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
#define N 100100
int id[300], x[N], fst[30], lst[30], cnt[30];
int n, a, b, m;
bool dp[1<<20];
char ch[30], s[N];
inline bool good(int y) {
int l = n, r = 0, tot = 0;
for (int i = 0; i < m; i ++) if (y >> i & 1) {
if (cnt[i]) {
tot += cnt[i];
... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, a, b;
std::cin >> n >> a >> b;
std::string s;
std::cin >> s;
std::vector<char> alpha(n);
for (int i = 0; i < n; ++i) {
alpha[i] = s[i];
}
std::sort(alpha.begin... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX = 1 << 20;
bitset<MAX> dpgl, mv, dp[20];
map<char, int> to;
char rv[20];
int cnt[20], le[20], ri[20], n, A, B, b;
void solve(int ms) {
int L = 1e9, R = -1, tot = 0;
vector<int> tr, chr, oth;
for(int i = 0; i < b; i++) {
... | CPP |
1450_G. Communism | Please pay attention to the unusual memory limit in this problem.
In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient times.
The government has n workers standing in a row and numbered with integers from 1 to n from left to right. Th... | 2 | 13 | /*
This is code of SuperJ6 for Codeforces.
Don't copy my code during f*kin' contests.
2.71828182845904523536
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
#include <vector>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.