Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .verify-helper/timestamps.remote.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"Test/Range/bit_subset.test.cpp": "2024-12-27 17:07:26 +0900",
"Test/Range/flatten.test.cpp": "2025-12-20 02:07:58 +0900",
"Test/String/LCPArray.test.cpp": "2025-01-23 04:47:08 +0900",
"Test/String/PalindromicTree.test.cpp": "2025-12-20 03:22:27 +0900",
"Test/String/PalindromicTree_large.test.cpp": "2025-12-20 03:22:27 +0900",
"Test/String/PalindromicTree.test.cpp": "2025-12-19 19:38:03 +0000",
"Test/String/PalindromicTree_large.test.cpp": "2025-12-19 19:38:03 +0000",
"Test/String/SuffixArray.test.cpp": "2024-12-27 17:36:05 +0900",
"Test/String/TrieTree.test.cpp": "2024-12-27 17:07:26 +0900",
"Test/String/ZAlgorithm.test.cpp": "2024-12-27 17:07:26 +0900",
Expand Down
16 changes: 8 additions & 8 deletions Library/String/PalindromicTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ namespace mtd {
if (first_itr == -1) {
first_itr = itr;
} else {
rest_itrs.push_back(itr);
rest_itrs.emplace_back(itr);
}
}

auto get_itrs() const -> std::vector<int> {
if (first_itr == -1) { return {}; }
std::vector<int> result;
result.reserve(1 + rest_itrs.size());
result.push_back(first_itr);
result.emplace_back(first_itr);
result.insert(result.end(), rest_itrs.begin(), rest_itrs.end());
return result;
}
Expand Down Expand Up @@ -102,8 +102,8 @@ namespace mtd {
template <class Lambda>
auto dfs_edges(const Lambda& lambda) const -> void {
std::stack<int, std::vector<int>> stk;
stk.push(ROOT_ODD);
stk.push(ROOT_EVEN);
stk.emplace(ROOT_ODD);
stk.emplace(ROOT_EVEN);

while (!stk.empty()) {
int idx = stk.top();
Expand All @@ -112,7 +112,7 @@ namespace mtd {
const auto& node = m_nodes[idx];
if (node.size > 0) { lambda(node.size, node.get_itrs()); }

for (const auto& [_, next_idx] : node.edges) { stk.push(next_idx); }
for (const auto& [_, next_idx] : node.edges) { stk.emplace(next_idx); }
}
}

Expand All @@ -129,14 +129,14 @@ namespace mtd {
int sl_idx = node.suffix_link;
if (sl_idx >= 2 && m_nodes[sl_idx].first_itr != -1) {
int to = m_nodes[sl_idx].first_itr;
graph[from].push_back(to);
graph[from].emplace_back(to);
++order_count[to];
}
}

std::queue<int> q;
for (int i = 0; i < static_cast<int>(m_s.size()); ++i) {
if (order_count[i] == 0) { q.push(i); }
if (order_count[i] == 0) { q.emplace(i); }
}

while (!q.empty()) {
Expand All @@ -145,7 +145,7 @@ namespace mtd {
for (int t : graph[f]) {
--order_count[t];
lambda(f, t);
if (order_count[t] == 0) { q.push(t); }
if (order_count[t] == 0) { q.emplace(t); }
}
}
}
Expand Down