結果
問題 | No.408 五輪ピック |
ユーザー | sntea |
提出日時 | 2017-10-28 15:33:59 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,845 bytes |
コンパイル時間 | 17,027 ms |
コンパイル使用メモリ | 377,948 KB |
実行使用メモリ | 7,296 KB |
最終ジャッジ日時 | 2024-11-22 03:25:08 |
合計ジャッジ時間 | 15,141 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,248 KB |
testcase_04 | AC | 1 ms
5,248 KB |
testcase_05 | AC | 11 ms
5,248 KB |
testcase_06 | AC | 9 ms
5,248 KB |
testcase_07 | AC | 12 ms
5,248 KB |
testcase_08 | AC | 9 ms
5,248 KB |
testcase_09 | AC | 9 ms
5,248 KB |
testcase_10 | AC | 9 ms
5,248 KB |
testcase_11 | AC | 8 ms
5,248 KB |
testcase_12 | AC | 14 ms
5,248 KB |
testcase_13 | AC | 12 ms
5,248 KB |
testcase_14 | AC | 4 ms
5,248 KB |
testcase_15 | AC | 13 ms
5,248 KB |
testcase_16 | AC | 14 ms
5,248 KB |
testcase_17 | AC | 13 ms
5,248 KB |
testcase_18 | AC | 14 ms
5,248 KB |
testcase_19 | AC | 15 ms
5,376 KB |
testcase_20 | AC | 5 ms
5,248 KB |
testcase_21 | AC | 3 ms
5,248 KB |
testcase_22 | AC | 8 ms
5,248 KB |
testcase_23 | AC | 28 ms
7,296 KB |
testcase_24 | WA | - |
testcase_25 | AC | 14 ms
5,504 KB |
testcase_26 | AC | 17 ms
6,144 KB |
testcase_27 | AC | 14 ms
5,248 KB |
testcase_28 | AC | 10 ms
5,248 KB |
testcase_29 | AC | 10 ms
5,248 KB |
testcase_30 | AC | 1 ms
5,248 KB |
testcase_31 | AC | 1 ms
5,248 KB |
コンパイルメッセージ
warning: unused macro definition: `readlvec` --> src/main.rs:29:14 | 29 | macro_rules! readlvec { | ^^^^^^^^ | = note: `#[warn(unused_macros)]` on by default warning: unused macro definition: `mvec` --> src/main.rs:39:14 | 39 | macro_rules! mvec { | ^^^^ warning: unused macro definition: `debug` --> src/main.rs:48:14 | 48 | macro_rules! debug { | ^^^^^ warning: function `printiter` is never used --> src/main.rs:54:4 | 54 | fn printiter<'a, T>(v: &'a T) | ^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: method `size` is never used --> src/main.rs:122:8 | 114 | impl Graph { | ---------- method in this implementation ... 122 | fn size(&self) -> usize{ | ^^^^
ソースコード
// use std::ops::{Index, IndexMut}; // use std::cmp::{Ordering, min, max}; // use std::collections::{BinaryHeap, BTreeMap}; // use std::collections::btree_map::Entry::{Occupied, Vacant}; // use std::clone::Clone; fn getline() -> String{ let mut res = String::new(); std::io::stdin().read_line(&mut res).ok(); res } macro_rules! readl { ($t: ty) => { { let s = getline(); s.trim().parse::<$t>().unwrap() } }; ($( $t: ty),+ ) => { { let s = getline(); let mut iter = s.trim().split(' '); ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) } }; } macro_rules! readlvec { ($t: ty) => { { let s = getline(); let iter = s.trim().split(' '); iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>() } } } macro_rules! mvec { ($v: expr, $s: expr) => { vec![$v; $s] }; ($v: expr, $s: expr, $($t: expr),*) => { vec![mvec!($v, $($t),*); $s] }; } macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } } fn printiter<'a, T>(v: &'a T) where &'a T: std::iter::IntoIterator, <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display { for (i,e) in v.into_iter().enumerate() { if i != 0 { print!(" "); } print!("{}", e); } println!(""); } type Cost = i64; #[derive(Clone)] struct Edge { to: usize, cost: Cost, } impl Ord for Edge { fn cmp(&self, other: &Edge) -> std::cmp::Ordering { (-self.cost).cmp(&(-other.cost)) } } impl PartialOrd for Edge { fn partial_cmp(&self, other: &Edge) -> Option<std::cmp::Ordering> { Some(self.cmp(other)) } } impl Eq for Edge {} impl PartialEq for Edge { fn eq(&self, other: &Edge) -> bool { self.cost == other.cost } } #[derive(Clone)] struct Graph { adj: Vec<Vec<Edge>>, } impl std::ops::Index<usize> for Graph { type Output = Vec<Edge>; fn index(&self, i: usize) -> &Vec<Edge> { &self.adj[i] } } impl std::ops::IndexMut<usize> for Graph { fn index_mut<'a>(&'a mut self, i: usize) -> &'a mut Vec<Edge> { &mut self.adj[i] } } impl Graph { fn new(n: usize) -> Graph{ Graph { adj: vec![vec![]; n], } } fn size(&self) -> usize{ self.adj.capacity() } fn add_edge(&mut self, from: usize, to_: usize, cost_: Cost) { self.adj[from].push(Edge{to: to_, cost: cost_}); } fn add_uedge(&mut self, from: usize, to_: usize, cost_: Cost) { self.add_edge(from, to_, cost_); self.add_edge(to_, from, cost_); } } use std::collections::HashSet; fn main() { let (n, m) = readl!(usize, usize); let g = { let mut g = Graph::new(n); for _ in 0..m { let (a, b) = readl!(usize, usize); g.add_uedge(a-1, b-1, -1); } g }; let mut pa = vec![HashSet::new(); n]; for e1 in &g[0] { for e2 in &g[e1.to] { if e2.to != 0 { pa[e2.to].insert(e1.to); } } } let pa: Vec<Vec<_>> = pa.into_iter().map(|s| { s.into_iter().collect() }).collect(); let mut f = false; for p in 0..n { for e in &g[p] { if pa[p].len() == 0 || pa[e.to].len() == 0 { continue; } if pa[p].len() == 1 && pa[e.to].len() == 1 { let a = pa[p][0]; let b = pa[e.to][0]; if a != b && a != e.to && b != p { f = true; } } else { f = true; } } } if f { println!("YES"); } else { println!("NO"); } }