From 3f16da49802d9c30c8e654c998583e777007d8ac Mon Sep 17 00:00:00 2001
From: Bruno Freitas Tissei <bft15@inf.ufpr.br>
Date: Sun, 12 May 2019 17:53:08 -0300
Subject: [PATCH] Small improvements

Signed-off-by: Bruno Freitas Tissei <bft15@inf.ufpr.br>
---
 algorithms/math/binary_exponentiation.cpp | 30 ++++++++++++-----------
 algorithms/paradigm/ternary_search.cpp    |  1 -
 contests/Cadernaveis/BALE11.cpp           |  2 --
 contests/Cadernaveis/URI1850.cpp          |  5 ++--
 4 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/algorithms/math/binary_exponentiation.cpp b/algorithms/math/binary_exponentiation.cpp
index c3cf0fd..ff4bd97 100644
--- a/algorithms/math/binary_exponentiation.cpp
+++ b/algorithms/math/binary_exponentiation.cpp
@@ -3,20 +3,22 @@
 /// Complexity (Time): O(log n)
 /// Complexity (Space): O(1)
 
-/// Returns x^n in O(log n) time
-/// @param x number
-/// @param n exponent
-template <typename T>
-T fast_pow(T x, ll n) {
-  T ans = 1;
+struct BinaryExponentiation {
 
-  while (n) {
-    if (n & 1)
-      ans = ans * x;
+  /// Returns x^n in O(log n) time
+  /// @param x number
+  /// @param n exponent
+  ll fast_pow(ll x, ll n) {
+    ll ans = 1;
 
-    n >>= 1;
-    x = x * x;
-  }
+    while (n) {
+      if (n & 1)
+        ans = ans * x;
+
+      n >>= 1;
+      x = x * x;
+    }
 
-  return ans;
-}
+    return ans;
+  }
+};
diff --git a/algorithms/paradigm/ternary_search.cpp b/algorithms/paradigm/ternary_search.cpp
index 6e462ac..3b00840 100644
--- a/algorithms/paradigm/ternary_search.cpp
+++ b/algorithms/paradigm/ternary_search.cpp
@@ -4,7 +4,6 @@
 /// Complexity (Space): O(1)
 
 struct TernarySearch {
-  const double EPS = 1e-6;
 
   /// Unimodal function 
   double f(double x) {
diff --git a/contests/Cadernaveis/BALE11.cpp b/contests/Cadernaveis/BALE11.cpp
index 9aa2fb8..4b0729f 100644
--- a/contests/Cadernaveis/BALE11.cpp
+++ b/contests/Cadernaveis/BALE11.cpp
@@ -32,13 +32,11 @@ int query(int idx) {
   return sum;
 }
 
-
 void update(int idx, int val) {
   for (; idx <= MAX; idx += (idx & -idx))
     tree[idx] += val;
 }
 
-
 int main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
diff --git a/contests/Cadernaveis/URI1850.cpp b/contests/Cadernaveis/URI1850.cpp
index ae800d4..a75ef86 100644
--- a/contests/Cadernaveis/URI1850.cpp
+++ b/contests/Cadernaveis/URI1850.cpp
@@ -48,7 +48,6 @@ int main() {
 
   while (!Q.empty()) {
     elem curr = Q.front(); Q.pop();
-    cont[curr.fi.fi][curr.fi.se][curr.se.fi] = 1;
     
     if (mat[curr.fi.fi][curr.fi.se] == '*')
       return cout << curr.se.se << ende, 0;
@@ -63,14 +62,14 @@ int main() {
 
         if (mat[x][y] >= 'A' && mat[x][y] <= 'G') {
           if (msk & (1 << (mat[x][y] - 'A'))) {
-            //cont[x][y][msk] = 1;
+            cont[x][y][msk] = 1;
             Q.push({{x, y}, {msk, curr.se.se + 1}});
           }
         } else {
           if (mat[x][y] >= 'a' && mat[x][y] <= 'g')
             msk |= (1 << (mat[x][y] - 'a'));
 
-          //cont[x][y][msk] = 1;
+          cont[x][y][msk] = 1;
           Q.push({{x, y}, {msk, curr.se.se + 1}});
         }
       }
-- 
GitLab