GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — rustforces/src/explorer_space_1517D.rs at master · schiemon/rustforces Expand file tree/ Copy pathexplorer_space_1517D.rsMore file actions 124 lines (100 loc) · 2.97 KB / Copy pathexplorer_space_1517D.rsFile metadata and controls124 lines (100 loc) · 2.97 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 #![allow(dead_code)] #![allow(unused_variables)] #![allow(unused_mut)] const MULTI_TEST: bool = false; fn print_matrix<T: std::fmt::Display>(A: &[Vec<T>]) { let n = A.len(); if n == 0 { println!("[]"); } else { let m = A[0].len(); let mut cell_width = 1; for i in 0..n { for j in 0..m { cell_width = cell_width.max(format!("{}", A[i][j]).len()); } } cell_width += 2; for i in 0..n { for j in 0..m { print!("{:>width$}", A[i][j], width = cell_width); } println!(); } } } fn solve<B: std::io::BufRead, W: std::io::Write>( read: &mut Reader<B>, write: &mut std::io::BufWriter<W>, ) { let n = read.next::<usize>(); let m = read.next::<usize>(); let k = read.next::<usize>(); let mut grid = vec![vec![0; m]; n]; for i in 0..n { for j in 0..m { grid[i][j] = read.next::<u32>(); } } print_matrix(&grid); } pub fn main() { let (stdin, stdout) = (std::io::stdin(), std::io::stdout()); let mut read = Reader::new(stdin.lock()); let mut write = std::io::BufWriter::new(stdout.lock()); let t = if MULTI_TEST { read.next::<u32>() } else { 1 }; for _ in 0..t { solve(&mut read, &mut write); } } pub struct Reader<B> { reader: B, buf_str: Vec<u8>, buf_iter: std::str::SplitWhitespace<'static>, } impl<B: std::io::BufRead> Reader<B> { pub fn new(reader: B) -> Self { Self { reader, buf_str: Vec::new(), buf_iter: "".split_whitespace(), } } pub fn next<T: std::str::FromStr>(&mut self) -> T { loop { if let Some(token) = self.buf_iter.next() { return token.parse().ok().expect("Failed parse"); } // First, clear the buffer. We want to read new data now. self.buf_str.clear(); // Read the next line. self.reader .read_until(b'\n', &mut self.buf_str) .expect("Failed to read the next line."); // Split the line into tokens and buffer them. self.buf_iter = unsafe { let slice = std::str::from_utf8_unchecked(&self.buf_str); let split_slice = slice.split_whitespace(); std::mem::transmute(split_slice) } } } pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> { let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(self.next()); } v } pub fn next_char_vec(&mut self, n: usize) -> Vec<char> { let s = self.next::<String>(); let cv = s.chars().collect::<Vec<char>>(); assert_eq!(cv.len(), n); cv } pub fn next_pair<T: std::str::FromStr>(&mut self) -> (T, T) { let first = self.next(); let second = self.next(); (first, second) } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |