結果
問題 | No.1703 Much Matching |
ユーザー | Moss_Local |
提出日時 | 2021-10-08 22:50:11 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 12,666 bytes |
コンパイル時間 | 12,730 ms |
コンパイル使用メモリ | 403,668 KB |
実行使用メモリ | 31,556 KB |
最終ジャッジ日時 | 2024-07-23 05:58:00 |
合計ジャッジ時間 | 16,524 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
コンパイルメッセージ
warning: unnecessary parentheses around type --> src/main.rs:115:15 | 115 | fn readi() -> (i64) { | ^ ^ | = note: `#[warn(unused_parens)]` on by default help: remove these parentheses | 115 - fn readi() -> (i64) { 115 + fn readi() -> i64 { | warning: unused variable: `n` --> src/main.rs:423:10 | 423 | let (n, m, q) = readuuu(); | ^ help: if this is intentional, prefix it with an underscore: `_n` | = note: `#[warn(unused_variables)]` on by default warning: unused variable: `m` --> src/main.rs:423:13 | 423 | let (n, m, q) = readuuu(); | ^ help: if this is intentional, prefix it with an underscore: `_m` warning: unused variable: `i` --> src/main.rs:426:9 | 426 | for i in 0..q { | ^ help: if this is intentional, prefix it with an underscore: `_i` warning: variable `INF` should have a snake case name --> src/main.rs:306:21 | 306 | let INF = 2_000_000_001; | ^^^ help: convert the identifier to snake case: `inf` | = note: `#[warn(non_snake_case)]` on by default
ソースコード
// -*- coding:utf-8-unix -*- // #![feature(map_first_last)] #![allow(dead_code)] #![allow(unused_imports)] #![allow(unused_macros)] use std::arch::x86_64::_XCR_XFEATURE_ENABLED_MASK; use std::cmp::Ordering::*; use std::collections::*; use std::convert::*; use std::convert::{From, Into}; use std::f64::consts::PI; use std::fmt::Debug; use std::fmt::Display; use std::fs::File; use std::hash::Hash; use std::io::prelude::*; use std::io::*; use std::marker::Copy; use std::mem::*; use std::ops::Bound::*; use std::ops::{Add, Mul, Neg, Sub}; use std::str; use std::vec; use std::{cmp, process::Output}; use std::{cmp::Ordering, env::consts::DLL_PREFIX}; const INF: i64 = 1223372036854775807; const UINF: usize = INF as usize; // const FINF: f64 = 122337203685.0; const LINF: i64 = 2147483647; const FINF: f64 = LINF as f64; const INF128: i128 = 1223372036854775807000000000000; const MOD: i64 = 1000000007; // const MOD: i64 = 998244353; const MPI: f64 = 3.14159265358979323846264338327950288f64; // const MOD: i64 = INF; const UMOD: usize = MOD as usize; use std::cmp::*; use std::collections::*; use std::io::stdin; use std::io::stdout; use std::io::Write; macro_rules! p { ($x:expr) => { println!("{}", $x); }; } macro_rules! d { ($x:expr) => { println!("{:?}", $x); }; } macro_rules! chmin { ($base:expr, $($cmps:expr),+ $(,)*) => {{ let cmp_min = min!($($cmps),+); if $base > cmp_min { $base = cmp_min; true } else { false } }}; } macro_rules! chmax { ($base:expr, $($cmps:expr),+ $(,)*) => {{ let cmp_max = max!($($cmps),+); if $base < cmp_max { $base = cmp_max; true } else { false } }}; } macro_rules! min { ($a:expr $(,)*) => {{ $a }}; ($a:expr, $b:expr $(,)*) => {{ std::cmp::min($a, $b) }}; ($a:expr, $($rest:expr),+ $(,)*) => {{ std::cmp::min($a, min!($($rest),+)) }}; } macro_rules! max { ($a:expr $(,)*) => {{ $a }}; ($a:expr, $b:expr $(,)*) => {{ std::cmp::max($a, $b) }}; ($a:expr, $($rest:expr),+ $(,)*) => {{ std::cmp::max($a, max!($($rest),+)) }}; } // use str::Chars; // use str::Chars; #[allow(dead_code)] fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } #[allow(dead_code)] fn readi() -> (i64) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); iter.next().unwrap().parse::<i64>().unwrap() } #[allow(dead_code)] fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() } #[allow(dead_code)] fn read_mat<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> { (0..n).map(|_| read_vec()).collect() } #[allow(dead_code)] fn readii() -> (i64, i64) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::<i64>().unwrap(), iter.next().unwrap().parse::<i64>().unwrap(), ) } fn readff() -> (f64, f64) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::<f64>().unwrap(), iter.next().unwrap().parse::<f64>().unwrap(), ) } #[allow(dead_code)] fn readiii() -> (i64, i64, i64) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::<i64>().unwrap(), iter.next().unwrap().parse::<i64>().unwrap(), iter.next().unwrap().parse::<i64>().unwrap(), ) } #[allow(dead_code)] fn readuu() -> (usize, usize) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::<usize>().unwrap(), iter.next().unwrap().parse::<usize>().unwrap(), ) } fn readcc() -> (char, char) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::<char>().unwrap(), iter.next().unwrap().parse::<char>().unwrap(), ) } #[allow(dead_code)] fn readuuu() -> (usize, usize, usize) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::<usize>().unwrap(), iter.next().unwrap().parse::<usize>().unwrap(), iter.next().unwrap().parse::<usize>().unwrap(), ) } #[allow(dead_code)] fn readuuuu() -> (usize, usize, usize, usize) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::<usize>().unwrap(), iter.next().unwrap().parse::<usize>().unwrap(), iter.next().unwrap().parse::<usize>().unwrap(), iter.next().unwrap().parse::<usize>().unwrap(), ) } fn readiiii() -> (i64, i64, i64, i64) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::<i64>().unwrap(), iter.next().unwrap().parse::<i64>().unwrap(), iter.next().unwrap().parse::<i64>().unwrap(), iter.next().unwrap().parse::<i64>().unwrap(), ) } pub mod dinic { #[derive(Clone, Copy, Debug)] struct Edge { to: usize, cap: i64, rev: usize, } pub struct Network { g: Vec<Vec<Edge>>, level: Vec<Option<usize>>, iter: Vec<usize>, } #[doc = "direct flow graph. O(EV^2)"] impl Network { pub fn new(n: usize) -> Network { Network { g: vec![vec![]; n], level: vec![None; n], iter: vec![0; n], } } pub fn add_edge(&mut self, from: usize, to: usize, cap: i64) { assert!(cap >= 0); let from_rev = self.g[to].len(); let to_rev = self.g[from].len(); self.g[from].push(Edge { to: to, cap: cap, rev: from_rev, }); self.g[to].push(Edge { to: from, cap: 0, rev: to_rev, }); } fn n(&self) -> usize { self.g.len() } fn bfs(&mut self, s: usize) { self.level = vec![None; self.n()]; let mut q = std::collections::VecDeque::new(); q.push_back(s); self.level[s] = Some(0); while let Some(v) = q.pop_front() { for e in &self.g[v] { if e.cap > 0 && self.level[e.to].is_none() { self.level[e.to] = self.level[v].map(|x| x + 1); q.push_back(e.to); } } } } fn dfs(&mut self, v: usize, t: usize, f: i64) -> i64 { if v == t { return f; } let iter_v_cur = self.iter[v]; for i in iter_v_cur..self.g[v].len() { let e = self.g[v][i].clone(); if e.cap > 0 && self.level[v] < self.level[e.to] { let d = self.dfs(e.to, t, std::cmp::min(f, e.cap)); if d > 0 { self.g[v][i].cap -= d; self.g[e.to][e.rev].cap += d; return d; } } self.iter[v] += 1; } return 0; } pub fn max_flow(&mut self, s: usize, t: usize) -> i64 { let mut flow = 0; loop { self.bfs(s); // finally if we could not find any path to t then return flow if self.level[t].is_none() { return flow; } let INF = 2_000_000_001; self.iter = vec![0; self.n()]; let mut f = self.dfs(s, t, INF); while f > 0 { flow += f; f = self.dfs(s, t, INF); } } } } } // #[test] // fn test_dinic() { // use dinic::*; // let mut nw = Network::new(5); // let conns = [ // (0, 1, 10), // (0, 2, 2), // (1, 2, 6), // (1, 3, 6), // (3, 2, 3), // (2, 4, 5), // (3, 4, 8), // ]; // for conn in &conns { // nw.add_edge(conn.0, conn.1, conn.2); // } // assert_eq!(nw.max_flow(0, 4), 11); // } /// Equivalent to std::lowerbound and std::upperbound in c++ pub trait BinarySearch<T> { fn lower_bound(&self, x: &T) -> usize; fn upper_bound(&self, x: &T) -> usize; } impl<T: Ord> BinarySearch<T> for [T] { fn lower_bound(&self, x: &T) -> usize { let mut low = 0; let mut high = self.len(); while low != high { let mid = (low + high) / 2; match self[mid].cmp(x) { Ordering::Less => { low = mid + 1; } Ordering::Equal | Ordering::Greater => { high = mid; } } } low } fn upper_bound(&self, x: &T) -> usize { let mut low = 0; let mut high = self.len(); while low != high { let mid = (low + high) / 2; match self[mid].cmp(x) { Ordering::Less | Ordering::Equal => { low = mid + 1; } Ordering::Greater => { high = mid; } } } low } } #[derive(PartialEq, Eq, Clone, Debug)] enum Inf<T> { Val(T), Inf, } impl<T: Ord> Inf<T> { #[allow(dead_code)] fn val(self) -> Option<T> { match self { Inf::Val(v) => Some(v), _ => None, } } } impl<T: PartialOrd> PartialOrd for Inf<T> { fn partial_cmp(&self, other: &Self) -> Option<Ordering> { match (self, other) { (&Inf::Inf, &Inf::Inf) => Some(Ordering::Equal), (&Inf::Inf, &Inf::Val(_)) => Some(Ordering::Greater), (&Inf::Val(_), &Inf::Inf) => Some(Ordering::Less), (&Inf::Val(ref a), &Inf::Val(ref b)) => a.partial_cmp(b), } } } impl<T: Ord> Ord for Inf<T> { fn cmp(&self, other: &Self) -> Ordering { match (self, other) { (&Inf::Inf, &Inf::Inf) => Ordering::Equal, (&Inf::Inf, &Inf::Val(_)) => Ordering::Greater, (&Inf::Val(_), &Inf::Inf) => Ordering::Less, (&Inf::Val(ref a), &Inf::Val(ref b)) => a.cmp(b), } } } #[allow(dead_code)] /// Calculate length of Longest Increasing Subsequence. O(N log N) pub fn lis<T: Ord>(seq: &[T]) -> usize { let mut dp: Vec<Inf<&T>> = vec![Inf::Inf; seq.len() + 1]; for x in seq.iter() { let i = dp.upper_bound(&Inf::Val(x)); dp[i] = Inf::Val(x); } dp.upper_bound(&Inf::Inf) } fn solve() { use dinic::*; let (n, m, q) = readuuu(); let mut vec = vec![]; let mut data = vec![]; for i in 0..q { let (a, b) = readuu(); data.push((b, a)); } data.sort(); for i in data { vec.push(i.1); } let res = lis(&vec); println!("{:?}", res); // let mut nw = Network::new(n + m + 2); // // let conns = [ // // (0, 1, 10), // // (0, 2, 2), // // (1, 2, 6), // // (1, 3, 6), // // (3, 2, 3), // // (2, 4, 5), // // (3, 4, 8), // // ]; // let mut conns = vec![(0, 0, 0); 0]; // let mut src = 0; // let mut dst = n + m + 1; // for i in 0..n { // conns.push((src, i + 1, 1)); // } // for i in 0..m { // conns.push((i + 1 + n, dst, 1)); // } // for i in 0..q { // let (a, b) = readuu(); // if a >= b { // continue; // } // conns.push((a, n + b, 1)); // } // for conn in &conns { // nw.add_edge(conn.0, conn.1, conn.2); // } // let mut res = nw.max_flow(src, dst); // println!("{:?}", res); return; } fn main() { solve(); return; }