0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

初心者プログラマーAtCoderに挑んだ軌跡-ABC416-A-

Posted at

ABC416-A

問題の内容

文字列が一致しているか判定

言語

Rust

解法

指定箇所を借用し切り抜いて一致判定

課題

  • 文字列スライス→ABC417-A→今回はNG
  • 中に"x"が含まれるか→ABC418-A→s.contains("x")

学んだこと

  • ABC417-Aの文字列スライスはバイト単位ためUTF-8では機能しなくなる
  • .collect() → イテレータをまとめてコレクション
  • .skip(n) → n個の要素を飛ばす
  • .take(n) → 最初のn個を取る
    .slip(n).take(m).collect()
    → n+1個目から数えてm個を取りだしコレクション

提出内容

use proconio::input;

fn main() {
  input! {
    n: usize,
    l: usize,
    r: usize,
    s: String,
  }
  let result: String = s.chars().skip(l - 1).take(r - l + 1).collect();
  if result.contains("x") {
    println!("No");
  } else {
    println!("Yes");
  }
}

成績

  • 278Byte
  • AC
  • 1ms
  • 2012KiB
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?