Submission #39658094
Source Code Expand
// -*- coding:utf-8-unix -*- pub fn main() { proconio::input! { h: usize, w: usize, a: [u32; w * h], } let mut comp_hash = rustc_hash::FxHashMap::with_capacity_and_hasher(w * h, std::hash::BuildHasherDefault::default()); let mut comp_count = 0usize; let a: Vec<usize> = std::iter::FromIterator::from_iter(a.iter().map(|&e| *comp_hash.entry(e).or_insert_with(|| { let c = comp_count; comp_count += 1; c }) )); let h1 = h - 1; let w1 = w - 1; let hw2 = h1 + w1; let mut count = 0usize; let mut hset = rustc_hash::FxHashSet::<u32>::default(); let mut comb = (1u32 << w1) - 1; while comb < (1 << hw2) { let mut hbool = [false; 100]; hset.clear(); let mut i = 0; count += 1; for k in 0..hw2 { hbool[a[i]] = true; i += if comb & (1 << k) == 0 { w } else { 1 }; if hbool[a[i]] { count -= 1; break; } } let x = comb & comb.wrapping_neg(); let y = comb + x; comb = ((comb & !y) / x >> 1) | y; } println!("{}", count); }
Submission Info
Submission Time | |
---|---|
Task | C - Make Takahashi Happy |
User | mizarjp |
Language | Rust (1.42.0) |
Score | 300 |
Code Size | 1179 Byte |
Status | AC |
Exec Time | 7 ms |
Memory | 2148 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, example0.txt, example1.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 5 ms | 2012 KiB |
001.txt | AC | 2 ms | 1944 KiB |
002.txt | AC | 5 ms | 2064 KiB |
003.txt | AC | 5 ms | 2148 KiB |
004.txt | AC | 2 ms | 2020 KiB |
005.txt | AC | 2 ms | 2032 KiB |
006.txt | AC | 6 ms | 2004 KiB |
007.txt | AC | 2 ms | 2036 KiB |
008.txt | AC | 2 ms | 2040 KiB |
009.txt | AC | 2 ms | 1968 KiB |
010.txt | AC | 4 ms | 2060 KiB |
011.txt | AC | 5 ms | 2064 KiB |
012.txt | AC | 3 ms | 2108 KiB |
013.txt | AC | 6 ms | 1936 KiB |
014.txt | AC | 5 ms | 2036 KiB |
015.txt | AC | 3 ms | 2060 KiB |
016.txt | AC | 5 ms | 2116 KiB |
017.txt | AC | 7 ms | 2056 KiB |
018.txt | AC | 5 ms | 2060 KiB |
019.txt | AC | 5 ms | 2144 KiB |
020.txt | AC | 3 ms | 2032 KiB |
021.txt | AC | 4 ms | 2016 KiB |
022.txt | AC | 6 ms | 2092 KiB |
example0.txt | AC | 2 ms | 2032 KiB |
example1.txt | AC | 6 ms | 2148 KiB |