Skip to content

Commit bef65bd

Browse files
committed
Solve D in abc209
1 parent e285cd1 commit bef65bd

File tree

14 files changed

+1088
-0
lines changed

14 files changed

+1088
-0
lines changed

atcoder/rust/abc209/Cargo.lock

Lines changed: 638 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

atcoder/rust/abc209/Cargo.toml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
[package]
2+
name = "abc209"
3+
version = "0.1.0"
4+
authors = ["k-yomo <kanji.yy@gmail.com>"]
5+
edition = "2018"
6+
7+
[package.metadata.cargo-compete]
8+
config = "../compete.toml"
9+
10+
[package.metadata.cargo-compete.bin]
11+
a = { name = "abc209-a", problem = { platform = "atcoder", contest = "abc209", index = "A", url = "https://atcoder.jp/contests/abc209/tasks/abc209_a" } }
12+
b = { name = "abc209-b", problem = { platform = "atcoder", contest = "abc209", index = "B", url = "https://atcoder.jp/contests/abc209/tasks/abc209_b" } }
13+
c = { name = "abc209-c", problem = { platform = "atcoder", contest = "abc209", index = "C", url = "https://atcoder.jp/contests/abc209/tasks/abc209_c" } }
14+
d = { name = "abc209-d", problem = { platform = "atcoder", contest = "abc209", index = "D", url = "https://atcoder.jp/contests/abc209/tasks/abc209_d" } }
15+
e = { name = "abc209-e", problem = { platform = "atcoder", contest = "abc209", index = "E", url = "https://atcoder.jp/contests/abc209/tasks/abc209_e" } }
16+
f = { name = "abc209-f", problem = { platform = "atcoder", contest = "abc209", index = "F", url = "https://atcoder.jp/contests/abc209/tasks/abc209_f" } }
17+
18+
[[bin]]
19+
name = "abc209-a"
20+
path = "src/bin/a.rs"
21+
22+
[[bin]]
23+
name = "abc209-b"
24+
path = "src/bin/b.rs"
25+
26+
[[bin]]
27+
name = "abc209-c"
28+
path = "src/bin/c.rs"
29+
30+
[[bin]]
31+
name = "abc209-d"
32+
path = "src/bin/d.rs"
33+
34+
[[bin]]
35+
name = "abc209-e"
36+
path = "src/bin/e.rs"
37+
38+
[[bin]]
39+
name = "abc209-f"
40+
path = "src/bin/f.rs"
41+
[dependencies]
42+
num = "=0.2.1"
43+
num-bigint = "=0.2.6"
44+
num-complex = "=0.2.4"
45+
num-integer = "=0.1.42"
46+
num-iter = "=0.1.40"
47+
num-rational = "=0.2.4"
48+
num-traits = "=0.2.11"
49+
num-derive = "=0.3.0"
50+
ndarray = "=0.13.0"
51+
nalgebra = "=0.20.0"
52+
alga = "=0.9.3"
53+
libm = "=0.2.1"
54+
rand = { version = "=0.7.3", features = ["small_rng"] }
55+
getrandom = "=0.1.14"
56+
rand_chacha = "=0.2.2"
57+
rand_core = "=0.5.1"
58+
rand_hc = "=0.2.0"
59+
rand_pcg = "=0.2.1"
60+
rand_distr = "=0.2.2"
61+
petgraph = "=0.5.0"
62+
indexmap = "=1.3.2"
63+
regex = "=1.3.6"
64+
lazy_static = "=1.4.0"
65+
ordered-float = "=1.0.2"
66+
ascii = "=1.0.0"
67+
permutohedron = "=0.2.4"
68+
superslice = "=1.0.0"
69+
itertools = "=0.9.0"
70+
itertools-num = "=0.1.3"
71+
maplit = "=1.0.2"
72+
either = "=1.5.3"
73+
im-rc = "=14.3.0"
74+
fixedbitset = "=0.2.0"
75+
bitset-fixed = "=0.1.0"
76+
proconio = { version = "=0.3.6", features = ["derive"] }
77+
text_io = "=0.1.8"
78+
whiteread = "=0.5.0"
79+
rustc-hash = "=1.1.0"
80+
smallvec = "=1.2.0"

atcoder/rust/abc209/src/bin/a.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![allow(unused_imports)]
2+
3+
use std::cmp::*;
4+
use std::collections::*;
5+
use std::io::Write;
6+
use std::ops::Bound::*;
7+
8+
use itertools::__std_iter::once;
9+
use itertools::*;
10+
use itertools_num::ItertoolsNum;
11+
use proconio::marker::*;
12+
use proconio::*;
13+
use superslice::*;
14+
15+
fn main() {
16+
input! {
17+
a: usize, b: usize,
18+
}
19+
if a >= b {
20+
println!("0")
21+
} else {
22+
println!("{}", b - a + 1)
23+
}
24+
}

