solution stringlengths 11 983k | difficulty int64 0 21 | language stringclasses 2
values |
|---|---|---|
#include <bits/stdc++.h>
using namespace std;
double a, b, c, a1, a2, mini;
int n, i, j;
int main() {
cin >> a >> b >> c;
if (!a && !b) {
if (!c)
cout << "-1";
else
cout << "0";
return 0;
}
if (!a) {
a1 = (-c) / b;
printf("1\n%lf", a1);
return 0;
}
if ((b * b < (4 * a * c... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
double a, b, c;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
scanf("%lf%lf%lf", &a, &b, &c);
if (a == 0) {
if (b == 0 && c == 0)
cout << -1;
else if (b == 0)
cout << 0 << endl;
else
printf("1\n%.10lf", -c / b);
} else {
... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
float a, b, c;
cin >> a >> b >> c;
float d = (b * b - 4 * a * c);
if (a == 0) {
if (b == 0) {
if (c == 0)
cout << -1 << endl;
else
cout << 0 << endl;
} else
cout << 1 << endl << fixed << setprecision(6) << -c / ... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c, d;
double x1, x2;
cin >> a >> b >> c;
if (a == 0) {
if (b == 0) {
if (c == 0)
cout << -1 << endl;
else
cout << 0 << endl;
} else
printf("1\n%f\n", -1 * c / b);
} else {
d = b * b - 4 * a * ... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
long double x = 0, y = 0, l = 0;
long long int a = 0, b, c;
int main() {
cin >> a >> b >> c;
x = (b * b) - (4 * a * c);
if (a == 0 && b == 0 && c == 0) {
cout << -1;
return 0;
}
if (a == 0 && b == 0) {
cout << 0;
return 0;
}
cout.precision(6);
... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c;
cin >> a >> b >> c;
long long DIS = (b * b) - (4 * a * c);
if ((a == 0 and b == 0 and c == 0))
cout << -1 << endl;
else if (DIS < 0 or (a == 0 and b == 0))
cout << 0 << endl;
else if (a == 0)
printf("1\n%.10lf\n", (dou... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
double a, b, c;
int main() {
while (scanf("%lf%lf%lf", &a, &b, &c) != EOF) {
double jd = b * b - 4 * a * c;
if (a == 0) {
if (b == 0)
printf("%d\n", c == 0 ? -1 : 0);
else
printf("1\n%.10lf\n", (double)-c / (double)b);
} else if (jd... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
while (~scanf("%lf%lf%lf", &a, &b, &c)) {
if (a == 0 && b == 0)
if (c == 0)
puts("-1");
else
puts("0");
else if (a == 0 && c == 0)
puts("1\n0");
else if (b == 0 && c == 0)
puts("1\n0");
... | 8 | CPP |
a, b, c = map(int, input().split())
t = [1, -c / b] if b else [-(c == 0)]
if a:
d, x = b * b - 4 * a * c, -2 * a
if d: t = [0] if d < 0 else [2] + sorted([(b - d ** 0.5) / x, (b + d ** 0.5) / x])
else: t = [1, b / x]
print(*t) | 8 | PYTHON3 |
from math import sqrt
a, b, c = map(int, input().split())
if a == 0 and b == 0:
if c == 0:
print(-1)
else:
print(0)
elif a == 0:
print(1)
print('{0:.10f}'.format(-(c/b)))
else:
delta = (b**2) - (4 * a * c)
if delta > 0:
print(2)
x1 = (-b + sqrt(delta)) / (2*a)
x2 = (-b - sqrt(delta)) ... | 8 | PYTHON3 |
import math
nl = list(input().split(' '))
a = int(nl[0])
b = int(nl[1])
c = int(nl[2])
if a == 0 and b == 0:
if c != 0:
print(0)
exit()
print(-1)
exit()
if a == 0:
print(1)
print("%10.5f" % (-c/b))
exit()
sqrt = b*b - 4*a*c
if sqrt == 0:
print(1)
print("%10.5f" % (-b/2/a))
elif sqrt < 0:
print(0)
else... | 8 | PYTHON3 |
from math import sqrt
a, b, c = map(int, input().split())
disc = b * b - 4 * a * c
if a == 0 and b == 0 and c == 0:
print(-1)
elif a == 0 and b == 0 or disc < 0:
print(0)
elif a == 0:
print(1)
# y = bx + c
# -c / b
print(-c / b)
elif disc == 0:
print(1)
print(-b / 2 / a)
else:
prin... | 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
bool SR(int &x) { return scanf("%d", &x) == 1; }
bool SR(long long &x) { return scanf("%lld", &x) == 1; }
bool SR(double &x) { return scanf("%lf", &x) == 1; }
bool SR(char *s) { return scanf("%s", s) == 1; }
bool RI() { return true; }
template <typename I, typename... T>
bo... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF32 = INT_MAX;
const ll INF64 = ((ll)INF32 << 29ll);
void reflex() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
}
signed main() {
reflex();
using ld = long double;
ld a, b, c... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
double a, b, c;
int main() {
cin >> a >> b >> c;
if (a == 0 && b == 0 && c == 0) {
cout << "-1" << endl;
return 0;
}
if (a == 0) {
if (b == 0)
cout << "0" << endl;
else {
cout << "1" << endl;
double x = -c / b;
cout.precision(... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c, det, x1, x2;
while (scanf("%lf%lf%lf", &a, &b, &c) != EOF) {
if (a == 0 && b == 0) {
if (c == 0)
puts("-1");
else
puts("0");
continue;
}
if (a == 0) {
x1 = -1.0 * c / b;
if (x1 == -0.... | 8 | CPP |
import sys
import collections
import random
sys.setrecursionlimit(30000)
def main():
a,b,c = [float(it) for it in input().split()]
if a == 0:
if b == 0:
if c == 0:
sys.stdout.write('-1 \n')
else:
sys.stdout.write('0 \n')
else:
... | 8 | PYTHON3 |
from math import sqrt
a,b,c = map(int,input().split())
if a==0 and b == 0:
if c == 0:
print("-1")
else:
print("0")
elif a == 0 :
if c == 0:
print(1)
print("{:.5f}".format(c))
else:
x = -1*c/b
print('1')
print ("{:.5f}".format(x))
elif b == 0 :
... | 8 | PYTHON3 |
a,b,c=map(int,input().split())
if a:
d=b**2-4*a*c
if d<0:
ans=[0]
elif d==0:
ans=[1,-b/(2*a)]
else:
ans=[2]+sorted([-(b-d**0.5)/(2*a),-(b+d**0.5)/(2*a)])
else:
if b:
ans=[1, -c/b]
else:
if c:
ans=[0]
else:
ans=[-1]
print(*an... | 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
inline long long int max(long long int a, long long int b, long long int c) {
return max(max(a, b), c);
}
inline long long int min(long long int a, long long int b, long long int c) {
return min(min(a, b), c);
}
inline long long int max(long long int a, long long int b)... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
cin >> a >> b >> c;
double d = pow(b, 2.0) - 4.0 * a * c;
if (d < 0 || a == 0 && b == 0 && c != 0) {
cout << 0 << "\n";
return 0;
} else if (a == 0 && b == 0 && c == 0) {
cout << -1 << "\n";
return 0;
} else if (a == ... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
double a, b, c;
cin >> a >> b >> c;
if (a == 0 && b == 0) {
if (c == 0) {
cout << -1 << endl;
} else {
cout << 0 << endl;
}
return 0;
}
if (a == 0) {
cout << 1 << endl;
printf("%.6f\n", 0... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int TestMillerRabin[12] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};
long long mulmod(long long a, long long b, long long p) {
long long x = 0, y = a % p;
while (b > 0) {
if (b % 2 == 1) x = (x + y) % p;
y = (1LL * y * 2) % p;
b = b / 2;
}
return x % ... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
cin >> a >> b >> c;
if (a == 0) {
if (b == 0) {
if (c == 0) {
printf("-1");
} else {
printf("0");
}
} else {
printf("1\n%f", -c / b);
}
} else {
if (b * b - 4 * a * c < -1E-6) {
... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
double x[3];
cin >> a >> b >> c;
if (a == 0 && b == 0 && c == 0) {
cout << "-1" << endl;
return 0;
}
if (a == 0 && b == 0) {
cout << "0" << endl;
return 0;
}
if (a == 0) {
cout << "1" << endl;
cout << fixe... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c, det, x1, x2;
cout.precision(15);
cin >> a >> b >> c;
det = b * b - 4 * a * c;
if (a == 0 && b == 0 && c == 0)
cout << -1;
else if (a == 0 && b == 0 || det < 0)
cout << 0;
else if (a == 0)
cout << 1 << endl << -c / b;
... | 8 | CPP |
#include <bits/stdc++.h>
int main() {
double a, b, c;
scanf("%lf %lf %lf", &a, &b, &c);
if (a == 0) {
if (b == 0) {
puts(c ? "0" : "-1");
} else {
printf("1\n%.6lf\n", -c / b);
}
} else {
if (a < 0) {
a = -a;
b = -b;
c = -c;
}
double d = b * b - 4 * a * c;
... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
cin >> a >> b >> c;
double f;
if (a == 0 && b == 0) {
if (c == 0)
cout << "-1" << endl;
else
cout << "0" << endl;
} else if (a == 0 && c == 0) {
cout << "1" << endl;
cout << fixed << setprecision(8) << 0.0 <... | 8 | CPP |
#include <bits/stdc++.h>
int main() {
long long a, b, c, d;
scanf("%lld %lld %lld", &a, &b, &c);
if (a == 0 && b == 0 && c == 0) {
printf("-1");
return 0;
}
if (a == 0 && b == 0) {
printf("0");
return 0;
}
d = b * b - 4 * a * c;
if (d < 0) {
printf("0");
return 0;
}
if (a == ... | 8 | CPP |
a,b,c=map(int,input().split())
dis=b*b-4*(a)*(c)
if(a==0):
if(b==0):
if(c==0):
print(-1)
else:
print(0)
else:
print(1)
print(-c/b)
else:
if(dis==0):
print(1)
print((-b+dis**(0.5))/(2*a))
else:
if(dis<0):
print(0... | 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
double a, b, c;
cin >> a >> b >> c;
if (a == 0 && b == 0 && c == 0) {
cout << -1;
return 0;
} else if (a == 0 && b == 0) {
cout << 0;
return 0;
}
if (a == 0) {
cout << 1 << endl... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
float a, b, c, zero = 0, count = 0;
cin >> a >> b >> c;
if (a != 0) {
float z = (b * b) - (4 * a * c);
if (z > -1) {
if (b == 0 && c == 0) {
cout << 1 << endl << setprecision(10) << fixed << 0 << endl;
return 0;
} else ... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
void SieveOfEratosthenes(long long n) {
bool prime[n + 1];
memset(prime, true, sizeof(prime));
for (long long p = 2; p * p <= n; p++) {
if (prime[p] == true) {
for (long long i = p * p; i <= n; i += p) prime[i] = false;
}
}
}
long long power(long long ... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
double a, b, c;
int main() {
cin >> a >> b >> c;
if (a == 0) {
if (b == 0) {
if (c == 0)
cout << -1;
else
cout << 0;
} else {
cout << 1 << endl;
double x = -c / b;
printf("%.8f", x);
}
} else {
double D = b... | 8 | CPP |
from math import sqrt
x = input()
y = x.split()
a = int(y[0])
b = int(y[1])
c = int(y[2])
det = b**2-4*a*c
if a ==0:
if b!=0:
print(1)
print(-c/b)
if b==0:
if a*c<0:
print(2)
print(-sqrt(-c/a))
print(sqrt(-c/a))
if det <0:
print(0)
if det ==0:
if a==0... | 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
double f = 0, g = 0, i = 0;
cin >> a >> b >> c;
f = ((-1 * b + sqrt((b * b) - (4 * a * c))) / (2 * a));
g = ((-1 * b - sqrt((b * b) - (4 * a * c))) / (2 * a));
i = ((-1 * c) / b);
if (a == 0 && b != 0) {
cout << 1 << endl << fi... | 8 | CPP |
a, b, c = map(int, input().split())
def quadroot(a, b, c):
roots = []
negb = -1*b
discriminant = (b**2 - 4*a*c)**(1/2)
bottom = 2*a
roots.append(format((negb - discriminant) / (bottom), ".6f"))
roots.append(format((negb + discriminant) / (bottom), ".6f"))
return roots
if a == 0 and b == 0 ... | 8 | PYTHON3 |
class CodeforcesTask20BSolution:
def __init__(self):
self.result = ''
self.a_b_c = []
def read_input(self):
self.a_b_c = [int(x) for x in input().split(" ")]
def process_task(self):
if not self.a_b_c[0]:
if not self.a_b_c[1]:
if not self.a_b_c[2]... | 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
double A, B, C;
double d, x1, x2;
cin >> A >> B >> C;
cout << fixed << setprecision(10);
if (A == 0) {
if (B == 0) {
if (C == 0) {
cout << -1;
} else {
cout << 0;
}
} else {
cout << 1 << endl;
cout... | 8 | CPP |
a1,a2,a3=input("").split()
a= int(a1)
b = int(a2)
c= int(a3)
d =b*b - (4*a*c)
if a==0 and b==0 and c==0:
print("-1")
elif d < 0 or d>0 or d==0:
if d>0 and a!=0:
r1 = (-b+(d**0.5))/(2*a)
r2 = (-b-(d**0.5))/(2*a)
mi = min(r1,r2)
ma = max(r1,r2)
print("2")
print(("{0... | 8 | PYTHON3 |
import math
a,b,c = map(int,input().split(' '))
def root(a,b,c):
d = (b**2) - (4*a*c)
if d == 0:
#Equal Root
x = (-b)/(2*a)
print(1)
print("%.10f"%x)
elif d > 0:
#real root
x = ((-b)+math.sqrt(d))/(2*a)
y = ((-b)-math.sqrt(d))/(2*a)
print(2)
if x > y:
print("%.10f"%y)
print("%.10f"%x)
els... | 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
double A, B, C;
double eps = 1e-9;
cin >> A >> B >> C;
double D = B * B - 4.0 * A * C;
if (fabs(A) < eps) {
if (fabs(B) < eps) {
if (fabs(C) < eps)
cout << "-1";
else
cout << "0";
} else {
... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long delta(long long a, long long b, long long c) {
return b * b - 4 * a * c;
}
int main() {
long long a, b, c;
scanf("%I64d%I64d%I64d", &a, &b, &c);
if (a == 0 && b == 0 && c == 0) {
puts("-1");
return 0;
} else if (a == 0 && b == 0 && c != 0) {
... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
double delta(long long a, long long b, long long c) {
long long res = 0;
res = b * b - 4 * a * c;
return res;
}
int main() {
int n;
double a, b, c;
double r1, r2;
cin >> a >> b >> c;
if (a == 0) {
n = (b == 0) ? 0 : 1;
r1 = (b == 0) ? 0 : -c / b;
... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
scanf("%lf%lf%lf", &a, &b, &c);
if (a == 0 && b == 0 && c == 0)
printf("-1\n");
else if (a == 0 && b == 0 && c)
printf("0\n");
else if (a == 0)
printf("1\n%.10lf\n", -c / b);
else if (b == 0) {
if (c < 0) printf("2\n%... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
const long double EPS = (long double)1e-7;
const long double PI = acos(0) * 2;
bool isZero(const long double& x) { return abs(x) <= EPS; }
int sign(const long double& x) { return isZero(x) ? 0 : (0 < x ? 1 : -1); }
long long gcd(long long a, long long b) {
for (; b; a %= ... | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c;
double res1, res2;
cin >> a >> b >> c;
if (a == 0) {
if (b == 0) {
if (c == 0)
cout << "-1\n";
else
cout << "0\n";
} else {
cout << "1\n";
cout << fixed << setprecision(10) << (-c / b) << e... | 8 | CPP |
a, b, c = map(int, input().split())
d = b * b - 4 * a * c
if not a:
if not b:
if not c: print(-1)
else: print(0)
else: print(1) or print(-c/b)
else:
if d < 0: print(0)
elif not d: print(1) or print((-b + d ** 0.5) / 2 / a)
else: print(2) or print(min((-b - d ** 0.5) / 2 / a, (-b + d ** 0.5) / 2 / a)) ... | 8 | PYTHON3 |
#include <bits/stdc++.h>
struct edge {
int to;
edge* next;
} E[6010], *ne = E, *first[3010];
void link(int a, int b) {
*ne = (edge){b, first[a]};
first[a] = ne++;
}
int C[3010], cnt;
bool tag[3010];
int dfs1(int i, int f) {
int t;
tag[i] = 1;
for (edge* e = first[i]; e; e = e->next)
if (e->to != f) {
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int vi[3005], cir;
int ori[3005][3005];
int sccl[3005][3005];
vector<int> s[3005], scc[3005], g[3005];
stack<int> sta;
int dfs_cnt = 0, pre[3005] = {0}, sccno[3005] = {0}, scc_cnt = 0;
int dfs(int u, int fa) {
int lowu, lowv, i;
lowu = pre[u] = ++dfs_cnt;
sta.push(u);... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int inf = ~0U >> 1;
const long long INF = ~0ULL >> 1;
;
int n, x, y, cnt[4000], vis[4000], circle[4000], Cnt, top;
double ans;
vector<int> E[4000];
void check(int S, int u, int dis) {
vis[u] = 1;
for (int i = (0); i < (E[u].size()); ++i)
if (!vis[E[u][i]])
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
double ans;
int d[3005], lp[3005], bl[3005], vst[3005], lc[3005][3005], dep[3005], cnt,
fa[3005], pos[3005];
vector<int> son[3005];
queue<int> q;
void dfs(int now) {
vst[lp[pos[now] = ++cnt] = now] = 2;
for (int T, i = 0; i < son[now].size(); ++i)
if (!vst[T = s... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void in(T &x) {
x = 0;
short f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') x = x * 10 + (c ^ '0'), c = getchar();
x *= f;
}
template <class T>
inlin... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
vector<int> to[N];
int f[N][15], st[N], top, cir[N], dep[N], col[N], n, cnt, siz, vis[N], oncir[N];
void add(int a, int b) {
to[a].push_back(b);
to[b].push_back(a);
}
int find(int now, int fa) {
if (vis[now]) {
int v;
do {
v = st[top-... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
namespace _buff {
const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
if (ib == ie) {
ib = ibuf;
ie = ibuf + fread(ibuf, 1, BUFF, stdin);
}
return ib == ie ? -1 : *ib++;
}
} // namespace _buff
LL read() {
... | 10 | CPP |
#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, ind[maxn];
int cirr[maxn];
bool vis[maxn];
int dis[maxn][maxn];
bool vis2[maxn][maxn];
void... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
static const int maxn = 3000 + 5;
static const int maxm = 6000 + 5;
static int n, c;
static int suf[maxn], pre[maxm], tar[maxm], e;
static int vis[maxn], dep[maxn], dis[maxn];
static int deg[maxn], que[maxn], head, tail;
static double ans;
inline int read() {
int k = 0, f... | 10 | CPP |
#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... | 10 | CPP |
#include <bits/stdc++.h>
const int N = 3e3 + 10;
int n, vis[N], px, py, dep[N], fa[12][N], id[N], flag[N], lg[N];
std::vector<int> e[N], x, y;
int main() {
scanf("%d", &n);
for (int i(2); i < N; ++i) {
lg[i] = lg[i / 2] + 1;
}
for (int i(1), x, y; i <= n; ++i) {
scanf("%d %d", &x, &y);
++x;
++y;... | 10 | CPP |
#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], dep[N], dis[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];
h... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
inline bool SR(int &x) { return scanf("%d", &x) == 1; }
inline bool SR(long long &x) { return scanf("%lld", &x) == 1; }
inline bool SR(double &x) { return scanf("%lf", &x) == 1; }
inline bool SR(char *s) { return scanf("%s", s) == 1; }
inline bool RI() { return true; }
temp... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
struct Edge {
int nxt, to;
} e[6005];
int hd[3005], e_cnt;
void add(int u, int v) {
e[++e_cnt] = (Edge){hd[u], v};
hd[u] = e_cnt;
}
int n, dia[3005], dia_cnt, rec[3005];
double ans;
bool vis[3005];
void dfs1(int u, int r, int dep) {
vis[u] = true;
rec[dep] = u;
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int n;
struct Edge {
int to, next;
};
const int maxn = 6060;
Edge e[maxn];
int st[maxn], tot = -1;
void add(int u, int v) {
e[++tot].to = v;
e[tot].next = st[u];
st[u] = tot;
}
bool vis[3030], cir[maxn];
int fa[maxn], dep[maxn], C;
void prep(int now) {
for (int i ... | 10 | CPP |
#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... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
struct Edge {
int to, next;
} e[6060];
int point[3030], te = 1;
void addE(int st, int ed) {
te++;
e[te].to = ed;
e[te].next = point[st];
point[st] = te;
}
int ind[3030];
queue<int> q;
int ter, cir;
int vis[3030], dis[3030], dis2[3030];
double ans;
void dfs(int now... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read(register T& t) {
register T f = 1;
register char ch = getchar();
t = 0;
while (ch < '0' || ch > '9') {
if (ch == '-') f = -f;
ch = getchar();
}
while (ch >= '0' && ch <= '9') t = t * 10 + ch - '0', ch = getchar();
t ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x20202020;
const int mod = 1000000007;
template <class T>
inline void read(T& x) {
bool fu = 0;
char c;
for (c = getchar(); c <= 32; c = getchar())
;
if (c == '-') fu = 1, c = getchar();
for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0';... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
template <class t>
ostream &operator<<(ostream &tout, const vector<t> &s) {
tout << '[';
for (int i = 0; i < s.size(); i++)
if (i + 1 == s.size())
tout << s[i];
else
tout << s[i] << ',';
tout << ']';
return (tout);
}
template <class a, class b>
o... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T min(T &a, T &b) {
return a < b ? a : b;
}
template <class T>
inline T max(T &a, T &b) {
return a > b ? a : b;
}
template <class T>
void read(T &x) {
char ch;
while ((ch = getchar()) && !isdigit(ch))
;
x = ch - '0';
while ((ch = ge... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 100;
const int inf = 0x3f3f3f3f;
const int iinf = 1 << 30;
const long long linf = 2e18;
const long long mod = 998244353;
const double eps = 1e-7;
template <class T = int>
T read() {
T f = 1, a = 0;
char ch = getchar();
while (!isdigit(ch)) {
... | 10 | CPP |
#include <bits/stdc++.h>
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("popcnt")
using namespace std;
int stk[3010], n, top = 0;
long double ans = 0;
bool in[3010], loop[3010], found = false;
vector<int> nxt[3010];
vector<pair<int, int> > vec[3010];
template <class T>
void read... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int n;
struct edge {
int v;
int next;
edge() {}
edge(int v, int next) : v(v), next(next) {}
} e[6004];
int ind[3004];
bool vzt[3004];
int stk[3004];
int top, newedge;
int circle_len;
bool oncircle[3004];
int d[3];
int path_on_circle;
double ans;
void addedge(int u, ... | 10 | CPP |
#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... | 10 | CPP |
#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... | 10 | CPP |
#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... | 10 | CPP |
#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... | 10 | CPP |
#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... | 10 | CPP |
#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[++... | 10 | CPP |
#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... | 10 | CPP |
#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... | 10 | CPP |
#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] = ... | 10 | CPP |
#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 >... | 10 | CPP |
#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... | 10 | CPP |
#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[... | 10 | CPP |
#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) {
... | 10 | CPP |
#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... | 10 | CPP |
#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 ... | 10 | CPP |
#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;... | 10 | CPP |
#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... | 10 | CPP |
#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... | 10 | CPP |
#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... | 10 | CPP |
#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 ... | 10 | CPP |
#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... | 10 | CPP |
#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 ... | 10 | CPP |
#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... | 10 | CPP |
#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 &... | 10 | CPP |
#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]... | 10 | CPP |
#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... | 10 | CPP |
#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;
... | 10 | CPP |
#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++;... | 10 | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.