File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ // https://atcoder.jp/contests/abc168/tasks/abc168_b
2
+ //
3
+ // 以下のクレートを使用。
4
+ // - `ascii`
5
+ // - `proconio`
6
+
7
+ use ascii:: { AsciiStr , AsciiString } ;
8
+ use proconio:: input;
9
+
10
+ fn main ( ) {
11
+ // `str`/`String`や`[u8]`/`Vec<u8>`のかわりに`ascii::AsciiStr`/`ascii/AsciiString`を使うことができる。
12
+ //
13
+ // https://docs.rs/ascii/1.0.0/ascii/struct.AsciiStr.html
14
+ // https://docs.rs/ascii/1.0.0/ascii/struct.AsciiString.html
15
+
16
+ // `proconio::input!`。
17
+ //
18
+ // https://docs.rs/proconio/0.3.6/proconio/macro.input.html
19
+ input ! {
20
+ k: usize ,
21
+ mut s: AsciiString ,
22
+ }
23
+
24
+ if s. len ( ) > k {
25
+ s. truncate ( k) ;
26
+ s += AsciiStr :: from_ascii ( b"..." ) . unwrap ( ) ;
27
+ }
28
+
29
+ println ! ( "{}" , s) ;
30
+ }
31
+
32
+ // 参考: Sを`Vec<u8>`で取った場合
33
+ const _: fn ( ) = || {
34
+ use proconio:: marker:: Bytes ;
35
+
36
+ input ! {
37
+ k: usize ,
38
+ mut s: Bytes ,
39
+ }
40
+
41
+ if s. len ( ) > k {
42
+ s. truncate ( k) ;
43
+ s. extend_from_slice ( b"..." ) ;
44
+ }
45
+
46
+ println ! ( "{}" , String :: from_utf8( s) . unwrap( ) ) ;
47
+ } ;
Original file line number Diff line number Diff line change @@ -254,6 +254,13 @@ url = "https://atcoder.jp/contests/abc166/tasks/abc166_b"
254
254
matching = " Words"
255
255
meta = { using = [" itertools" , " proconio" ] }
256
256
257
+ [examples .abc168-b ]
258
+ type = " Normal"
259
+ name = " ABC168 - B - ... (Triple Dots)"
260
+ url = " https://atcoder.jp/contests/abc168/tasks/abc168_b"
261
+ matching = " Words"
262
+ meta = { using = [" ascii" , " proconio" ] }
263
+
257
264
[examples .agc020-c ]
258
265
type = " Normal"
259
266
name = " AGC020: C - Median Sum"
You can’t perform that action at this time.
0 commit comments