File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ // https://atcoder.jp/contests/abc166/tasks/abc166_b
2
+ //
3
+ // 以下のクレートを使用。
4
+ // - `itertools`
5
+ // - `proconio`
6
+
7
+ use itertools:: Itertools as _;
8
+ use proconio:: { input, marker:: Usize1 } ;
9
+
10
+ fn main ( ) {
11
+ // `proconio::input!`には`n: usize, xs: [T; n]`のかわりに`xs: [T]`と書ける機能がある。
12
+ // この機能を用いることで今回のような入力をシンプルにできる。
13
+ //
14
+ // https://docs.rs/proconio/0.3.6/proconio/macro.input.html
15
+ input ! {
16
+ n: usize ,
17
+ ass: [ [ Usize1 ] ] ,
18
+ }
19
+
20
+ // `Itertools::unique`で要素の重複が省かれたイテレータが手に入る。
21
+ //
22
+ // https://docs.rs/itertools/0.9.0/itertools/trait.Itertools.html#method.unique
23
+ let ans = n - ass. into_iter ( ) . flatten ( ) . unique ( ) . count ( ) ;
24
+
25
+ // あるいは`fixedbitset::FixedBitSet`を使っても良い。
26
+ // `FixedBitSet`は`FromIterator<usize>`であり、`count_ones`という「`1`」を数えるメソッドを持つ。
27
+ //
28
+ // https://docs.rs/fixedbitset/0.2.0/fixedbitset/struct.FixedBitSet.html
29
+ // https://docs.rs/fixedbitset/0.2.0/fixedbitset/struct.FixedBitSet.html#method.count_ones
30
+ //use fixedbitset::FixedBitSet;
31
+ //let ans = n - ass
32
+ // .into_iter()
33
+ // .flatten()
34
+ // .collect::<FixedBitSet>()
35
+ // .count_ones(..);
36
+
37
+ println ! ( "{}" , ans) ;
38
+ }
Original file line number Diff line number Diff line change @@ -247,6 +247,13 @@ url = "https://atcoder.jp/contests/abc165/tasks/abc165_c"
247
247
matching = " Words"
248
248
meta = { using = [" itertools" , " proconio" ] }
249
249
250
+ [examples .abc166-b ]
251
+ type = " Normal"
252
+ name = " ABC166 - B - Trick or Treat"
253
+ url = " https://atcoder.jp/contests/abc166/tasks/abc166_b"
254
+ matching = " Words"
255
+ meta = { using = [" itertools" , " proconio" ] }
256
+
250
257
[examples .agc020-c ]
251
258
type = " Normal"
252
259
name = " AGC020: C - Median Sum"
You can’t perform that action at this time.
0 commit comments