Skip to content
Snippets Groups Projects
Commit 80edd87b authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Standardize code

parent 22edf841
No related branches found
No related tags found
No related merge requests found
......@@ -27,13 +27,15 @@ int convex_hull(vector<dd> &v) {
// Uppermost part of convex hull
for (int i = 0; i < v.sz; ++i) {
while (k >= 2 && cross(v[ans[k - 2]], v[ans[k - 1]], v[i]) < 0) k--;
while (k >= 2 && cross(v[ans[k - 2]], v[ans[k - 1]], v[i]) < 0)
k--;
ans[k++] = i;
}
// Lowermost part of convex hull
for (int i = v.sz - 2, t = k + 1; i >= 0; --i) {
while (k >= t && cross(v[ans[k - 2]], v[ans[k - 1]], v[i]) < 0) k--;
while (k >= t && cross(v[ans[k - 2]], v[ans[k - 1]], v[i]) < 0)
k--;
ans[k++] = i;
}
......
......@@ -31,21 +31,22 @@ void dfs(int x) {
dfs(i);
low[x] = min(low[x], low[i]);
if ((parent[x] == -1 && child > 1) || (parent[x] != -1 && low[i] >= L[x]))
if ((parent[x] == -1 && child > 1) || (parent[x] != -1 &&
low[i] >= L[x]))
articulations.pb(x);
if (low[i] > L[x])
bridges.pb(ii(x, i));
} else if (parent[x] != i) {
} else if (parent[x] != i)
low[x] = min(low[x], L[i]);
}
}
}
// Applies tarjan algorithm and format articulations vector
void tarjan(int v) {
memset(parent, -1, sizeof parent);
mset(parent, -1);
dfs(v);
// Remove duplicates for articulations
......
......@@ -19,8 +19,9 @@ bool path(int s, int t) {
return true;
for (int i = 0; i < N; ++i)
if (!cont[i] and rg[s][i]) {
if (!cont[i] && rg[s][i]) {
par[i] = s;
if (path(i, t))
return true;
}
......
......@@ -15,7 +15,7 @@ int lis(vector<int> v) {
lis[i] = 1;
for (int j = 0; j < i; ++j)
if (v[i] > v[j] and lis[i] < lis[j] + 1)
if (v[i] > v[j] && lis[i] < lis[j] + 1)
lis[i] = lis[j] + 1;
}
......
......@@ -50,10 +50,10 @@ void update(int i, int j, int val, int node = 1, int a = 0, int b = N - 1) {
if (lazy[node] != 0)
push(node, a, b, lazy[node]);
if (a > b or a > j or b < i)
if (a > b || a > j || b < i)
return;
if (a >= i and b <= j) {
if (i <= a && b <= j) {
push(node, a, b, val);
return;
}
......@@ -72,7 +72,7 @@ int query(int i, int j, int node = 1, int a = 0, int b = N - 1) {
if (lazy[node])
push(node, a, b, lazy[node]);
if (a >= i and b <= j)
if (a >= i && b <= j)
return tree[node];
int q1 = query(i, j, left(node), a, (a + b) / 2);
......
......@@ -33,7 +33,7 @@ void build(int node = 1, int a = 0, int b = N - 1) {
// Update position idx with value val
void update(int idx, int val, int node = 1, int a = 0, int b = N - 1) {
if (a > b or a > idx or b < idx)
if (a > b || a > idx || b < idx)
return;
if (a == b) {
......@@ -49,10 +49,10 @@ void update(int idx, int val, int node = 1, int a = 0, int b = N - 1) {
// Return sum of [i,j]
int query(int i, int j, int node = 1, int a = 0, int b = N - 1) {
if (a > b or a > j or b < i)
if (a > b || a > j || b < i)
return 0;
if (i <= a and b <= j)
if (i <= a && b <= j)
return tree[node];
int q1 = query_tree(i, j, left(node), a, (a + b) / 2);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment