File tree Expand file tree Collapse file tree 6 files changed +14
-9
lines changed Expand file tree Collapse file tree 6 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -206,11 +206,11 @@ path = "examples/helpers/lis_handmade.rs"
206
206
207
207
[[example ]]
208
208
name = " range_container_aizu"
209
- path = " examples/helpers /range_container_aizu.rs"
209
+ path = " examples/data_structures /range_container_aizu.rs"
210
210
211
211
[[example ]]
212
212
name = " range_container_handmade"
213
- path = " examples/helpers /range_container_handmade.rs"
213
+ path = " examples/data_structures /range_container_handmade.rs"
214
214
215
215
[[example ]]
216
216
name = " mono_st"
Original file line number Diff line number Diff line change 1
1
// verification-helper: PROBLEM https://onlinejudge.u-aizu.ac.jp/problems/DSL_2_D
2
2
3
3
use proconio:: input;
4
- use programming_team_code_rust:: helpers :: range_container:: RangeContainer ;
4
+ use programming_team_code_rust:: data_structures :: range_container:: RangeContainer ;
5
5
6
6
fn main ( ) {
7
7
input ! {
Original file line number Diff line number Diff line change 1
1
// verification-helper: PROBLEM https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/all/ITP1_1_A
2
2
3
- use programming_team_code_rust:: helpers :: range_container:: RangeContainer ;
3
+ use programming_team_code_rust:: data_structures :: range_container:: RangeContainer ;
4
4
use rand:: { thread_rng, Rng } ;
5
5
use std:: collections:: BTreeMap ;
6
6
@@ -11,12 +11,11 @@ fn main() {
11
11
let mut vis = vec ! [ false ; max_n + 1 ] ;
12
12
let mut rc = RangeContainer :: default ( ) ;
13
13
for _ in 0 ..100 {
14
- let mut le = rng. gen_range ( 0 ..max_n) ;
15
- let mut ri = rng. gen_range ( 0 ..max_n) ;
14
+ let mut le = rng. gen_range ( 0 ..= max_n) ;
15
+ let mut ri = rng. gen_range ( 0 ..= max_n) ;
16
16
if le > ri {
17
17
( le, ri) = ( ri, le) ;
18
18
}
19
- ri += 1 ;
20
19
match rng. gen_range ( 0 ..2 ) {
21
20
0 => {
22
21
rc. insert_range ( le as i32 ..ri as i32 ) ;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ pub mod binary_trie;
3
3
pub mod disjoint_rmq;
4
4
pub mod fenwick;
5
5
pub mod lazy_seg_tree;
6
+ pub mod range_container;
6
7
pub mod rmq;
7
8
pub mod seg_tree;
8
9
pub mod trie;
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ use std::ops::Range;
5
5
6
6
/// # Example
7
7
/// ```
8
- /// use programming_team_code_rust::helpers ::range_container::RangeContainer;
8
+ /// use programming_team_code_rust::data_structures ::range_container::RangeContainer;
9
9
///
10
10
/// let mut rc = RangeContainer::default();
11
11
/// rc.insert_range(-2..2);
@@ -45,6 +45,9 @@ impl<T: Copy + Ord> RangeContainer<T> {
45
45
/// - Time: O(log n) ammortized
46
46
/// - Space: O(1) ammortized
47
47
pub fn insert_range ( & mut self , mut range : Range < T > ) {
48
+ if range. is_empty ( ) {
49
+ return ;
50
+ }
48
51
if let Some ( last_ri) = self . remove ( & range) {
49
52
range. end = std:: cmp:: max ( range. end , last_ri) ;
50
53
}
@@ -63,6 +66,9 @@ impl<T: Copy + Ord> RangeContainer<T> {
63
66
/// - Time: O(log n) ammortized
64
67
/// - Space: O(1) ammortized
65
68
pub fn remove_range ( & mut self , range : Range < T > ) {
69
+ if range. is_empty ( ) {
70
+ return ;
71
+ }
66
72
if let Some ( last_ri) = self . remove ( & range) {
67
73
if range. end < last_ri {
68
74
self . mp . insert ( range. end , last_ri) ;
Original file line number Diff line number Diff line change 1
1
//! # Helpers
2
2
pub mod compress;
3
3
pub mod lis;
4
- pub mod range_container;
5
4
pub mod unsafe_recursive_closure;
You can’t perform that action at this time.
0 commit comments