Skip to content

Commit 415b0b2

Browse files
committed
Example of thread with custom stack size
1 parent 25f0e6f commit 415b0b2

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ A collection of famous data structures and algorithms, emphasizing beauty and cl
55
This repository is distributed under the [MIT License](LICENSE). The license text need not be included in contest submissions, though I would appreciate linking back to this repo for others to find. Enjoy!
66

77
## Academic Programming Competitions
8+
89
The original intent of this project was to build a reference for use in programming competitions such as [Codeforces](http://codeforces.com) and the [Google Code Jam](https://code.google.com/codejam). As a result, it contains algorithms that are frequently useful to have in one's toolkit, with an emphasis on making the code concise and easy to modify in time-constrained settings.
910

1011
Most competitive programmers use C/C++ because it allows for fast coding as well as fast execution. However, these languages are notoriously unsafe, wasting a considerable share of the contestant's time and attention on accident prevention. Java is the next most popular choice, offering a bit of safety at some expense to coding and execution speed. To my delight, I found that Rust provides a lot more safety than Java without the visual clutter, and it's *fast*.

tests/example_problem.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
/*extern crate algorithms;
2-
1+
// To make a single-file Codeforces contest submission, dump the module contents
2+
// directly here instead of these use statements.
3+
extern crate algorithms;
34
use algorithms::scanner::*;
45
use algorithms::graph::*;
56

6-
#[test]
7-
fn integration() {
7+
fn main1() {
88
let mut scan = Scanner::new();
9-
let n = scan.next::<usize>();
10-
let mut tree = Graph::new(n, n-1);
11-
for e in 0..n-1 {
12-
let u = scan.next::<usize>() - 1;
13-
let v = scan.next::<usize>() - 1;
14-
tree.add_edge(u, v);
9+
let mut graph = Graph::new(1, 0);
10+
for _ in 0..0 {
11+
let u = scan.next::<usize>();
12+
let v = scan.next::<usize>();
13+
graph.add_edge(u, v);
1514
}
16-
}*/
15+
}
16+
17+
#[test]
18+
fn integration() {
19+
// If your contest solution requires a lot of stack space, make sure to
20+
// run it on a custom thread.
21+
std::thread::Builder::new().stack_size(50_000_000)
22+
.spawn(main1).unwrap().join().unwrap();
23+
}

0 commit comments

Comments
 (0)