結果
問題 | No.1711 Divide LCM |
ユーザー | akakimidori |
提出日時 | 2021-10-15 22:38:16 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,989 bytes |
コンパイル時間 | 13,885 ms |
コンパイル使用メモリ | 380,044 KB |
実行使用メモリ | 48,424 KB |
最終ジャッジ日時 | 2024-09-17 17:47:46 |
合計ジャッジ時間 | 23,207 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 3 ms
5,376 KB |
testcase_04 | AC | 5 ms
5,376 KB |
testcase_05 | AC | 14 ms
5,376 KB |
testcase_06 | AC | 5 ms
5,376 KB |
testcase_07 | AC | 12 ms
5,376 KB |
testcase_08 | AC | 7 ms
5,376 KB |
testcase_09 | AC | 24 ms
5,624 KB |
testcase_10 | AC | 6 ms
5,376 KB |
testcase_11 | AC | 32 ms
6,528 KB |
testcase_12 | AC | 6 ms
5,376 KB |
testcase_13 | AC | 3 ms
5,376 KB |
testcase_14 | AC | 4 ms
5,376 KB |
testcase_15 | WA | - |
testcase_16 | AC | 3 ms
5,376 KB |
testcase_17 | WA | - |
testcase_18 | AC | 62 ms
20,480 KB |
testcase_19 | AC | 62 ms
20,480 KB |
testcase_20 | AC | 61 ms
20,480 KB |
testcase_21 | AC | 116 ms
25,472 KB |
testcase_22 | AC | 251 ms
38,916 KB |
testcase_23 | AC | 286 ms
48,424 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 92 ms
16,868 KB |
testcase_28 | AC | 86 ms
16,256 KB |
testcase_29 | AC | 4 ms
5,376 KB |
testcase_30 | WA | - |
testcase_31 | AC | 3 ms
5,376 KB |
testcase_32 | AC | 163 ms
22,016 KB |
testcase_33 | AC | 97 ms
22,144 KB |
testcase_34 | AC | 6 ms
5,376 KB |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | AC | 107 ms
27,008 KB |
testcase_39 | AC | 112 ms
24,576 KB |
testcase_40 | AC | 2 ms
5,376 KB |
testcase_41 | AC | 3 ms
5,376 KB |
testcase_42 | AC | 3 ms
5,376 KB |
testcase_43 | AC | 2 ms
5,376 KB |
testcase_44 | AC | 3 ms
5,376 KB |
ソースコード
// ---------- begin next_permutation ---------- fn next_permutation<T: Ord>(a: &mut [T]) -> bool { a.windows(2).rposition(|a| a[0] < a[1]).map_or(false, |x| { let y = a.iter().rposition(|b| a[x] < *b).unwrap(); a.swap(x, y); a[(x + 1)..].reverse(); true }) } // ---------- end next_permutation ---------- // ---------- begin scannner ---------- #[allow(dead_code)] mod scanner { use std::str::FromStr; pub struct Scanner<'a> { it: std::str::SplitWhitespace<'a>, } impl<'a> Scanner<'a> { pub fn new(s: &'a String) -> Scanner<'a> { Scanner { it: s.split_whitespace(), } } pub fn next<T: FromStr>(&mut self) -> T { self.it.next().unwrap().parse::<T>().ok().unwrap() } pub fn next_bytes(&mut self) -> Vec<u8> { self.it.next().unwrap().bytes().collect() } pub fn next_chars(&mut self) -> Vec<char> { self.it.next().unwrap().chars().collect() } pub fn next_vec<T: FromStr>(&mut self, len: usize) -> Vec<T> { (0..len).map(|_| self.next()).collect() } } } // ---------- end scannner ---------- use std::io::Write; fn main() { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut sc = scanner::Scanner::new(&s); let out = std::io::stdout(); let mut out = std::io::BufWriter::new(out.lock()); run(&mut sc, &mut out); } fn run<W: Write>(sc: &mut scanner::Scanner, out: &mut std::io::BufWriter<W>) { let n: usize = sc.next(); let mut dp = vec![0; 1000000 + 1]; let mut a = vec![]; for _ in 0..n { let m: usize = sc.next(); let mut p = vec![(0usize, 0usize); m]; for p in p.iter_mut() { p.0 = sc.next(); p.1 = sc.next(); dp[p.0] = dp[p.0].max(p.1); } a.push(p); } let mut cond = vec![]; for i in 0..dp.len() { if dp[i] > 0 { cond.push(i); } } for a in a.iter() { if a.len() == cond.len() && a.iter().all(|p| p.1 == dp[p.0]) { writeln!(out, "-1").ok(); return; } } let mut ban = std::collections::BTreeSet::new(); for a in a.iter() { let mut p = vec![]; for a in a.iter() { if dp[a.0] == a.1 { p.push(a.0); } } ban.insert(p); } for i in 1.. { let mut next = vec![]; for ban in ban.iter() { if ban.len() > i { let mut p = ban.clone(); p.remove(i); next.push(p); } } if next.len() == 0 { break; } ban.extend(next); } for k in 2.. { let mut test = vec![0; cond.len()]; for t in test.iter_mut().rev().take(k) { *t = 1; } while { let mut x = vec![]; for (i, t) in test.iter().enumerate() { if *t > 0 { x.push(cond[i]); } } if !ban.contains(&x) { let mut ans = vec![vec![]; k]; for a in a { for (ans, &x) in ans.iter_mut().zip(&x) { if !a.contains(&(x, dp[x])) { ans.push(a.iter().fold(1, |s, a| s * a.0.pow(a.1 as u32))); break; } } } writeln!(out, "{}", ans.len()).ok(); for ans in ans { write!(out, "{}", ans.len()).ok(); for a in ans { write!(out, " {}", a).ok(); } writeln!(out).ok(); } return; } next_permutation(&mut test) } {} } }