From 237f4a3264a734f29c5a855220272443ce2cc6fb Mon Sep 17 00:00:00 2001
From: Bruno Freitas Tissei <bft15@inf.ufpr.br>
Date: Mon, 17 Sep 2018 19:26:09 -0300
Subject: [PATCH] Add correct README

Signed-off-by: Bruno Freitas Tissei <bft15@inf.ufpr.br>
---
 README.md                       | 42 +++-----------------------------
 structure/lazy_segment_tree.cpp | 43 +++++++++++----------------------
 2 files changed, 17 insertions(+), 68 deletions(-)

diff --git a/README.md b/README.md
index 769ffa2..553e6d2 100644
--- a/README.md
+++ b/README.md
@@ -1,41 +1,5 @@
-# Algorithm for Correction of Marker Rotation and Displacement Errors
+# Implementações de algoritmos e resoluções de problemas; estudo, treino e consulta para programação competitiva (maratona de programação)
 
-The algorithm is described and explained at report.pdf  
+Os algoritmos estão classificados por area de estudo e todos eles estão listados nas Issues.  
 
-# Get mid Points (First Step)
-
-Gets last PE point before each marker detection.  
-
---md and --pe are the logs from marker detection and pose estimator from the path that needs to be optimized, this path needs the global pose update by markers turned on.  
-
-```
-$ python script/get_mid_points.py --marker=data/logs/20180516-134720/marker/pose.csv --pe=data/logs/20180516-134720/pe/pose.csv > mid_data
-```
-
-# Parse Marker Error (Second Step)
-
-Parse log from path without global position update by marker detection  
-
-```
-$ python script/parse_marker_error.py --map=data/gvz_ext.yml --md=data/logs/20180516-133414/marker/pose.csv > correction_data
-```  
-
-If no such path was captured, then the --md option should receive the same marker log that was used in the first step, in this case the "True values" in the algorithm's plot shall be ignored.
-
-
-# Run Algorithm
-
-Will plot the result and also create a file "fixed_gvz.yml", which is the gvz yml with the new values for the theta
-
-```
-$ python script/algorithm.py --inter=mid_data --correction=correction_data
-```
-
-
-# Plotter
-
-Plots a path. The --show option specifies which logs need to be included in the plot (m=marker, p=pose, c=ctrl, i=inter). The inter log can be obtained from the First Step.  
-
-```
-$ python script/plotter.py --map=data/gvz_ext.yml --log=data/logs/20180516-134720 --show=mpci
-```
+A seleção dos problemas e contests foi feita com base na minha necessidade e curiosidade de aprender assuntos específicos.
diff --git a/structure/lazy_segment_tree.cpp b/structure/lazy_segment_tree.cpp
index d4eac73..9f7552a 100644
--- a/structure/lazy_segment_tree.cpp
+++ b/structure/lazy_segment_tree.cpp
@@ -22,45 +22,38 @@ void build_tree(int node = 1, int a = 0, int b = N) {
 
   build_tree(node * 2, a, (a + b) / 2);
   build_tree(node * 2 + 1, 1 + (a + b) / 2, b);
-
   tree[node] = tree[node * 2] + tree[node * 2 + 1];
 }
 
-int modification(int a, int b, int val) {
-  return ((b - a) + 1) * val;
+
+void push(int node, int val) {
+  tree[node] += value;
+
+  if (a != b) {
+    lazy[node * 2] += val;
+    lazy[node * 2 + 1] += val;
+  }
+
+  lazy[node] = 0;
 }
 
 
 // Update segment [i,j] by adding value val
 void update_tree(int i, int j, int val, int node = 1, int a = 0, int b = N) {
-  if (lazy[node] != 0) {
-    tree[node] += modification(a, b, lazy[node]);
-
-    if (a != b) {
-      lazy[node * 2] += lazy[node];
-      lazy[node * 2 + 1] += lazy[node];
-    }
+  if (lazy[node] != 0)
+    push(node, lazy[node]);
 
-    lazy[node] = 0;
-  }
 
   if (a > b || a > j || b < i)
     return;
 
   if (a >= i && b <= j) {
-    tree[node] += modification(a, b, val);
-
-    if (a != b) {
-      lazy[node * 2] += val;
-      lazy[node * 2 + 1] += val;
-    }
-
+    push(node, val);
     return;
   }
 
   update_tree(i, j, node * 2, a, (a + b) / 2);
   update_tree(i, j, node * 2 + 1, 1 + (a + b) / 2, b);
-
   tree[node] = tree[node * 2] + tree[node * 2 + 1];
 }
 
@@ -71,14 +64,7 @@ int query_tree(int i, int j, int node = 1, int a = 0, int b = N) {
     return 0;
 
   if (lazy[node] != 0) {
-    tree[node] += modification(a, b, lazy[node]);
-
-    if (a != b) {
-      lazy[node * 2] += lazy[node];
-      lazy[node * 2 + 1] += lazy[node];
-    }
-
-    lazy[node] = 0;
+    push(node, val); 
   }
 
   if (a >= i && b <= j)
@@ -86,6 +72,5 @@ int query_tree(int i, int j, int node = 1, int a = 0, int b = N) {
 
   int q1 = query_tree(i, j, node * 2, a, (a + b) / 2);
   int q2 = query_tree(i, j, node * 2 + 1, 1 + (a + b) / 2, b);
-
   return q1 + q2;
 }
-- 
GitLab