結果

問題 No.3109 Swap members
ユーザー zer0-star
提出日時 2025-04-19 00:29:57
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 1,122 bytes
コンパイル時間 13,177 ms
コンパイル使用メモリ 399,040 KB
実行使用メモリ 17,280 KB
最終ジャッジ日時 2025-04-19 00:30:14
合計ジャッジ時間 16,350 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: constant `DIRS` is never used
 --> src/main.rs:3:7
  |
3 | const DIRS: [(isize, isize); 4] = [(0, 1), (1, 0), (0, -1), (-1, 0)];
  |       ^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: trait `OrdExt` is never used
 --> src/main.rs:5:7
  |
5 | trait OrdExt {
  |       ^^^^^^

warning: variable `N` should have a snake case name
  --> src/main.rs:33:9
   |
33 |         N: usize,
   |         ^ help: convert the identifier to snake case: `n`
   |
   = note: `#[warn(non_snake_case)]` on by default

warning: variable `K` should have a snake case name
  --> src/main.rs:34:9
   |
34 |         K: usize,
   |         ^ help: convert the identifier to snake case (notice the capitalization): `k`

warning: variable `S` should have a snake case name
  --> src/main.rs:35:9
   |
35 |         S: [String; N],
   |         ^ help: convert the identifier to snake case (notice the capitalization): `s`

warning: variable `T` should have a snake case name
  --> src/main.rs:36:9
   |
36 |         T: [String; N],
   |         ^ help: convert the identifier to snake case: `t`

warning: variable `S2` should have a snake case name
  --> src/main.rs:42:17
   |
42 |         let mut S2 = S.iter().skip(k).step_by(K).cloned().collect::<Vec<_>>();
   |                 ^^ help: convert the identifier to snake case (notice the capitalization): `s2`

warning: variable `T2` should have a snake case name
  --> src/main.rs:43:17
   |
43 |         let mut T2 = T.iter().skip(k).step_by(K).cloned().collect::<Vec<_>>();
   |                 ^^ help: convert the identifier to snake case: `t2`

ソースコード

diff #

use proconio::{fastout, input};

const DIRS: [(isize, isize); 4] = [(0, 1), (1, 0), (0, -1), (-1, 0)];

trait OrdExt {
    fn chmax(&mut self, other: Self) -> bool;
    fn chmin(&mut self, other: Self) -> bool;
}

impl<T: Ord> OrdExt for T {
    fn chmax(&mut self, other: Self) -> bool {
        if *self < other {
            *self = other;
            true
        } else {
            false
        }
    }

    fn chmin(&mut self, other: Self) -> bool {
        if *self > other {
            *self = other;
            true
        } else {
            false
        }
    }
}

#[fastout]
fn main() {
    input! {
        N: usize,
        K: usize,
        S: [String; N],
        T: [String; N],
    }

    let mut isok = true;

    for k in 0..K {
        let mut S2 = S.iter().skip(k).step_by(K).cloned().collect::<Vec<_>>();
        let mut T2 = T.iter().skip(k).step_by(K).cloned().collect::<Vec<_>>();
        S2.sort();
        T2.sort();

        if S2 != T2 {
            isok = false;
            break;
        }
    }

    if isok {
        println!("Yes");
    } else {
        println!("No");
    }
}
0