library-rs

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub naoya675/library-rs

:warning: Run Length
(string/run-length/src/lib.rs)

Description

Code

#[derive(Debug)]
pub struct RunLendth;

impl RunLendth {
    pub fn encode<T: Copy + PartialEq>(s: &Vec<T>) -> Vec<(T, usize)> {
        let mut res = vec![];
        if s.len() == 0 {
            return res;
        }
        let mut i = 0;
        while i < s.len() {
            let mut j = i;
            while j < s.len() && s[i] == s[j] {
                j += 1;
            }
            res.push((s[i], j - i));
            i = j;
        }
        res
    }

    pub fn decode<T: Copy>(s: &Vec<(T, usize)>) -> Vec<T> {
        let mut res = vec![];
        if s.len() == 0 {
            return res;
        }
        for &(value, c) in s {
            res.extend(vec![value; c]);
        }
        res
    }
}

pub fn encode<T: Copy + PartialEq>(s: &Vec<T>) -> Vec<(T, usize)> {
    let mut res = vec![];
    if s.len() == 0 {
        return res;
    }
    let mut i = 0;
    while i < s.len() {
        let mut j = i;
        while j < s.len() && s[i] == s[j] {
            j += 1;
        }
        res.push((s[i], j - i));
        i = j;
    }
    res
}

pub fn decode<T: Copy>(s: &Vec<(T, usize)>) -> Vec<T> {
    let mut res = vec![];
    if s.len() == 0 {
        return res;
    }
    for &(value, c) in s {
        res.extend(vec![value; c]);
    }
    res
}
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.12/x64/lib/python3.11/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.12/x64/lib/python3.11/site-packages/onlinejudge_verify/languages/rust.py", line 288, in bundle
    raise NotImplementedError
NotImplementedError
Back to top page