atcoder/rust/abc209/src/bin/b.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#![allow(unused_imports)]
2+
3+
use std::cmp::*;
4+
use std::collections::*;
5+
use std::io::Write;
6+
use std::ops::Bound::*;
7+
8+
use itertools::__std_iter::once;
9+
use itertools::*;
10+
use itertools_num::ItertoolsNum;
11+
use proconio::marker::*;
12+
use proconio::*;
13+
use superslice::*;
14+
15+
fn main() {
16+
input! {
17+
n: usize, mut x: i128,
18+
a: [i128; n],
19+
}
20+
21+
for (i, &v) in a.iter().enumerate() {
22+
x -= if i % 2 != 0 { v - 1 } else { v };
23+
}
24+
if x < 0 {
25+
return println!("No");
26+
}
27+
println!("Yes")
28+
}

atcoder/rust/abc209/src/bin/c.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#![allow(unused_imports)]
2+
3+
use std::cmp::*;
4+
use std::collections::*;
5+
use std::io::Write;
6+
use std::ops::Bound::*;
7+
8+
use itertools::__std_iter::once;
9+
use itertools::*;
10+
use itertools_num::ItertoolsNum;
11+
use proconio::marker::*;
12+
use proconio::*;
13+
use superslice::*;
14+
15+
fn main() {
16+
input! {
17+
n: usize,
18+
c: [usize; n],
19+
}
20+
}

atcoder/rust/abc209/src/bin/d.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#![allow(unused_imports)]
2+
3+
use std::cmp::*;
4+
use std::collections::*;
5+
use std::io::Write;
6+
use std::ops::Bound::*;
7+
8+
use itertools::*;
9+
use itertools::__std_iter::once;
10+
use itertools_num::ItertoolsNum;
11+
use proconio::*;
12+
use proconio::marker::*;
13+
use superslice::*;
14+
use std::{cmp::Reverse, collections::BinaryHeap};
15+
use std::iter::Map;
16+
17+
fn main() {
18+
input! {
19+
n: usize, q: usize,
20+
ab: [(usize, usize); n-1],
21+
cd: [(usize, usize); q],
22+
}
23+
24+
25+
let mut queue = VecDeque::new();
26+
let mut colors = vec![-1; n];
27+
colors[0] = 0;
28+
queue.push_back(0);
29+
30+
let mut paths = vec![vec![]; n];
31+
for (a, b) in ab {
32+
paths[a-1].push(b-1);
33+
paths[b-1].push(a-1);
34+
}
35+
36+
loop {
37+
if queue.is_empty() {
38+
break
39+
}
40+
let town = queue.pop_front().unwrap();
41+
for &i in paths[town].iter() {
42+
if colors[i] == -1 {
43+
colors[i] = 1 - colors[town];
44+
queue.push_back(i)
45+
}
46+
}
47+
}
48+
49+
for (c, d) in cd {
50+
if colors[c-1] == colors[d-1] {
51+
println!("Town");
52+
} else {
53+
println!("Road")
54+
}
55+
}
56+
}

atcoder/rust/abc209/src/bin/e.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![allow(unused_imports)]
2+
3+
use std::cmp::*;
4+
use std::collections::*;
5+
use std::io::Write;
6+
use std::ops::Bound::*;
7+
8+
use itertools::*;
9+
use itertools::__std_iter::once;
10+
use itertools_num::ItertoolsNum;
11+
use proconio::*;
12+
use proconio::marker::*;
13+
use superslice::*;
14+
15+
fn main() {
16+
input! {
17+
18+
}
19+
}

atcoder/rust/abc209/src/bin/f.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![allow(unused_imports)]
2+
3+
use std::cmp::*;
4+
use std::collections::*;
5+
use std::io::Write;
6+
use std::ops::Bound::*;
7+
8+
use itertools::*;
9+
use itertools::__std_iter::once;
10+
use itertools_num::ItertoolsNum;
11+
use proconio::*;
12+
use proconio::marker::*;
13+
use superslice::*;
14+
15+
fn main() {
16+
input! {
17+
18+
}
19+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
type: Batch
3+
timelimit: 2s
4+
match: Lines
5+
6+
cases:
7+
- name: sample1
8+
in: |
9+
2 4
10+
out: |
11+
3
12+
- name: sample2
13+
in: |
14+
10 100
15+
out: |
16+
91
17+
- name: sample3
18+
in: |
19+
3 2
20+
out: |
21+
0
22+
23+
extend: []
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
type: Batch
3+
timelimit: 2s
4+
match: Lines
5+
6+
cases:
7+
- name: sample1
8+
in: |
9+
2 3
10+
1 3
11+
out: |
12+
Yes
13+
- name: sample2
14+
in: |
15+
4 10
16+
3 3 4 4
17+
out: |
18+
No
19+
- name: sample3
20+
in: |
21+
8 30
22+
3 1 4 1 5 9 2 6
23+
out: |
24+
Yes
25+
26+
extend: []

0 commit comments

Comments
 (0)