Skip to content

Commit 9811805

Browse files
committed
Regenerate minified files with fixed preprocessor directives and fix test file path resolution
1 parent 1ffe20a commit 9811805

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+3936
-1484
lines changed

.verify-helper/scripts/inject_minified_docs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,10 @@ def main():
197197

198198
if is_test_file:
199199
# For test files, only generate bundled+minified version (not plain minified)
200-
# Reconstruct source file path
200+
# Reconstruct source file path - test files are relative to repo root
201201
if original_ext:
202-
source_file = Path(path_without_ext + original_ext)
202+
# path_without_ext is like "verify/test_file", we need the actual file in the repo
203+
source_file = docs_root.parent / (path_without_ext + original_ext)
203204
if source_file.exists():
204205
# Generate bundled+minified version only
205206
minified_bundled_code = bundle_and_minify(source_file)

cp-algo/min/geometry/closest_pair.hpp

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,53 @@
44
#include "point.hpp"
55
#include <vector>
66
#include <map>
7-
namespace cp_algo::geometry{template<typename ftype>
8-
auto closest_pair(std::vector<point_t<ftype>>const&r){using point=point_t<ftype>;
7+
namespace cp_algo::geometry{
8+
template<typename ftype>
9+
auto closest_pair(std::vector<point_t<ftype>>const&r){
10+
using point=point_t<ftype>;
911
size_t n=size(r);
1012
int64_t md=1e18;
11-
for(size_t i=0;i<n/100;i++){auto A=random::rng()%n;
13+
for(size_t i=0;i<n/100;i++){
14+
auto A=random::rng()%n;
1215
auto B=random::rng()%n;
13-
if(A!=B){md=std::min(md,norm(r[A]-r[B]));
14-
if(md==0){return std::pair{A,B};}}}
16+
if(A!=B){
17+
md=std::min(md,norm(r[A]-r[B]));
18+
if(md==0){
19+
return std::pair{A,B};
20+
}
21+
}
22+
}
1523
std::map<point,std::vector<size_t>>neigs;
1624
md=(int64_t)ceil(sqrt((double)md));
17-
for(size_t i=0;i<n;i++){neigs[r[i]/md].push_back(i);}
25+
for(size_t i=0;i<n;i++){
26+
neigs[r[i]/md].push_back(i);
27+
}
1828
size_t a=0,b=1;
1929
md=norm(r[a]-r[b]);
20-
for(auto&[p,id]:neigs){for(int dx:{-1,0,1}){for(int dy:{-1,0,1}){auto pp=p+point{dx,dy};
21-
if(!neigs.count(pp)){continue;}
22-
for(size_t i:neigs[pp]){for(size_t j:id){if(j==i){break;}
30+
for(auto&[p,id]:neigs){
31+
for(int dx:{-1,0,1}){
32+
for(int dy:{-1,0,1}){
33+
auto pp=p+point{dx,dy};
34+
if(!neigs.count(pp)){
35+
continue;
36+
}
37+
for(size_t i:neigs[pp]){
38+
for(size_t j:id){
39+
if(j==i){
40+
break;
41+
}
2342
int64_t cur=norm(r[i]-r[j]);
24-
if(cur<md){md=cur;
43+
if(cur<md){
44+
md=cur;
2545
a=i;
26-
b=j;}}}}}}
27-
return std::pair{a,b};}}
28-
#endif
46+
b=j;
47+
}
48+
}
49+
}
50+
}
51+
}
52+
}
53+
return std::pair{a,b};
54+
}
55+
}
56+
#endif

cp-algo/min/geometry/convex_hull.hpp

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,33 @@
55
#include <utility>
66
#include <vector>
77
#include <ranges>
8-
namespace cp_algo::geometry{template<typename ftype>
9-
std::vector<point_t<ftype>>convex_hull(std::vector<point_t<ftype>>r){using point=point_t<ftype>;
8+
namespace cp_algo::geometry{
9+
template<typename ftype>
10+
std::vector<point_t<ftype>>convex_hull(std::vector<point_t<ftype>>r){
11+
using point=point_t<ftype>;
1012
std::ranges::sort(r);
11-
if(size(r)<=1||r[0]==r.back()){return empty(r)?r:std::vector{r[0]};}
13+
if(size(r)<=1||r[0]==r.back()){
14+
return empty(r)?r:std::vector{r[0]};
15+
}
1216
std::vector<point>hull={r[0]};
13-
for(int half:{0,1}){size_t base=size(hull);
14-
for(auto it:std::views::drop(r,1)){while(size(hull)>=base+1){point a=hull.back();
15-
if(point::ccw(it-a,end(hull)[-2]-a)){break;}else{hull.pop_back();}}
16-
hull.push_back(it);}
17+
for(int half:{0,1}){
18+
size_t base=size(hull);
19+
for(auto it:std::views::drop(r,1)){
20+
while(size(hull)>=base+1){
21+
point a=hull.back();
22+
if(point::ccw(it-a,end(hull)[-2]-a)){
23+
break;
24+
}else{
25+
hull.pop_back();
26+
}
27+
}
28+
hull.push_back(it);
29+
}
1730
std::ranges::reverse(r);
18-
std::ignore=half;}
31+
std::ignore=half;
32+
}
1933
hull.pop_back();
20-
return hull;}}
21-
#endif
34+
return hull;
35+
}
36+
}
37+
#endif

