text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
struct _ {
ios_base::Init i;
_() {
cin.sync_with_stdio(0);
cin.tie(0);
}
} _;
vector<bool> isOnC;
struct Edge {
int a, b;
};
int t, k;
int n;
int temp = -1;
int cLength = 0;
vector<bool> isMarked;
vector<vector<int> > e;
vector<vector<int> > dist;
double sum... |
#include <bits/stdc++.h>
using namespace std;
inline long long rd() {
long long _x = 0;
int _ch = getchar(), _f = 1;
for (; !isdigit(_ch) && (_ch != '-') && (_ch != EOF); _ch = getchar())
;
if (_ch == '-') {
_f = 0;
_ch = getchar();
}
for (; isdigit(_ch); _ch = getchar()) _x = _x * 10 + _ch - '0... |
#include <bits/stdc++.h>
using namespace std;
const int maxN = 3000 + 5;
int n;
vector<int> G[maxN];
vector<int> loop;
int no[maxN];
bool vis[maxN];
int stk[maxN], len = 0;
bool DFS(int u, int fa) {
stk[len++] = u;
vis[u] = true;
for (int v : G[u])
if (v != fa) {
if (vis[v]) {
do {
len... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void rd(T &x) {
char ch;
x = 0;
bool fl = false;
while (!isdigit(ch = getchar())) (ch == '-') && (fl = true);
for (x = (ch ^ '0'); isdigit(ch = getchar()); x = x * 10 + (ch ^ '0'))
;
(fl == true) && (x = -x);
}
template <class T>
in... |
#include <bits/stdc++.h>
using namespace std;
int n, tot;
const int N = 3005;
int head[N], to[N << 1], nt[N << 1];
inline int read() {
int res = 0;
char ch = getchar();
bool XX = false;
for (; !isdigit(ch); ch = getchar()) (ch == '-') && (XX = true);
for (; isdigit(ch); ch = getchar()) res = (res << 3) + (res... |
#include <bits/stdc++.h>
using namespace std;
int n, tot, top, cnt;
int head[3100], nex[3100 << 1], to[3100 << 1];
int st[3100], deep[3100], cir[3100], inc[3100];
double ans;
vector<int> vec[3100];
void add(int x, int y) {
tot++;
nex[tot] = head[x];
head[x] = tot;
to[tot] = y;
}
void dfs(int x, int y) {
st[++... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
struct Edge {
int src, dst, rev;
int weight;
Edge(int src, int dst, int weight = 1, int rev = -1)
: src(src), dst(dst), weight(weight), rev(rev) {}
};
bool operator<(const Edge &e, const Edge &f) {
return e.weight != f.weight ? e.we... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3003;
int n, L, top, cir[N], stk[N], cnt[N], bel[N], dep[N], fa[N];
double ans;
vector<int> nxt[N];
void dfs(int u, int lst) {
dep[u] = dep[lst] + 1, fa[u] = lst;
for (auto v : nxt[u])
if (v != lst) {
if (!dep[v])
dfs(v, u);
else if... |
#include <bits/stdc++.h>
using namespace std;
int p[6010], n1[6010], h[6010], ee = 0, n;
int pre[6010], cir[6010], iscir[6010], cirtot = 0, tmp[6010], id[6010],
bl[6010], d[6010];
bool vis[3010][3010];
double ans = 0;
void ae(int x, int y) {
p[ee] = y;
n1[ee] = h[x];
h[x] = ... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read() {
register T sum = 0;
register char cc = getchar();
int sym = 1;
while (cc != '-' && (cc > '9' || cc < '0')) cc = getchar();
if (cc == '-') sym = -1, cc = getchar();
sum = sum * 10 + cc - '0';
cc = getchar();
while (cc >... |
#include <bits/stdc++.h>
using namespace std;
int head[3010];
int from[3010];
int to[6010];
int nex[6010];
int dep[3010];
int q[3010];
int cnt;
int vis[3010];
int bel[3010];
double ans;
int tot;
int x, y, n;
int f[3010][15];
void add(int x, int y) {
nex[++tot] = head[x];
head[x] = tot;
to[tot] = y;
}
bool dfs(int... |
#include <bits/stdc++.h>
int fr[3010], ne[6010], v[6010], bs = 0;
void addb(int a, int b) {
v[bs] = b;
ne[bs] = fr[a];
fr[a] = bs++;
}
int bk[3010], sd[3010], hu[3010], fa[3010], sl = 0;
void dfs1(int u, int f) {
bk[u] = 1;
fa[u] = f;
sd[u] = sd[f] + 1;
for (int i = fr[u]; i != -1; i = ne[i]) {
if (v[... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3010;
double ans = 0;
int n, l[maxn], e = 0;
int deg[maxn], dep[maxn], a[maxn], tot;
vector<int> sub[maxn], son[maxn];
struct Edge {
int v, x;
} E[maxn << 1];
inline void addEdge(int u, int v) { E[e].v = v, E[e].x = l[u], l[u] = e++; }
void dfs(int u) {
... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3005;
struct Node {
int to, id;
Node() = default;
Node(int a, int b) : to(a), id(b) {}
};
vector<Node> v[MAXN];
int vis[MAXN], st[MAXN], tt, flag;
int siz[MAXN], dep[MAXN], fa[MAXN];
int top[MAXN], son[MAXN], col[MAXN];
inline int read() {
int x = 0... |
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> depc[3300];
vector<int> adj[3300];
int dep[3300], pos[3300], fa[3300], subsz[3300];
vector<int> st, cycle;
double comprob(int cycleA, int cycleB, int tree1, int tree2) {
return 2.0 / (cycleA + tree1 + tree2 + 1) +
2.0 / (cycleB + tree1 + tree2 ... |
#include <bits/stdc++.h>
using namespace std;
const int MXN = 100005;
int N, loid[MXN], islolo[MXN];
int bln[MXN], dep[MXN];
vector<int> E[MXN];
vector<int> lolo;
int ins[MXN];
vector<int> stk;
long double ans;
bool DFS1(int u, int f) {
ins[u] = 1;
stk.push_back(u);
for (auto v : E[u]) {
if (v == f) continue;... |
#include <bits/stdc++.h>
using namespace std;
struct node {
int t, n;
} e[11000];
int fi[11000], di[11000], q[11000];
bool used[11000], in[11000];
int n, tot, len;
double ans;
inline void insert(const int& x, const int& y) {
e[++tot] = (node){y, fi[x]}, fi[x] = tot;
}
void dfs(int x, int l1, int l2) {
used[x] = t... |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
using namespace std;
namespace _c {
const double pi = acos(-1.0);
namespace min {
const int i8 = -128;
const int i16 = -32768;
const... |
#include <bits/stdc++.h>
using namespace std;
vector<int> v[3005];
bool vis[3005], cir[3005];
int q, s, n;
int Find_Cir(int x, int y) {
vis[x] = 1;
for (int i = 0; i < v[x].size(); i++)
if (!vis[v[x][i]]) {
int t = Find_Cir(v[x][i], x);
if (t) {
if (t > 0) {
cir[x] = 1;
s... |
#include <bits/stdc++.h>
using std::cerr;
using std::endl;
const int N = 3005;
int n, dep[N], stk[N], top, on[N];
int circle_size;
double ans;
std::vector<int> G[N];
bool find_circle(int x, int fa) {
dep[x] = dep[fa] + 1;
stk[++top] = x;
for (int y : G[x]) {
if (y == fa) continue;
if (!dep[y]) {
if ... |
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 3010;
struct Edge {
int to, nxt;
} edge[Maxn << 1];
int anc[12][Maxn];
int fa[Maxn];
int first[Maxn];
int ring[Maxn];
int dep[Maxn];
int tree[Maxn];
int te = 1, n, tp;
int ringlen, ban1, ban2;
int ringst;
void adde(int x, int y) {
edge[++te] = Edge{y, f... |
#include <bits/stdc++.h>
using namespace std;
const int inf = ~0U >> 1;
const long long INF = ~0LLU >> 1;
int rd() { return RAND_MAX == 32767 ? ((rand() << 15) ^ rand()) : rand(); }
template <class T>
void Read_T(T &x) {
char ch;
while ((ch = getchar()) && (ch < '0' || ch > '9'))
;
x = ch - '0';
while ((ch ... |
#include <bits/stdc++.h>
using namespace std;
int n;
int cnt = 0, st[3010] = {0};
struct line {
int to, next;
} a[6010];
inline void add(int &x, int &y) {
a[++cnt].to = y;
a[cnt].next = st[x];
st[x] = cnt;
}
int vis[3010], check = 0, st_p, cir_size;
stack<int> ge;
void dfs(int x, int fa) {
ge.push(x);
vis[x... |
#include <bits/stdc++.h>
using namespace std;
void Get_Val(int &Ret) {
Ret = 0;
char ch;
while (ch = getchar(), ch > '9' || ch < '0')
;
do {
(Ret *= 10) += ch - '0';
} while (ch = getchar(), ch >= '0' && ch <= '9');
}
const int Max_N(3050);
namespace UFS {
int Father[Max_N];
int Get_Father(const int &... |
#include <bits/stdc++.h>
using namespace std;
int n, x, y, pa[3333], rt[3333], dep[3333], dist[3333], len, pos[3333];
vector<int> g[3333], cycle;
bool used[3333], f, in_cycle[3333];
double ans, a, b, c, d;
void dfs(int i, int fa) {
used[i] = 1;
pa[i] = fa;
for (int j = 0; j < g[i].size(); j++) {
int to = g[i]... |
#include <bits/stdc++.h>
using namespace std;
int n, rt, bel[3100], dis[3100];
int cnt, q[3100], num[3100], fa[3100];
bool flag, vis[3100];
int edgenum, vet[6100], Next[6100], Head[3100];
double ans;
void addedge(int u, int v) {
vet[++edgenum] = v;
Next[edgenum] = Head[u];
Head[u] = edgenum;
}
void getcycle(int u... |
#include <bits/stdc++.h>
using namespace std;
int n;
double p[3010][3010];
vector<int> v[3010], cycle;
bool vis[3010], oncycle[3010];
int stk[3010], top = 0, dep[3010];
void dfs1(int np, int fath) {
if (!cycle.empty()) return;
vis[np] = 1;
stk[++top] = np;
for (int &x : v[np]) {
if (x == fath) continue;
... |
#include <bits/stdc++.h>
using namespace std;
int entry[3005], low[3005], n, tme = 1, scc[3005], sp[3005], sp2[3005], cycle,
cnt, cc;
vector<int> myvec[3005], ans;
bool bridges[3005][3005];
double prob, ret;
queue<int> q;
int dfs(int x, int p) {
int i, j, k;
low[x] = entry[x] = tme++;... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
struct edge {
int to, next;
} e[N * 2];
int head[N], tot;
int vis[N], q[N], V;
int deg[N], n, sz;
double ans;
void add(int x, int y) {
e[++tot] = (edge){y, head[x]};
head[x] = tot;
}
void dfs(int x, int A, int B) {
deg[x] == 2 ? B++ : A++;
vis[... |
#include <bits/stdc++.h>
char ch;
inline void read(int &x) {
x = 0;
ch = getchar();
while (ch <= 32) ch = getchar();
while (ch > 32) {
x = x * 10 + ch - 48;
ch = getchar();
};
};
int n;
struct edge {
edge *next;
int y;
};
edge *se[3005], e[3005 * 2], *etot = e;
inline void addedge(int x, int y) {
... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3010;
int n, inR[MAXN], dep[MAXN], jmp[13][MAXN];
int top, stk[MAXN], ins[MAXN], bl[MAXN], rt, ringo[MAXN];
vector<int> T[MAXN], Ring;
void dfs(int x, int fa) {
ins[stk[++top] = x] = 1;
for (int v : T[x])
if (v != fa) {
if (ins[v]) throw v;
... |
#include <bits/stdc++.h>
const int MAXN = 3000;
struct edge {
int to;
edge *nxt;
} edges[2 * MAXN + 5], *adj[MAXN + 5], *ecnt = edges;
void addedge(int u, int v) {
edge *p = (++ecnt);
p->to = v, p->nxt = adj[u], adj[u] = p;
p = (++ecnt);
p->to = u, p->nxt = adj[v], adj[v] = p;
}
bool vis[MAXN + 5], tag[MAXN... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 100005;
inline int read() {
int res, ok = 1;
char ch;
for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
if (ch == '-') ok = -1;
res = ch - '0';
for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar()... |
#include <bits/stdc++.h>
const int maxn = 3005;
const int maxm = 6005;
const int inf = 999999999;
struct edge {
int to, next;
};
int n;
edge e[maxm];
int head[maxn], tot;
int stn[maxn], stk[maxn], top = 1;
int cir[maxn], circ;
int cirr[maxn];
bool vis[maxn];
int dis[maxn][maxn];
bool vis2[maxn][maxn];
void dfs2(int u... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
vector<int> e[N];
double ans = 0;
int n, h, t, rt, tot, d[N], vis[N], q[N];
void dfs(int u, int a, int b) {
if (d[u] == 2)
++b;
else
++a;
vis[u] = rt;
if (b == tot)
ans += 1.0 / (a + 2);
else if (b <= 2)
ans += 1.0 / (a + b);
... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3005, mod = 1e9 + 7;
inline int read() {
int s = 0;
char ch = getchar();
while (!isdigit(ch)) ch = getchar();
while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar();
return s;
}
inline long long qpow(long long a, long long b) {
long long res = 1... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3005;
int To[MAXN * 2], Next[MAXN * 2], Final[MAXN], tot;
int Circle[MAXN], Deep[MAXN], Fa[MAXN][MAXN], Lst[MAXN], Top[MAXN], P[MAXN], N,
Up, Down;
void Link(int u, int v) { To[++tot] = v, Next[tot] = Final[u], Final[u] = tot; }
int Get(int a) { return ... |
#include <bits/stdc++.h>
using namespace std;
const int MX = 3500;
int N;
struct Edge {
int y, nx;
} E[MX << 1];
int H[MX], ec;
void Add(int x, int y) { E[++ec].y = y, E[ec].nx = H[x], H[x] = ec; }
int B[MX], dfn[MX], low[MX], dc;
int Cr[MX], Ic[MX], cc, stk[MX], tp;
void Tarjan(int x, int f) {
B[x] = 1, dfn[x] = l... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
struct _two {
int a, b;
} edge[N + N], p[N];
double ans;
int n, tot, num, pos, tnum;
int st[N], flag[N], stack[N], qu[N], tqu[N];
void Init() {
scanf("%d", &n);
int x, y;
tot = 1;
for (int i = 1; i <= n; i++) {
scanf("%d%d", &x, &y);
x+... |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
double ans;
int n, cnt,... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3333;
int n;
vector<int> g[N];
int inside[N];
int deg[N];
vector<int> dist0[N], dist1[N];
void dfs(int v, int d0, int d1) {
if (inside[v]) {
return;
}
dist0[v].push_back(d0);
dist1[v].push_back(d1);
inside[v] = 1;
for (int j = 0; j < (int)g[v].... |
#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);... |
#include <bits/stdc++.h>
using namespace std;
namespace Fread {
const int MAXN = 1 << 20;
char buffer[MAXN], *S, *T;
inline char getchar() {
if (S == T) {
T = (S = buffer) + fread(buffer, 1, MAXN, stdin);
if (S == T) return EOF;
}
return *S++;
}
} // namespace Fread
inline int read() {
int f = 1, x = 0... |
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> G[3005];
int stk[3005], tp, instk[3005];
vector<int> cyc;
int incyc[3005];
bool flag;
inline void findCycle(int u, int pa) {
stk[++tp] = u;
instk[u] = 1;
for (int i = 0; i < G[u].size(); ++i) {
int v = G[u][i];
if (v == pa) continue;
if ... |
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
const bool db = false;
vector<int> gr[3010];
double res;
int mark[3010], color;
int ds[3010], ds2[3010];
int deg[3010], n, m;
int Len;
void dfs(int v) {
mark[v] = 1;
for (int i = 0, sz = gr[v].size(); i < sz; ++i) {
int t... |
#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;
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res;
}
const int N = 3010;
vector<int> e[N], dis[N];
int q[N], n, u, ... |
#include <bits/stdc++.h>
using namespace std;
const int M = 3005;
vector<int> eg[M];
int n;
int fa[M], cnt[M], sz[M];
int getfa(int x) {
if (fa[x] == x) return x;
return fa[x] = getfa(fa[x]);
}
double ans;
int pl[M], psz;
int mark[M], TIM;
void dfs_jih_pre(int x) {
pl[psz++] = x;
mark[x] = TIM;
for (int i = 0... |
#include <bits/stdc++.h>
using namespace std;
struct node_ {
int v, next;
} node[6005];
int head[3005], e, fa[3005][14], gf[3005];
int bj[3005], bjj = 0;
bool b[3005];
void addnode(int u, int v) {
e++;
node[e].v = v;
node[e].next = head[u];
head[u] = e;
}
int flag = 0;
int n;
int dep[3005];
void dfs(int t, in... |
#include <bits/stdc++.h>
using namespace std;
int c[3050 * 2][2], ss = 1, h[3050][2], fi[3050], n, m, len;
bool b[3050], flag = false;
double ans;
inline int Read() {
int x = 0;
char y;
do y = getchar();
while (y < '0' || y > '9');
do x = x * 10 + y - '0', y = getchar();
while (y >= '0' && y <= '9');
retu... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool upmin(T &x, T y) {
return y < x ? x = y, 1 : 0;
}
template <typename T>
inline bool upmax(T &x, T y) {
return x < y ? x = y, 1 : 0;
}
const long double eps = 1e-11;
const long double pi = acos(-1);
const int oo = 1 << 30;
const long lon... |
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
char c, sg = 0;
while (c = getchar(), (c > '9' || c ... |
#include <bits/stdc++.h>
using namespace std;
struct bian {
int next, point;
} b[7000];
int p[4000], n, len, pd[4000], x[4000], s[4000], head, bo[4000], d[4000],
u[4000];
long double ans;
void ade(int k1, int k2) {
b[++len] = (bian){p[k1], k2};
p[k1] = len;
}
void add(int k1, int k2) {
ade(k1, k2);
ade(k2... |
#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
x = 0;
char c = getchar();
bool flag = false;
while (!isdigit(c)) {
if (c == '-') flag = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
if (flag) x = -x;
}
using name... |
#include <bits/stdc++.h>
using namespace std;
int lca[3005][3005];
int last[3005];
int cir[3005];
int lab[3005];
int par[3005];
int pre[6005];
int dep[3005];
int e[6005];
int f[3005];
int h[3005];
int n, m, cnt;
int find_cir(int x, int par, int cirst) {
int i;
h[x] = 1;
for (i = last[x]; i != 0; i = pre[i])
i... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3005, M = N << 1;
int n, tot, len, du[N], now[N], prep[M], son[M];
double ans;
void read(int &x) {
x = 0;
int f = 1;
char ch;
for (ch = getchar(); !isdigit(ch); ch = getchar())
if (ch == '-') f = -1;
for (; isdigit(ch); ch = getchar()) x = x * 10... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int NN = 3011;
inline int read() {
int t = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') f = (ch == '-') ? -1 : 1, ch = getchar();
while (ch >= '0' && ch <= '9') t = t * 10 + ch - '0', ch = getchar();
return t * f;
}
double... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3005;
int n, ai, bi;
vector<int> G[MAXN];
int deg[MAXN];
vector<pair<int, int> > C[MAXN];
int nxt(int i, int p) {
for (int j : G[i])
if (deg[j] == 2) {
if (j == p) continue;
return j;
}
return -1;
}
double prob(int d) { return 2.0 / ... |
#include <bits/stdc++.h>
using namespace std;
const int MXN = 100005;
int N, loid[MXN], islolo[MXN];
int bln[MXN], dep[MXN];
vector<int> E[MXN];
vector<int> lolo;
int ins[MXN];
vector<int> stk;
long double ans;
bool DFS1(int u, int f) {
ins[u] = 1;
stk.push_back(u);
for (auto v : E[u]) {
if (v == f) continue;... |
#include <bits/stdc++.h>
using namespace std;
int n, m, dep[5000], id[5000], cnt, sum, acc[5000], lca[3020][3020], f[5000];
int dfn[5000], low[5000], ist[5000], belong[5000], tot[5000], maxid;
double Ans;
stack<int> a;
vector<int> v[5000];
inline void tarjan(int x, int fa) {
dfn[x] = low[x] = ++cnt;
a.push(x);
is... |
#include <bits/stdc++.h>
using namespace std;
const int maxlog = 13;
const int maxn = 3003;
int n;
vector<int> g[maxn];
bool vis[maxn], mark[maxn];
int pos[maxn], cnt;
int dis[maxn], r[maxn], d[maxn][maxlog];
long double ans;
void go(int v, int u) {
if (mark[v]) return;
for (int i = 0; v != d[u][0]; i++) {
mark... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3000 + 3;
struct Edge {
int to, nxt;
} e[N << 1];
int n, cnt;
int hd[N], top, q[N], tail, cur[N], c[N], pos[N], belong[N], fa[N][13], dep[N];
bool vis[N], used[N];
long double ans;
inline void addedge(int x, int y) {
e[++top].to = y;
e[top].nxt = hd[x];
... |
#include <bits/stdc++.h>
using namespace std;
stack<int> st;
int head[333000], cnt, ins[333000], is[333000], c[333000], id[333000], le,
vis[333000], ntt[333000], s1[333000], s2[333000], s3[333000], s4[333000],
s5[333000], sth[2220000 * 5], lb[333000], len[333000], rev[333000], n, m, a,
b, ds[333000], mx1, v... |
#include <bits/stdc++.h>
using namespace std;
int head[5010];
int from[5010];
int to[100010];
int nex[100010];
int dep[5010];
int q[5010];
int cnt;
int vis[5010];
int bel[5010];
int num[100010];
double ans;
int tot;
int x, y, n, m;
int f[5010][17];
void add(int x, int y, int z) {
nex[++tot] = head[x];
head[x] = tot... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int n, fa[N], dfn[N], ord, mark[N], len, vis[N];
vector<int> G[N];
void dfs(int u) {
dfn[u] = ++ord;
for (auto& v : G[u])
if (v ^ fa[u]) {
if (!dfn[v]) {
fa[v] = u;
dfs(v);
} else if (dfn[v] < dfn[u]) {
for (in... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
using vec = vector<T>;
template <typename Iter>
ostream &_IterOutput_(ostream &o, Iter b, Iter e, const string ss = "",
const string se = "") {
o << ss;
for (auto it = b; it != e; it++) o << (it == b ? "" : ", ") << *it;
return... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3000 + 10;
namespace opt {
int N;
const int alp = 999, MOD = 1004535809;
static int a[MAXN], b[MAXN], w[MAXN], tmp[MAXN];
int Pow(int a, int b) {
int d = 1;
for (; b; d = (b & 1) ? (long long)d * a % MOD : d,
a = (long long)a * a % MOD, b /=... |
#include <bits/stdc++.h>
const int MAXN = 3005, MAXLOG = 15;
template <typename _T>
void read(_T &x) {
x = 0;
char s = getchar();
int f = 1;
while (s > '9' || s < '0') {
if (s == '-') f = -1;
s = getchar();
}
while (s >= '0' && s <= '9') {
x = (x << 3) + (x << 1) + (s - '0'), s = getchar();
}
... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3010;
const int MAXE = MAXN << 1;
int N;
int e[MAXE], enxt[MAXE], head[MAXN], ec;
void regi(int u, int v) {
e[++ec] = v;
enxt[ec] = head[u];
head[u] = ec;
}
int visId[MAXN];
vector<int> Loop, stk;
bool FindLoop(int ths, int prev) {
if (visId[ths] !=... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long Inf = 1e10;
const int N = 100005;
const int P = 1000000007;
int IN() {
int x = 0;
int f = 0, ch = 0;
for ((ch = getchar()); ch < 48 || ch > 57; (ch = getchar())) f = (ch == '-');
for (; ch >= 48 && ch <= 57; (ch = getchar()))
... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
struct E {
int to, next;
} mem[N << 1];
int n, x, y, num, h, t, c;
double ans;
int head[N], d1[N], d2[N], q[N];
bool vis[N];
void add(int x, int y) {
num++;
mem[num].to = y;
mem[num].next = head[x];
head[x] = num;
}
void init() {
int k, u;
... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
using vec = vector<T>;
template <typename Iter>
ostream &_IterOutput_(ostream &o, Iter b, Iter e, const string ss = "",
const string se = "") {
o << ss;
for (auto it = b; it != e; it++) o << (it == b ? "" : ", ") << *it;
return... |
#include <bits/stdc++.h>
using namespace std;
const int N = 4011;
namespace RikukiIX {
int n;
int xi, yi;
struct sumireko {
int to, ne;
} e[N << 1];
int he[N], ecnt;
void addline(int f, int t) {
e[++ecnt].to = t;
e[ecnt].ne = he[f];
he[f] = ecnt;
}
int sta[N], stp;
int vis[N];
int sp;
int onr[N], rnd[N], ra;
in... |
#include <bits/stdc++.h>
const int sz = 3010;
int vi[sz], low[sz], t;
int sta[sz], top = 0;
int con[sz], cir[sz];
std::vector<int> edge[sz], ed[sz];
void dfs(int x, int p) {
vi[x] = low[x] = ++t;
sta[top++] = x;
for (int k = 0; k < edge[x].size(); k++) {
int y = edge[x][k];
if (!vi[y]) dfs(y, x);
if (... |
#include <bits/stdc++.h>
using namespace std;
vector<int> E[3005];
int deg[3005], V[3005];
int sz;
double ans;
void dfs(int r, int i, int A, int B) {
deg[i] == 2 ? ++B : ++A;
V[i] = r;
if (B == sz)
ans += 1.0 / (A + 2);
else if (B <= 2)
ans += 1.0 / (A + B);
else
ans += 1.0 / (A + B) + 1.0 / (A + ... |
#include <bits/stdc++.h>
using namespace std;
int n, m, flag, sum, tot, dis[3001][3001], e[100001], nt[100001], hd[100001],
pa[100001], v[3001], d[3001], f[3001], sz[3001];
double ans;
void build(int x, int y) {
tot++;
e[tot] = y;
nt[tot] = hd[x];
hd[x] = tot;
}
void dfs(int x, int fa) {
int i, y;
if (v... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int q[N];
int fa[N], dep[N];
int n, co[N], dis[N];
vector<int> e[N];
double ans;
void dfs(int x) {
for (auto i : e[x])
if (i != fa[x]) {
if (!dep[i]) {
fa[i] = x;
dep[i] = dep[x] + 1;
dfs(i);
} else if (dep[i] < ... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005;
inline void read(int &x) {
x = 0;
int f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
x *= f;... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005;
int N, C, cnt, d[maxn], q[maxn], head[maxn], d1[maxn], d2[maxn];
double ans;
struct Data {
int next, to;
} data[maxn << 1];
bool vis[maxn];
void add(int x, int y) {
data[++cnt] = (Data){head[x], y};
head[x] = cnt;
}
void dfs(int x) {
vis[x] = ... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
x = 0;
bool f = 0;
char c = getchar();
for (; !isdigit(c); c = getchar())
if (c == '-') f = 1;
for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
if (f) x = -x;
}
template <typename F>
inline void write(F x, char... |
#include <bits/stdc++.h>
using namespace std;
vector<int> v[3005];
bool vis[3005], cir[3005];
int q, s, n;
int Find_Cir(int x, int y) {
vis[x] = 1;
for (int i = 0; i < v[x].size(); i++)
if (!vis[v[x][i]]) {
int t = Find_Cir(v[x][i], x);
if (t) {
if (t > 0) {
cir[x] = 1;
s... |
#include <bits/stdc++.h>
using namespace std;
int hed[3005], to[3005 << 1], nxt[3005 << 1], q[3005], cnt, tot;
bool in[3005], used[3005];
int n, deg[3005], C;
double ans;
void ins(int x, int y) {
nxt[++tot] = hed[x];
to[tot] = y;
hed[x] = tot;
}
void dfs(int x, int len, int lcn) {
used[x] = 1;
if (lcn <= 1)
... |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 3) + (x << 1) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
const int... |
#include <bits/stdc++.h>
std::set<std::pair<int, int> > set;
int head[3010], nxt[6010], b[6010], k, n, u, v, fa[3010], cnt, rt;
bool vis[3010];
long double ans;
void push(int s, int t) {
nxt[++k] = head[s];
head[s] = k;
b[k] = t;
}
void getloop(int x, int f) {
if (vis[x]) {
u = x, v = f;
return;
}
v... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
vector<int> g[N];
int n, cirLen, stk[N], top, vis[N], findCir, onCir[N];
double ans;
void dfs(int v, int p) {
stk[++top] = v;
vis[v] = 1;
for (int d : g[v])
if (d != p) {
if (!vis[d]) {
dfs(d, v);
if (findCir) return;
... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void ckmax(T& a, T b) {
if (b > a) a = b;
}
template <typename T>
void ckmin(T& a, T b) {
if (b < a) a = b;
}
struct _in {
const _in operator,(int& a) const {
a = 0;
char k = getchar();
int f = 1;
for (; !isdigit(k); k = getchar()... |
#include <bits/stdc++.h>
using namespace std;
const int MX = 3500;
int N;
struct Edge {
int y, nx;
} E[MX << 1];
int H[MX], ec;
void Add(int x, int y) { E[++ec].y = y, E[ec].nx = H[x], H[x] = ec; }
int B[MX], dfn[MX], low[MX], dc;
int Cr[MX], Ic[MX], cc, stk[MX], tp;
void Tarjan(int x, int f) {
B[x] = 1, dfn[x] = l... |
#include <bits/stdc++.h>
using namespace std;
int head[5010];
int from[5010];
int to[100010];
int nex[100010];
int dep[5010];
int q[5010];
int cnt;
int vis[5010];
int bel[5010];
int num[100010];
double ans;
int tot;
int x, y, n, m;
int f[5010][17];
void add(int x, int y, int z) {
nex[++tot] = head[x];
head[x] = tot... |
#include <bits/stdc++.h>
using namespace std;
queue<int> q;
int head[5009], tot, du[5009], n, cnt;
double ans;
int vis[5009];
inline int rd() {
int x = 0;
char c = getchar();
bool f = 0;
while (!isdigit(c)) {
if (c == '-') f = 1;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3333;
int n, m, a[N], b[N], c[N], d[N], f[N];
vector<int> v[N], h;
double ans, w[N];
int fnd(int x) {
if (f[x] == x) return x;
return f[x] = fnd(f[x]);
}
void dfs0(int u, int o) {
if (b[u]) return;
if (!b[o]) h.push_back(u);
b[u] = 1;
for (int i = ... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3000 + 10;
struct Graph {
int id, next;
} g[MAXN * 2];
int st[MAXN], dep[MAXN], fa[MAXN], bel[MAXN], n, lca[MAXN][MAXN], num[MAXN];
bool vis[MAXN];
vector<int> L;
void Add(int tot, int x, int y) {
g[tot].id = y, g[tot].next = st[x], st[x] = tot;
}
int f... |
#include <bits/stdc++.h>
struct Vertex {
bool vis;
int head, top, dist;
Vertex() : vis(false), head(0), top(0), dist(0) {}
} vertex[3005];
struct Edge {
int to, next;
Edge(int __to = 0, int __next = 0) : to(__to), next(__next) {}
} edge[6005];
int n, ptr, dist[3005][3005];
std::vector<int> circle;
void addEdg... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void rd(T &x) {
char ch;
x = 0;
bool fl = false;
while (!isdigit(ch = getchar())) (ch == '-') && (fl = true);
for (x = (ch ^ '0'); isdigit(ch = getchar()); x = x * 10 + (ch ^ '0'))
;
(fl == true) && (x = -x);
}
template <class T>
in... |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0;
char ch = getchar();
while (!isdigit(ch)) ch = getchar();
while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
return x;
}
int tot = 1;
int fir[3010], nex[3010 << 1], got[3010 << 1];
inline void AddEdge(int x, int y) {
nex[++... |
#include <bits/stdc++.h>
using namespace std;
int g() {
char ch;
bool f = 0;
while (!((ch = getchar() - 48) >= 0))
if (ch == -3) f = 1;
int v = ch;
while (((ch = getchar() - 48) >= 0)) v = v * 10 + ch;
return f ? -v : v;
}
const int Maxn = 3005;
vector<int> p[Maxn];
long double ans;
int n, R;
bool mark[... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int n, tot, fst[N], to[2 * N], nxt[2 * N], cir[N], pos[N], len, dep[N], fa[N],
subt[N], st[N], top, dis[N];
bool vis[N];
void addedge(int u, int v) {
nxt[++tot] = fst[u];
fst[u] = tot;
to[tot] = v;
nxt[++tot] = fst[v];
fst[v] = tot;
to[to... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int n;
double ans;
double inv[N];
struct Edge {
int ce;
int hd[N], nxt[N * 2], v[N * 2];
void ade(int x, int y) {
ce++;
nxt[ce] = hd[x];
v[ce] = y;
hd[x] = ce;
}
};
Edge T;
int lenc, tp;
int fa[N], dep[N], cir[N], lc[N], rc[N];
vo... |
#include <bits/stdc++.h>
using namespace std;
pair<int, int> it;
int n, f[3010], x, y, fa[3010], dep[3010], tot, L[3010], t, tmp[3010],
num[3010], belong[3010];
vector<int> E[3010];
int dis[3010][3010];
bool vis[3010];
queue<int> h;
void read(int &x) {
char ch = getchar();
int mark = 1;
for (; ch != '-' && (c... |
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = 1e-10;
inline int read() {
static char ch;
bool sgn = false;
while (ch = getchar(), ch < '0' || ch > '9')
if (ch == '-') sgn = true;
int res = ch - 48;
while (ch = getchar(), ch >= '0' && ch <= '9') res = res * ... |
#include <bits/stdc++.h>
using namespace std;
struct edge {
int to, next;
} e[6005];
int n, m, head[3005], d[3005], d2[3005], num, c;
bool ok[3005];
queue<int> q;
double ans;
inline void insert(int u, int v) {
e[++num].to = v;
e[num].next = head[u];
head[u] = num;
e[++num].to = u;
e[num].next = head[v];
h... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int n, stk[N], top, num[N], cyc[N], idx;
bool vis[N], instk[N], fl;
vector<int> v[N];
void dfs(int pos, int fa) {
stk[++top] = pos;
instk[pos] = 1;
for (auto &i : v[pos]) {
if (i == fa) continue;
if (!instk[i]) return dfs(i, pos);
if (f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.