Skip to content

Commit 4b4c9d5

Browse files
chore: update minified library versions
1 parent 5421b41 commit 4b4c9d5

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

cp-algo/min/structures/eertree.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
#include <iostream>
77
#include <vector>
88
#include <string>
9-
namespace cp_algo::structures{template<int sigma=26,char mch='a'>struct eertree{eertree(size_t q){q+=2;s=big_string(q,-1);len=par=link=big_vector(q,0);to.resize(q);link[0]=1;len[1]=-1;}int get_link(int v)const{while(s[n-1]!=s[n-len[v]-2]){v=link[v];}return v;}int get(int v,int c)const{for(int cu:to[v]){if(char(cu)==c){return cu>>8;}}return 0;}void add_letter(char c){c-='a';s[n++]=c;last=get_link(last);if(!get(last,c)){int u=get(get_link(link[last]),c);link[sz]=u;par[sz]=last;len[sz]=len[last]+2;to[last].emplace_front((sz++<<8)|c);}last=get(last,c);}int sufpal(auto&&adjust)const{return adjust(last);}int sufpal()const{return sufpal(std::identity{});}void print(auto&&adjust)const{std::cout<<sz-2<<"\n";for(int i=2;i<sz;i++){std::cout<<adjust(par[i])<<' '<<adjust(link[i])<<"\n";}}void print()const{print(std::identity{});}private:big_vector<std::forward_list<int>>to;big_vector<int>len,link,par;big_string s;int n=1,sz=2,last=0;};}
9+
namespace cp_algo::structures{template<int sigma=26,char mch='a'>struct eertree{eertree(size_t q){q+=2;s=big_string(q,-1);len=par=link=big_vector(q,0);to.resize(q);link[0]=1;len[1]=-1;}int get_link(int v)const{while(s[n-1]!=s[n-len[v]-2]){v=link[v];}return v;}int get(int v,int c)const{for(int cu:to[v]){if(char(cu)==c){return cu>>8;}}return 0;}void add_letter(char c){c-='a';s[n++]=c;last=get_link(last);if(!get(last,c)){int u=get(get_link(link[last]),c);link[sz]=u;par[sz]=last;len[sz]=len[last]+2;to[last].emplace_front((sz++<<8)|c);}last=get(last,c);}int sufpal(auto&&adjust)const{return adjust(last);}int sufpal()const{return sufpal(std::identity{});}void print(auto&&adjust)const{std::cout<<sz-2<<"\n";for(int i=2;i<sz;i++){std::cout<<adjust(par[i])<<' '<<adjust(link[i])<<"\n";}}void print()const{print(std::identity{});}private:big_vector<big_forward_list<int>>to;big_vector<int>len,link,par;big_string s;int n=1,sz=2,last=0;};}
1010
#endif

cp-algo/min/tree/diameter.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
#include <tuple>
77
#include <string>
88
#include <algorithm>
9-
namespace cp_algo::graph{enum class diameter_mode{recover_path,no_recover};template<diameter_mode mode=diameter_mode::no_recover,weighted_undirected_graph_type graph>auto tree_diameter(graph const&g,const auto*parents){struct up_path{int64_t length=0;node_index start=0;};big_vector<up_path>up(g.n());for(auto v:g.nodes()){up[v].start=v;}up_path s,t;auto callback=[&](node_index v,edge_index ep){if(ep==edge_index(-1))return;node_index u=g.edge(ep).traverse(v);up[v].length+=g.edge(ep).w;if(up[v].length+up[u].length>s.length+t.length){s=up[v];t=up[u];}if(up[v].length>up[u].length){up[u]=up[v];}};big_vector<edge_index>parents_owned;if(parents){parent_dfs(g,*parents,callback);}else{parents_owned=xor_dfs(g,callback);parents=&parents_owned;}if constexpr(mode==diameter_mode::no_recover){return s.length+t.length;}else{auto collect=[&](up_path v){std::basic_string<edge_index>path;while(v.length){edge_index ep=(*parents)[v.start];path.push_back(ep);v.length-=g.edge(ep).w;v.start=g.edge(ep).traverse(v.start);}return path;};auto paths=collect(s);auto patht=collect(t);std::ranges::reverse(patht);return std::tuple{s.length+t.length,s.start,paths+=patht};}}template<diameter_mode mode=diameter_mode::no_recover,weighted_undirected_graph_type graph>auto tree_diameter(graph const&g){return tree_diameter<mode>(g,(big_vector<edge_index>const*)(nullptr));}}
9+
namespace cp_algo::graph{enum class diameter_mode{recover_path,no_recover};template<diameter_mode mode=diameter_mode::no_recover,weighted_undirected_graph_type graph>auto tree_diameter(graph const&g,const auto*parents){struct up_path{int64_t length=0;node_index start=0;};big_vector<up_path>up(g.n());for(auto v:g.nodes()){up[v].start=v;}up_path s,t;auto callback=[&](node_index v,edge_index ep){if(ep==edge_index(-1))return;node_index u=g.edge(ep).traverse(v);up[v].length+=g.edge(ep).w;if(up[v].length+up[u].length>s.length+t.length){s=up[v];t=up[u];}if(up[v].length>up[u].length){up[u]=up[v];}};big_vector<edge_index>parents_owned;if(parents){parent_dfs(g,*parents,callback);}else{parents_owned=xor_dfs(g,callback);parents=&parents_owned;}if constexpr(mode==diameter_mode::no_recover){return s.length+t.length;}else{auto collect=[&](up_path v){big_basic_string<edge_index>path;while(v.length){edge_index ep=(*parents)[v.start];path.push_back(ep);v.length-=g.edge(ep).w;v.start=g.edge(ep).traverse(v.start);}return path;};auto paths=collect(s);auto patht=collect(t);std::ranges::reverse(patht);return std::tuple{s.length+t.length,s.start,paths+=patht};}}template<diameter_mode mode=diameter_mode::no_recover,weighted_undirected_graph_type graph>auto tree_diameter(graph const&g){return tree_diameter<mode>(g,(big_vector<edge_index>const*)(nullptr));}}
1010
#endif

