結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2017-07-22 23:35:00 |
言語 | Rust (1.83.0 + proconio) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,110 bytes |
コンパイル時間 | 12,899 ms |
コンパイル使用メモリ | 403,104 KB |
実行使用メモリ | 7,296 KB |
最終ジャッジ日時 | 2024-10-09 10:04:48 |
合計ジャッジ時間 | 36,483 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 RE * 6 TLE * 10 |
コンパイルメッセージ
warning: unused imports: `HashMap`, `LinkedList` --> src/main.rs:2:24 | 2 | use std::collections::{HashMap, LinkedList}; | ^^^^^^^ ^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unnecessary parentheses around `for` iterator expression --> src/main.rs:16:12 | 16 | for i in (0..v.len()) { | ^ ^ | = note: `#[warn(unused_parens)]` on by default help: remove these parentheses | 16 - for i in (0..v.len()) { 16 + for i in 0..v.len() { | warning: unnecessary parentheses around `for` iterator expression --> src/main.rs:19:16 | 19 | for j in (i..v.len()) { | ^ ^ | help: remove these parentheses | 19 - for j in (i..v.len()) { 19 + for j in i..v.len() { | warning: unused variable: `n` --> src/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
ソースコード
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::<i32>().unwrap() ).collect::<Vec<i32>>(); let mut va = v.clone(); va.sort(); let mut cnt = 0; for i in (0..v.len()) { if v[i] != va[i] { let mut toswap = 0; for j in (i..v.len()) { if v[j] == va[i] { toswap = j; cnt += 1; break; } } let tmp = v[toswap].clone(); v[toswap] = v[i]; v[i] = tmp; if v == va { break; } } } if k < cnt { println!("NO"); }else if (k - cnt)%2 == 0 { println!("YES"); }else { println!("NO"); } }