cp-algo/min/geometry/point.hpp

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,39 @@
22
#define CP_ALGO_GEOMETRY_POINT_HPP
33
#include "../util/complex.hpp"
44
#include <iostream>
5-
namespace cp_algo::geometry{template<typename ftype>
6-
struct point_t:complex<ftype>{using Base=complex<ftype>;
5+
namespace cp_algo::geometry{
6+
template<typename ftype>
7+
struct point_t:complex<ftype>{
8+
using Base=complex<ftype>;
79
using Base::Base;
810
point_t(Base const&t):Base(t){}
9-
auto operator<=>(point_t const&t)const{return std::pair{y(),-x()}<=>std::pair{t.y(),-t.x()};}
11+
auto operator<=>(point_t const&t)const{
12+
return std::pair{y(),-x()}<=>std::pair{t.y(),-t.x()};
13+
}
1014
ftype x()const{return Base::real();}
1115
ftype y()const{return Base::imag();}
1216
point_t cmul(point_t const&t)const{return conj(*this)*t;}
1317
ftype dot(point_t const&t)const{return cmul(t).x();}
1418
ftype cross(point_t const&t)const{return cmul(t).y();}
1519
static constexpr point_t O={0,0};
16-
int half()const{return*this<O?-1:*this==O?0:1;}
17-
static bool ccw(point_t const&a,point_t const&b){return a.cross(b)>0;}
18-
static bool ccw_abs(point_t const&a,point_t const&b){return std::tuple{a.half(),(ftype)0,norm(a)}<
19-
std::tuple{b.half(),a.cross(b),norm(b)};}
20-
void read(){ftype _x,_y;
20+
int half()const{
21+
return*this<O?-1:*this==O?0:1;
22+
}
23+
static bool ccw(point_t const&a,point_t const&b){
24+
return a.cross(b)>0;
25+
}
26+
static bool ccw_abs(point_t const&a,point_t const&b){
27+
return std::tuple{a.half(),(ftype)0,norm(a)}<
28+
std::tuple{b.half(),a.cross(b),norm(b)};
29+
}
30+
void read(){
31+
ftype _x,_y;
2132
std::cin>>_x>>_y;
22-
*this={_x,_y};}
23-
void print()const{std::cout<<x()<<' '<<y()<<"\n";}};}
24-
#endif
33+
*this={_x,_y};
34+
}
35+
void print()const{
36+
std::cout<<x()<<' '<<y()<<"\n";
37+
}
38+
};
39+
}
40+
#endif

cp-algo/min/graph/base.hpp

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,43 @@
44
#include "concepts.hpp"
55
#include "../structures/stack_union.hpp"
66
#include <ranges>
7-
namespace cp_algo::graph{using edge_index=int;
7+
namespace cp_algo::graph{
8+
using edge_index=int;
89
template<edge_type _edge_t=edge_base,graph_mode _mode=undirected>
9-
struct graph{using edge_t=_edge_t;
10+
struct graph{
11+
using edge_t=_edge_t;
1012
static constexpr auto mode=_mode;
1113
using incidence_list=structures::stack_union<edge_index>;
1214
graph(int n,int v0=0):v0(v0),adj(n){}
13-
graph transpose()const{static_assert(mode==directed,"transpose is only defined for directed graphs");
15+
graph transpose()const{
16+
static_assert(mode==directed,"transpose is only defined for directed graphs");
1417
graph<edge_t,mode>gt(n(),v0);
15-
for(auto v:nodes()){for(auto e:outgoing(v)){gt.add_edge(edge(e).traverse(v),edge(e));}}
16-
return gt;}
17-
edge_index add_edge(node_index u,edge_t e){edge_index idx=(edge_index)size(E);
18+
for(auto v:nodes()){
19+
for(auto e:outgoing(v)){
20+
gt.add_edge(edge(e).traverse(v),edge(e));
21+
}
22+
}
23+
return gt;
24+
}
25+
edge_index add_edge(node_index u,edge_t e){
26+
edge_index idx=(edge_index)size(E);
1827
E.push_back(e);
1928
adj.push(u,idx);
20-
if constexpr(mode==undirected){adj.push(e.traverse(u),idx);}
21-
return idx;}
22-
edge_index add_edge(node_index u,auto... Args){return add_edge(u,edge_t(u,Args...));}
23-
void read_edges(node_index m){adj.reserve(mode==undirected?2*m:m);
24-
for(edge_index i=0;i<m;i++){auto[u,e]=edge_t::read(v0);
25-
add_edge(u,e);}}
29+
if constexpr(mode==undirected){
30+
adj.push(e.traverse(u),idx);
31+
}
32+
return idx;
33+
}
34+
edge_index add_edge(node_index u,auto... Args){
35+
return add_edge(u,edge_t(u,Args...));
36+
}
37+
void read_edges(node_index m){
38+
adj.reserve(mode==undirected?2*m:m);
39+
for(edge_index i=0;i<m;i++){
40+
auto[u,e]=edge_t::read(v0);
41+
add_edge(u,e);
42+
}
43+
}
2644
auto outgoing(node_index v)const{return adj[v];}
2745
auto edges()const{return E|std::views::all;}
2846
auto nodes()const{return std::views::iota(node_index(0),n());}
@@ -31,13 +49,16 @@ auto&&incidence_lists(this auto&&self){return self.adj;}
3149
auto&&edge(this auto&&self,edge_index e){return self.E[e];}
3250
node_index n()const{return(node_index)incidence_lists().size();}
3351
edge_index m()const{return(edge_index)edges().size();}
34-
private:node_index v0;
52+
private:
53+
node_index v0;
3554
big_vector<edge_t>E;
36-
incidence_list adj;};
55+
incidence_list adj;
56+
};
3757
template<edge_type edge_t=edge_base>
3858
using digraph=graph<edge_t,directed>;
3959
template<weighted_edge_type edge_t=weighted_edge,graph_mode mode=undirected>
4060
using weighted_graph=graph<edge_t,mode>;
4161
template<weighted_edge_type edge_t=weighted_edge>
42-
using weighted_digraph=digraph<edge_t>;}
43-
#endif
62+
using weighted_digraph=digraph<edge_t>;
63+
}
64+
#endif

