Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
competitive
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bruno Freitas Tissei
competitive
Commits
43eb105f
Commit
43eb105f
authored
5 years ago
by
Bruno Freitas Tissei
Browse files
Options
Downloads
Patches
Plain Diff
Small fixes
Signed-off-by:
Bruno Freitas Tissei
<
bft15@inf.ufpr.br
>
parent
a6251d32
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
algorithms/graph/kruskal.cpp
+4
-4
4 additions, 4 deletions
algorithms/graph/kruskal.cpp
algorithms/string/kmp.cpp
+14
-17
14 additions, 17 deletions
algorithms/string/kmp.cpp
algorithms/structure/segment_tree.cpp
+1
-1
1 addition, 1 deletion
algorithms/structure/segment_tree.cpp
with
19 additions
and
22 deletions
algorithms/graph/kruskal.cpp
+
4
−
4
View file @
43eb105f
...
...
@@ -6,8 +6,8 @@
/// Include:
/// - structure/disjoint_set
typedef
pair
<
ii
,
int
>
iii
;
vector
<
iii
>
edges
;
using
edge
=
pair
<
ii
,
int
>
;
vector
<
edge
>
edges
;
struct
Kruskal
{
int
N
;
...
...
@@ -17,8 +17,8 @@ struct Kruskal {
// Minimum Spanning Tree: comp = less<int>()
// Maximum Spanning Tree: comp = greater<int>()
int
run
(
vector
<
iii
>
&
mst
,
function
<
bool
(
int
,
int
)
>
comp
)
{
sort
(
all
(
edges
),
[
&
](
const
iii
&
a
,
const
iii
&
b
)
{
int
run
(
vector
<
edge
>
&
mst
,
function
<
bool
(
int
,
int
)
>
comp
)
{
sort
(
all
(
edges
),
[
&
](
const
edge
&
a
,
const
edge
&
b
)
{
return
comp
(
a
.
se
,
b
.
se
);
});
...
...
This diff is collapsed.
Click to expand it.
algorithms/string/kmp.cpp
+
14
−
17
View file @
43eb105f
...
...
@@ -9,36 +9,33 @@
struct
KMP
{
string
patt
;
vector
<
int
>
table
;
vector
<
int
>
pi
;
KMP
(
string
patt
)
:
patt
(
patt
),
table
(
patt
.
size
()
+
1
)
patt
(
patt
),
pi
(
patt
.
size
())
{
preprocess
();
}
void
preprocess
()
{
fill
(
all
(
table
),
-
1
);
patt
[
0
]
=
0
;
for
(
int
i
=
1
,
j
=
0
;
i
<
patt
.
size
();
++
i
)
{
while
(
j
>
0
&&
patt
[
i
]
!=
patt
[
j
])
j
=
pi
[
j
-
1
];
for
(
int
i
=
0
,
j
=
-
1
;
i
<
patt
.
size
();
++
i
)
{
while
(
j
>=
0
&&
patt
[
i
]
!=
patt
[
j
])
j
=
table
[
j
];
table
[
i
+
1
]
=
++
j
;
if
(
patt
[
i
]
==
patt
[
j
])
j
++
;
pi
[
i
]
=
j
;
}
}
vector
<
int
>
search
(
const
string
&
txt
)
{
vector
<
int
>
occurs
;
void
search
(
const
string
&
txt
)
{
for
(
int
i
=
0
,
j
=
0
;
i
<
txt
.
size
();
++
i
)
{
while
(
j
>=
0
&&
txt
[
i
]
!=
patt
[
j
])
j
=
table
[
j
];
j
++
;
while
(
j
>
0
&&
txt
[
i
]
!=
patt
[
j
])
j
=
pi
[
j
-
1
];
if
(
txt
[
i
]
==
patt
[
j
])
j
++
;
if
(
j
==
patt
.
size
())
{
occurs
.
pb
(
i
-
j
)
;
j
=
table
[
j
];
cout
<<
"Pattern found at "
<<
(
i
-
j
)
<<
ende
;
j
=
pi
[
j
-
1
];
}
}
return
occurs
;
}
};
This diff is collapsed.
Click to expand it.
algorithms/structure/segment_tree.cpp
+
1
−
1
View file @
43eb105f
...
...
@@ -20,7 +20,7 @@ struct SegmentTree {
T
ident
=
T
();
vector
<
T
>
tree
;
SegmentTree
(
F
&
func
)
:
func
(
func
),
tree
(
MAX
*
4
)
{}
SegmentTree
(
F
func
)
:
func
(
func
),
tree
(
MAX
*
4
)
{}
void
build
(
const
vector
<
T
>
&
v
,
int
node
=
1
,
int
l
=
0
,
int
r
=
N
-
1
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment