Skip to content

Commit 455f8a4

Browse files
committed
fix existing tests of manacher
1 parent aa9704c commit 455f8a4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

graph/test/shortest_path_dial.yuki1695.test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ int solve(const string &S, const string &T) {
1414
if (!nmatch) return INF;
1515
if (T.size() % 2) return INF;
1616
auto trev = T;
17+
reverse(trev.begin(), trev.end());
1718
if (trev != T) return INF;
1819
shortest_path<int> graph(T.size() + 1);
1920
for (int i = 0; i < int(T.size()); ++i) graph.add_edge(i, i + 1, 0);
@@ -23,7 +24,7 @@ int solve(const string &S, const string &T) {
2324
if ((l + r) % 2 == 0) graph.add_edge(r, (l + r) / 2, 1);
2425
}
2526
graph.dial(T.size(), nmatch);
26-
return graph.dist[nmatch];
27+
return std::max(1, graph.dist[nmatch]);
2728
}
2829

2930
int main() {

graph/test/zero_one_bfs.yuki1695.test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ int solve(const string &S, const string &T) {
1414
if (!nmatch) return INF;
1515
if (T.size() % 2) return INF;
1616
auto trev = T;
17+
reverse(trev.begin(), trev.end());
1718
if (trev != T) return INF;
1819
shortest_path<int> graph(T.size() + 1);
1920
for (int i = 0; i < int(T.size()); ++i) graph.add_edge(i, i + 1, 0);
@@ -23,7 +24,7 @@ int solve(const string &S, const string &T) {
2324
if ((l + r) % 2 == 0) graph.add_edge(r, (l + r) / 2, 1);
2425
}
2526
graph.zero_one_bfs(T.size(), nmatch);
26-
return graph.dist[nmatch];
27+
return std::max(1, graph.dist[nmatch]);
2728
}
2829

2930
int main() {

0 commit comments

Comments
 (0)