cp-algo/min/graph/concepts.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
#define CP_ALGO_GRAPH_CONCEPTS_HPP
33
#include "edge_types.hpp"
44
#include <type_traits>
5-
namespace cp_algo::graph{enum graph_mode{directed,undirected};
5+
namespace cp_algo::graph{
6+
enum graph_mode{directed,undirected};
67
template<typename T,typename=void>
78
struct graph_traits:std::false_type{};
89
template<typename T>
9-
struct graph_traits<T,std::void_t<typename T::edge_t,decltype(T::mode)>>:std::true_type{using edge_t=typename T::edge_t;
10+
struct graph_traits<T,std::void_t<typename T::edge_t,decltype(T::mode)>>:std::true_type{
11+
using edge_t=typename T::edge_t;
1012
static constexpr auto mode=T::mode;
1113
static constexpr bool is_directed=mode==directed;
1214
static constexpr bool is_undirected=mode==undirected;
13-
static constexpr bool is_weighted=weighted_edge_type<edge_t>;};
15+
static constexpr bool is_weighted=weighted_edge_type<edge_t>;
16+
};
1417
template<typename G>
1518
concept graph_type=graph_traits<G>::value;
1619
template<typename G>
@@ -22,5 +25,6 @@ concept weighted_graph_type=graph_type<G>&&graph_traits<G>::is_weighted;
2225
template<typename G>
2326
concept weighted_digraph_type=digraph_type<G>&&graph_traits<G>::is_weighted;
2427
template<typename G>
25-
concept weighted_undirected_graph_type=undirected_graph_type<G>&&graph_traits<G>::is_weighted;}
26-
#endif
28+
concept weighted_undirected_graph_type=undirected_graph_type<G>&&graph_traits<G>::is_weighted;
29+
}
30+
#endif

cp-algo/min/graph/cycle.hpp

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,33 @@
33
#include "dfs.hpp"
44
#include "base.hpp"
55
#include <deque>
6-
namespace cp_algo::graph{template<graph_type graph>
7-
struct cycle_context:dfs_context<graph>{using base=dfs_context<graph>;
6+
namespace cp_algo::graph{
7+
template<graph_type graph>
8+
struct cycle_context:dfs_context<graph>{
9+
using base=dfs_context<graph>;
810
using base::base;
911
std::deque<edge_index>cycle;
1012
bool closed=false;
1113
int v0;
12-
void on_return_from_child(node_index v,edge_index e){if(!empty(cycle)&&!closed){cycle.push_front(e);
13-
closed|=v==v0;}}
14-
void on_back_edge(node_index v,edge_index e){if(empty(cycle)){v0=base::g->edge(e).traverse(v);
14+
void on_return_from_child(node_index v,edge_index e){
15+
if(!empty(cycle)&&!closed){
16+
cycle.push_front(e);
17+
closed|=v==v0;
18+
}
19+
}
20+
void on_back_edge(node_index v,edge_index e){
21+
if(empty(cycle)){
22+
v0=base::g->edge(e).traverse(v);
1523
base::done=true;
1624
closed=v==v0;
17-
cycle.push_front(e);}}};
25+
cycle.push_front(e);
26+
}
27+
}
28+
};
1829
template<graph_type graph>
19-
std::pair<node_index,std::deque<edge_index>>find_cycle(graph const&g){auto context=dfs<cycle_context>(g);
20-
return{context.v0,context.cycle};}}
21-
#endif
30+
std::pair<node_index,std::deque<edge_index>>find_cycle(graph const&g){
31+
auto context=dfs<cycle_context>(g);
32+
return{context.v0,context.cycle};
33+
}
34+
}
35+
#endif

0 commit comments

Comments
 (0)