cp-algo/min/util/big_alloc.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#ifndef CP_ALGO_UTIL_big_alloc_HPP
22
#define CP_ALGO_UTIL_big_alloc_HPP
3+
#include <set>
34
#include <map>
45
#include <deque>
56
#include <stack>
@@ -9,6 +10,7 @@
910
#include <cstddef>
1011
#include <iostream>
1112
#include <generator>
13+
#include <forward_list>
1214
#if defined(__linux__) || defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
1315
# define CP_ALGO_USE_MMAP 1
1416
# include <sys/mman.h>
@@ -23,5 +25,5 @@ return static_cast<T*>(::operator new(padded,std::align_val_t(align)));}void dea
2325
#if CP_ALGO_USE_MMAP
2426
if(padded>=MEGABYTE){munmap(p,padded);return;}
2527
#endif
26-
::operator delete(p,padded,std::align_val_t(align));}private:static constexpr std::size_t MEGABYTE=1<<20;static constexpr std::size_t round_up(std::size_t x)noexcept{return(x+Align-1)/Align*Align;}};template<typename T>using big_vector=std::vector<T,big_alloc<T>>;template<typename T>using big_basic_string=std::basic_string<T,std::char_traits<T>,big_alloc<T>>;template<typename T>using big_deque=std::deque<T,big_alloc<T>>;template<typename Key,typename Value,typename Compare=std::less<Key>>using big_map=std::map<Key,Value,Compare,big_alloc<std::pair<const Key,Value>>>;using big_string=big_basic_string<char>;template<typename T>using big_stack=std::stack<T,big_deque<T>>;template<typename T>using big_queue=std::queue<T,big_deque<T>>;template<typename T>using big_priority_queue=std::priority_queue<T,big_vector<T>>;template<typename Ref,typename V=void>using big_generator=std::generator<Ref,V,big_alloc<std::byte>>;}namespace std::ranges{template<typename Ref,typename V>elements_of(cp_algo::big_generator<Ref,V>&&)->elements_of<cp_algo::big_generator<Ref,V>&&,cp_algo::big_alloc<std::byte>>;}
28+
::operator delete(p,padded,std::align_val_t(align));}private:static constexpr std::size_t MEGABYTE=1<<20;static constexpr std::size_t round_up(std::size_t x)noexcept{return(x+Align-1)/Align*Align;}};template<typename T>using big_vector=std::vector<T,big_alloc<T>>;template<typename T>using big_basic_string=std::basic_string<T,std::char_traits<T>,big_alloc<T>>;template<typename T>using big_deque=std::deque<T,big_alloc<T>>;template<typename T>using big_stack=std::stack<T,big_deque<T>>;template<typename T>using big_queue=std::queue<T,big_deque<T>>;template<typename T>using big_priority_queue=std::priority_queue<T,big_vector<T>>;template<typename T>using big_forward_list=std::forward_list<T,big_alloc<T>>;using big_string=big_basic_string<char>;template<typename Key,typename Value,typename Compare=std::less<Key>>using big_map=std::map<Key,Value,Compare,big_alloc<std::pair<const Key,Value>>>;template<typename T,typename Compare=std::less<T>>using big_multiset=std::multiset<T,Compare,big_alloc<T>>;template<typename Ref,typename V=void>using big_generator=std::generator<Ref,V,big_alloc<std::byte>>;}namespace std::ranges{template<typename Ref,typename V>elements_of(cp_algo::big_generator<Ref,V>&&)->elements_of<cp_algo::big_generator<Ref,V>&&,cp_algo::big_alloc<std::byte>>;}
2729
#endif

0 commit comments

Comments
 (0)