Skip to content

Commit 16a9595

Browse files
committed
Add an example for ABC168-B
1 parent c867fec commit 16a9595

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

examples/abc168-b.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
};

test-examples.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,13 @@ url = "https://atcoder.jp/contests/abc166/tasks/abc166_b"
254254
matching = "Words"
255255
meta = { using = ["itertools", "proconio"] }
256256

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+
257264
[examples.agc020-c]
258265
type = "Normal"
259266
name = "AGC020: C - Median Sum"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy