結果
問題 | No.2300 Substring OR Sum |
ユーザー | haihamabossu |
提出日時 | 2023-05-12 21:55:10 |
言語 | Rust (1.77.0) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 1,869 bytes |
コンパイル時間 | 11,215 ms |
コンパイル使用メモリ | 378,744 KB |
実行使用メモリ | 14,720 KB |
最終ジャッジ日時 | 2024-05-06 11:44:31 |
合計ジャッジ時間 | 12,888 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | AC | 17 ms
5,248 KB |
testcase_04 | AC | 14 ms
5,376 KB |
testcase_05 | AC | 17 ms
5,632 KB |
testcase_06 | AC | 8 ms
5,376 KB |
testcase_07 | AC | 52 ms
14,080 KB |
testcase_08 | AC | 22 ms
6,784 KB |
testcase_09 | AC | 19 ms
6,016 KB |
testcase_10 | AC | 44 ms
11,392 KB |
testcase_11 | AC | 47 ms
12,928 KB |
testcase_12 | AC | 53 ms
14,336 KB |
testcase_13 | AC | 29 ms
14,720 KB |
testcase_14 | AC | 24 ms
14,396 KB |
testcase_15 | AC | 23 ms
7,168 KB |
testcase_16 | AC | 41 ms
11,392 KB |
testcase_17 | AC | 52 ms
14,080 KB |
testcase_18 | AC | 1 ms
5,376 KB |
testcase_19 | AC | 0 ms
5,376 KB |
testcase_20 | AC | 1 ms
5,376 KB |
testcase_21 | AC | 1 ms
5,376 KB |
testcase_22 | AC | 1 ms
5,376 KB |
ソースコード
pub mod scanner { pub struct Scanner { buf: Vec<String>, } impl Scanner { pub fn new() -> Self { Self { buf: vec![] } } pub fn new_from(source: &str) -> Self { let source = String::from(source); let buf = Self::split(source); Self { buf } } pub fn next<T: std::str::FromStr>(&mut self) -> T { loop { if let Some(x) = self.buf.pop() { return x.parse().ok().expect(""); } let mut source = String::new(); std::io::stdin().read_line(&mut source).expect(""); self.buf = Self::split(source); } } fn split(source: String) -> Vec<String> { source .split_whitespace() .rev() .map(String::from) .collect::<Vec<_>>() } } } use crate::scanner::Scanner; fn main() { let mut scanner = Scanner::new(); let t: usize = 1; for _ in 0..t { solve(&mut scanner); } } fn solve(scanner: &mut Scanner) { let n: usize = scanner.next(); let a: Vec<usize> = (0..n) .map(|_| { let a = scanner.next(); a }) .collect(); let mut ans: usize = 0; let mut x: usize = 1; for b in 0..28 { let mut count = (1 + n) * n / 2; let mut l = 0; while l < n { if ((a[l] >> b) & 1) == 0 { let mut r = l; while r < n && ((a[r] >> b) & 1) == 0 { r += 1; } count -= (1 + (r - l)) * (r - l) / 2; l = r; } else { l += 1; } } ans += x * count; x *= 2; } println!("{}", ans); }