結果

問題 No.482 あなたの名は
ユーザー 💕💖💞💕💖💞
提出日時 2017-07-22 23:53:29
言語 Rust
(1.72.1)
結果
WA  
実行時間 -
コード長 947 bytes
コンパイル時間 1,010 ms
コンパイル使用メモリ 154,132 KB
実行使用メモリ 8,124 KB
最終ジャッジ日時 2023-07-30 14:54:48
合計ジャッジ時間 2,779 ms
ジャッジサーバーID
(参考情報)
judge15 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 WA -
testcase_13 AC 1 ms
4,380 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 36 ms
8,096 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 36 ms
8,112 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 35 ms
8,100 KB
testcase_24 AC 36 ms
8,020 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused imports: `HashMap`, `LinkedList`
 --> Main.rs:2:24
  |
2 | use std::collections::{HashMap, LinkedList};
  |                        ^^^^^^^  ^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unnecessary parentheses around `for` iterator expression
  --> Main.rs:17:12
   |
17 |   for i in (0..v.len()) {
   |            ^          ^
   |
   = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
   |
17 -   for i in (0..v.len()) {
17 +   for i in 0..v.len() {
   |

warning: unused variable: `n`
 --> Main.rs:9:8
  |
9 |   let (n, k) = (v[0], v[1]);
  |        ^ help: if this is intentional, prefix it with an underscore: `_n`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: variable does not need to be mutable
  --> Main.rs:19:11
   |
19 |       let mut toswap = v[i];
   |           ----^^^^^^
   |           |
   |           help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

warning: 4 warnings emitted

ソースコード

diff #

use std::io::{self, BufRead};
use std::collections::{HashMap, LinkedList};

fn main() {
  let stdin  = io::stdin();
  let line   = stdin.lock().lines().next().unwrap().unwrap();
  let v      = line.split(" ").collect::<Vec<&str>>()
                .iter().map( |x| x.to_string()).map(|x| x.parse::<i32>().unwrap() ).collect::<Vec<i32>>();
  let (n, k) = (v[0], v[1]);
  let line   = stdin.lock().lines().next().unwrap().unwrap();
  let mut v  = line.split(" ").collect::<Vec<&str>>()
                .iter().map( |x| x.to_string()).map(|x| x.parse::<usize>().unwrap() - 1 ).collect::<Vec<usize>>();
  let mut va = v.clone();
  va.sort();
  let mut cnt = 0;
  
  for i in (0..v.len()) {
    if v[i] != i {
      let mut toswap = v[i];
      v[i]           = v[toswap];
      v[toswap]      = toswap;
      cnt += 1;
    }
  }
  if k < cnt {
    println!("NO");
  }else if (k - cnt)%2 == 0 { 
    println!("YES");
  }else {
    println!("NO");
  }
}
0