From 80edd87bfc174684678cf22175eef9d7243ce3db Mon Sep 17 00:00:00 2001
From: Bruno Freitas Tissei <bft15@inf.ufpr.br>
Date: Fri, 22 Feb 2019 22:17:41 -0300
Subject: [PATCH] Standardize code

Signed-off-by: Bruno Freitas Tissei <bft15@inf.ufpr.br>
---
 algorithms/geometry/convex_hull.cpp        | 6 ++++--
 algorithms/graph/articulations_bridges.cpp | 9 +++++----
 algorithms/graph/ford_fulkerson.cpp        | 3 ++-
 algorithms/paradigm/lis.cpp                | 2 +-
 algorithms/structure/lazy_segment_tree.cpp | 6 +++---
 algorithms/structure/segment_tree.cpp      | 6 +++---
 6 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/algorithms/geometry/convex_hull.cpp b/algorithms/geometry/convex_hull.cpp
index f1c1109..0ebd65e 100644
--- a/algorithms/geometry/convex_hull.cpp
+++ b/algorithms/geometry/convex_hull.cpp
@@ -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;
   }
 
diff --git a/algorithms/graph/articulations_bridges.cpp b/algorithms/graph/articulations_bridges.cpp
index 73c9b6e..a2b780a 100644
--- a/algorithms/graph/articulations_bridges.cpp
+++ b/algorithms/graph/articulations_bridges.cpp
@@ -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
diff --git a/algorithms/graph/ford_fulkerson.cpp b/algorithms/graph/ford_fulkerson.cpp
index 87da194..0507b51 100644
--- a/algorithms/graph/ford_fulkerson.cpp
+++ b/algorithms/graph/ford_fulkerson.cpp
@@ -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;
     }
diff --git a/algorithms/paradigm/lis.cpp b/algorithms/paradigm/lis.cpp
index 48ccd6e..55b960b 100644
--- a/algorithms/paradigm/lis.cpp
+++ b/algorithms/paradigm/lis.cpp
@@ -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;
   }
 
diff --git a/algorithms/structure/lazy_segment_tree.cpp b/algorithms/structure/lazy_segment_tree.cpp
index ea5c8a7..68c279c 100644
--- a/algorithms/structure/lazy_segment_tree.cpp
+++ b/algorithms/structure/lazy_segment_tree.cpp
@@ -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);
diff --git a/algorithms/structure/segment_tree.cpp b/algorithms/structure/segment_tree.cpp
index a579079..c5038a7 100644
--- a/algorithms/structure/segment_tree.cpp
+++ b/algorithms/structure/segment_tree.cpp
@@ -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);
-- 
GitLab