結果

問題 No.2374 ASKT Subsequences
ユーザー 👑 H20H20
提出日時 2023-07-07 22:16:09
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 3,298 bytes
コンパイル時間 4,637 ms
コンパイル使用メモリ 160,152 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2023-09-28 23:38:34
合計ジャッジ時間 8,778 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,448 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 4 ms
4,376 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable does not need to be mutable
   --> Main.rs:34:13
    |
34  |           let mut $var = read_value!($next, $t);
    |               ----^^^^
    |               |
    |               help: remove this `mut`
...
100 | /     input! {
101 | |         n: usize,
102 | |         mut a : [isize; n]
103 | |     }
    | |_____- in this macro invocation
    |
    = note: `#[warn(unused_mut)]` on by default
    = note: this warning originates in the macro `input_inner` which comes from the expansion of the macro `input` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: 1 warning emitted

ソースコード

diff #

macro_rules! input {
    ($($r:tt)*) => {
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(std::io::stdin()));
        let mut next = move |is_word: bool| -> String{
            if is_word {
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            } else {
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c| c == &'\n')
                    .take_while(|c| c != &'\n')
                    .collect()
            }
        };
        input_inner!{next, $($r)*};
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, static $var:ident : $t:tt $($rest:tt)*) => {
        $var = read_value!($next, $t);
        input_inner!{$next $($rest)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($rest:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($rest)*}
    };

    ($next:expr, $var:ident : $t:tt $($rest:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($rest)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; all ]) => { {
            let mut str = $next(false);
            str.split_whitespace().map(|it| it.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len as usize).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, lines) => {
        {
            let mut vec = Vec::new();
            let mut str = $next(false);
            while str != "" {
                vec.push(str);
                str = $next(false);
            }
            vec
        }
    };

    ($next:expr, line) => {
        $next(false)
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next(true).parse::<$t>().expect("Parse error")
    };
}

pub fn get_time() -> f64 {
    static mut STIME: f64 = -1.0;
    let t = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap();
    let ms = t.as_secs() as f64 + t.subsec_nanos() as f64 * 1e-9;
    unsafe {
        if STIME < 0.0 {
            STIME = ms;
        }
        ms - STIME
    }
}

fn main() {
    input! {
        n: usize,
        mut a : [isize; n]
    }

    let mut a13 = Vec::new();
    let mut a24 = Vec::new();

    for i in 0..n {
        for j in (i + 1)..n {
            if a[i] == a[j] - 10 {
                a13.push((i, j));
            }
            if a[i] == a[j] - 1 {
                a24.push((i, j));
            }
        }
    }

    let mut ans = 0;

    for &(a1, a3) in &a13 {
        for &(a2, a4) in &a24 {
            if a1 < a2 && a2 < a3 && a3 < a4 && a[a1] + 10 < a[a2] {
                ans += 1;
            }
            if a2>a3{
                break;
            }
        }
    }

    println!("{}", ans);

}
0