Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
vidjil
vidjil
Commits
6e1d108c
Commit
6e1d108c
authored
Feb 29, 2016
by
Mathieu Giraud
Browse files
core/dynprog.cpp: backtrack also works on reversed sequences
parent
0b87fb1a
Changes
1
Hide whitespace changes
Inline
Side-by-side
algo/core/dynprog.cpp
View file @
6e1d108c
...
...
@@ -424,6 +424,13 @@ void DynProg::backtrack()
int
i
=
best_i
+
1
;
int
j
=
best_j
+
1
;
// Retake good i/j when there were reversed strings
if
(
reverse_x
)
i
=
m
-
i
+
1
;
if
(
reverse_y
)
j
=
n
-
j
+
1
;
// Compute backtrack strings
ostringstream
back_x
;
...
...
@@ -432,9 +439,11 @@ void DynProg::backtrack()
while
(
1
)
{
if
(
j
==
marked_pos_j
)
if
((
!
reverse_y
&&
(
j
==
marked_pos_j
))
||
(
reverse_y
&&
(
n
-
j
+
1
==
marked_pos_j
)))
{
marked_pos_i
=
i
;
marked_pos_i
=
reverse_x
?
m
-
i
+
1
:
i
;
}
if
((
i
<
0
)
||
(
j
<
0
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment