結果
| 問題 | No.497 入れ子の箱 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-06-21 21:05:04 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,670 bytes |
| 記録 | |
| コンパイル時間 | 11,614 ms |
| コンパイル使用メモリ | 388,748 KB |
| 実行使用メモリ | 13,880 KB |
| 最終ジャッジ日時 | 2024-10-02 11:46:25 |
| 合計ジャッジ時間 | 18,674 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | TLE * 1 -- * 28 |
ソースコード
#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };
#[allow(unused_macros)]
macro_rules! trace {
($var:expr) => ({
let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
})
}
#[allow(unused_macros)]
macro_rules! swap { ($a:expr, $b:expr) => ({ let t = $b; $b = $a; $a = t; }) }
struct Hako(i32, i32, i32);
fn can_include(a: &Hako, b: &Hako) -> bool {
let Hako(x1, y1, z1) = *a;
let Hako(x2, y2, z2) = *b;
if x1 > x2 && y1 > y2 && z1 > z2 { return true }
if x1 > x2 && y1 > z2 && z1 > y2 { return true }
if x1 > y2 && y1 > x2 && z1 > z2 { return true }
if x1 > y2 && y1 > z2 && z1 > x2 { return true }
if x1 > z2 && y1 > x2 && z1 > y2 { return true }
if x1 > z2 && y1 > y2 && z1 > x2 { return true }
false
}
fn main() {
let mut sc = Scanner::new();
let n: usize = sc.cin();
let mut hakos = vec![];
for _ in 0..n {
let x: i32 = sc.cin();
let y: i32 = sc.cin();
let z: i32 = sc.cin();
hakos.push(Hako(x, y, z));
}
let mut neigh = vec![vec![]; n];
for i in 0..n {
for j in 0..n {
if can_include(&hakos[i], &hakos[j]) {
neigh[i].push(j);
}
}
}
let mut max_length = 0;
for root in 0..n {
let mut s = vec![(root, 1)];
while let Some((u, length)) = s.pop() {
max_length = max(max_length, length);
for &v in neigh[u].iter() {
s.push((v, length + 1));
}
}
}
println!("{}", max_length);
}
#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
fn reserve(&mut self) {
while self.buffer.len() == 0 {
let mut line = String::new();
let _ = self.stdin.read_line(&mut line);
for w in line.split_whitespace() {
self.buffer.push_back(String::from(w));
}
}
}
fn cin<T: FromStr>(&mut self) -> T {
self.reserve();
match self.buffer.pop_front().unwrap().parse::<T>() {
Ok(a) => a,
Err(_) => panic!("parse err")
}
}
fn get_char(&mut self) -> char {
self.reserve();
let head = self.buffer[0].chars().nth(0).unwrap();
let tail = String::from( &self.buffer[0][1..] );
if tail.len()>0 { self.buffer[0]=tail } else { self.buffer.pop_front(); }
head
}
}