結果
問題 | No.517 壊れたアクセサリー |
ユーザー | gyu-don |
提出日時 | 2017-07-27 20:27:15 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,741 bytes |
コンパイル時間 | 12,648 ms |
コンパイル使用メモリ | 384,036 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-10 02:12:33 |
合計ジャッジ時間 | 13,748 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | WA | - |
testcase_04 | AC | 1 ms
5,248 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | RE | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | RE | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
コンパイルメッセージ
warning: unused import: `std::io::prelude` --> src/main.rs:1:5 | 1 | use std::io::prelude::*; | ^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unused variable: `i` --> src/main.rs:26:9 | 26 | for i in 0..n { | ^ help: if this is intentional, prefix it with an underscore: `_i` | = note: `#[warn(unused_variables)]` on by default warning: unused variable: `i` --> src/main.rs:54:9 | 54 | for i in 0..n { | ^ help: if this is intentional, prefix it with an underscore: `_i`
ソースコード
use std::io::prelude::*; use std::io::stdin; use std::fmt::Debug; use std::str; #[derive(Debug, Clone)] struct List { pub prev: Option<usize>, pub next: Option<usize>, pub used: bool, } fn main() { let mut list: Vec<List> = vec![List { prev: None, next: None, used: false }; 26]; let n: usize = { let mut s = String::new(); stdin().read_line(&mut s).unwrap(); s.trim().parse().unwrap() }; if n == 1 { let mut s = String::new(); stdin().read_line(&mut s).unwrap(); println!("{}", s.trim()); return; } for i in 0..n { let mut s = String::new(); stdin().read_line(&mut s).unwrap(); if s.trim().len() == 1 { let i = (s.as_bytes()[0] - 'A' as u8) as usize; list[i].used = true; } for b in s.trim().as_bytes().windows(2) { let i = (b[0] - 'A' as u8) as usize; let j = (b[1] - 'A' as u8) as usize; list[i].next = Some(j); list[j].prev = Some(i); list[i].used = true; list[j].used = true; } } let n: usize = { let mut s = String::new(); stdin().read_line(&mut s).unwrap(); s.trim().parse().unwrap() }; if n == 1 { let mut s = String::new(); stdin().read_line(&mut s).unwrap(); //println!("{}", s.trim()); return; } for i in 0..n { let mut s = String::new(); stdin().read_line(&mut s).unwrap(); if s.trim().len() == 1 { let i = (s.as_bytes()[0] - 'A' as u8) as usize; list[i].used = true; } for b in s.trim().as_bytes().windows(2) { let i = (b[0] - 'A' as u8) as usize; let j = (b[1] - 'A' as u8) as usize; list[i].next = Some(j); list[j].prev = Some(i); list[i].used = true; list[j].used = true; } } let mut cursor = None; let mut s = vec![]; let mut count = 0; for (i,c) in list.iter().enumerate() { if c.prev.is_none() && c.next.is_some() { assert!(cursor.is_none()); cursor = c.next.clone(); s.push(i as u8 + 'A' as u8); } if c.used { count += 1; println!("{}: {:?}", (i as u8 + 'A' as u8) as char, c); } } if cursor.is_none() { println!("-1"); } else { while cursor.is_some() { let n = *cursor.as_ref().unwrap(); s.push(n as u8 + 'A' as u8); cursor = list[n].next; } } if s.len() != count { println!("-1"); } else { println!("{}", str::from_utf8(&s).unwrap()); } }