結果
問題 | No.2735 Demarcation |
ユーザー | yosupot |
提出日時 | 2024-04-19 22:32:52 |
言語 | Rust (1.77.0 + proconio) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,930 bytes |
コンパイル時間 | 17,025 ms |
コンパイル使用メモリ | 376,800 KB |
実行使用メモリ | 71,680 KB |
最終ジャッジ日時 | 2024-10-11 16:09:06 |
合計ジャッジ時間 | 18,956 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | AC | 122 ms
47,360 KB |
testcase_22 | AC | 170 ms
68,224 KB |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
コンパイルメッセージ
warning: unused import: `marker::Bytes` --> src/main.rs:1:23 | 1 | use proconio::{input, marker::Bytes}; | ^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unused import: `iter` --> src/main.rs:2:34 | 2 | use std::{collections::BTreeSet, iter}; | ^^^^
ソースコード
use proconio::{input, marker::Bytes}; use std::{collections::BTreeSet, iter}; use core::cmp::{max, min}; const INF: i128 = 1_000_000_000_000_000_000 + 1000; fn main() { input! { n: i32, x: [i32; n], q: i32, ques: [(i32, i32, i64); q], } let mut count_same = vec![0; n as usize]; for i in 0..(n - 1) { count_same[(i + 1) as usize] = count_same[i as usize] + if x[i as usize] == x[(i + 1) as usize] { 1 } else { 0 } } let mut range = vec![vec![n; 4]; n as usize]; for i in 0..n { let mut set = BTreeSet::new(); for j in (max(0, i - 3)..i + 1).rev() { set.insert(x[j as usize]); range[i as usize][set.len()] = j; } for k in set.len()..4 { range[i as usize][k] = 0; } } for (l, r, s) in ques { let l = l - 1; let dist = r - l; if dist <= 62 && 1i64 << (dist - 1) <= s { println!("-1"); continue; } let same = count_same[(r - 1) as usize] - count_same[l as usize]; if 61 <= same || (s < 1i64 << same) { println!("0"); continue; } println!("?"); for k in 2.. { let mut dp = vec![0i128; (dist + 1) as usize]; let mut dp_sum = vec![0i128; (dist + 1 + 1) as usize]; dp[0] = 1; dp_sum[1] = 1; for i in l..r { dp[(i + 1 - l) as usize] = min(INF, dp_sum[(i + 1 - l) as usize] - dp_sum[(max(l, range[i as usize][k]) - l) as usize]); dp_sum[(i + 1 - l + 1) as usize] = dp_sum[(i + 1 - l) as usize] + dp[(i + 1 - l) as usize]; } if dp[(r - l) as usize] > s as i128 { println!("{}", k - 1); break; } } } }