Submission #19455436


Source Code Expand

Copy
// -*- coding:utf-8-unix -*-

#![allow(dead_code)]
#![allow(unused_imports)]
use std::collections::*;
use std::convert::*;
use std::convert::{From, Into};
use std::fmt::Debug;
use std::fs::File;
use std::io::prelude::*;
use std::io::*;
use std::marker::Copy;
use std::mem::*;
use std::ops::Bound::*;
use std::ops::{Add, Mul, Neg, Sub};
use std::str;
use std::vec;
use std::{cmp, process::Output};
use std::{cmp::Ordering, env::consts::DLL_PREFIX};
use std::{cmp::Ordering::*, f32::consts::PI};

const INF: i64 = 1223372036854775807;
// const INF: i64 = 2147483647;
const MEM_SIZE: usize = 202020;
const MOD: i64 = 1000000007;
// const MOD: i64 = 998244353;
use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;

use btree_map::{Keys, Values};
// use str::Chars;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn readi() -> (i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    iter.next().unwrap().parse::<i64>().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn readii() -> (i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}

fn readff() -> (f64, f64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<f64>().unwrap(),
        iter.next().unwrap().parse::<f64>().unwrap(),
    )
}

#[allow(dead_code)]
fn readiii() -> (i64, i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}
#[allow(dead_code)]
fn readuu() -> (usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

fn readcc() -> (char, char) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<char>().unwrap(),
        iter.next().unwrap().parse::<char>().unwrap(),
    )
}

#[allow(dead_code)]
fn readuuu() -> (usize, usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(dead_code)]
fn readuuuu() -> (usize, usize, usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

fn readiiii() -> (i64, i64, i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}

fn readin() -> (usize, char) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<char>().unwrap(),
    )
}

fn solve() {
    let n: usize = read();
    let mut vec: Vec<usize> = read_vec();
    let mut s1 = 0;
    let mut s2 = 0;
    let mut res = 0 as usize;
    let mut r = 0 as usize;
    let mut cnt = 0 as usize;
    for l in 0..n {
        if r < n {
            while s1 + vec[r] == s2 ^ vec[r] {
                s1 += vec[r];
                s2 ^= vec[r];
                r += 1;
                if r == n {
                    break;
                }
            }
        }
        res += r - l;
        s1 -= vec[l];
        s2 ^= vec[l];
    }
    println!("{:?}", res);

    return;
}

fn main() {
    solve()
}

Submission Info

Submission Time
Task D - Xor Sum 2
User MoSooN
Language Rust (1.42.0)
Score 500
Code Size 5316 Byte
Status AC
Exec Time 23 ms
Memory 5888 KB

Compile Error

warning: unnecessary parentheses around type
  --> src/main.rs:43:15
   |
43 | fn readi() -> (i64) {
   |               ^^^^^ help: remove these parentheses
   |
   = note: `#[warn(unused_parens)]` on by default

warning: unused variable: `cnt`
   --> src/main.rs:169:13
    |
169 |     let mut cnt = 0 as usize;
    |             ^^^ help: consider prefixing with an underscore: `_cnt`
    |
    = note: `#[warn(unused_variables)]` on by default

warning: variable does not need to be mutable
   --> src/main.rs:164:9
    |
164 |     let mut vec: Vec<usize> = read_vec();
    |         ----^^^
    |         |
    |         help: remove this `mut`
    |
    = note: `#[warn(unused_mut)]` on by default

warning: variable does not need to be mutable
   --> src/main.rs:169:9
    |
169 |     let mut cnt = 0 as usize;
    |         ----^^^
    |         |
    |         help: remove this `mut`

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 38
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt, subtask_1_26.txt, subtask_1_27.txt, subtask_1_28.txt, subtask_1_29.txt, subtask_1_30.txt, subtask_1_31.txt, subtask_1_32.txt
Case Name Status Exec Time Memory
sample_01.txt AC 6 ms 2008 KB
sample_02.txt AC 2 ms 2000 KB
sample_03.txt AC 1 ms 1872 KB
subtask_1_01.txt AC 1 ms 2008 KB
subtask_1_02.txt AC 2 ms 2028 KB
subtask_1_03.txt AC 11 ms 3796 KB
subtask_1_04.txt AC 2 ms 2084 KB
subtask_1_05.txt AC 14 ms 3564 KB
subtask_1_06.txt AC 10 ms 3372 KB
subtask_1_07.txt AC 2 ms 2104 KB
subtask_1_08.txt AC 7 ms 3328 KB
subtask_1_09.txt AC 9 ms 3840 KB
subtask_1_10.txt AC 13 ms 4148 KB
subtask_1_11.txt AC 11 ms 4020 KB
subtask_1_12.txt AC 21 ms 4816 KB
subtask_1_13.txt AC 6 ms 2616 KB
subtask_1_14.txt AC 3 ms 2396 KB
subtask_1_15.txt AC 4 ms 2820 KB
subtask_1_16.txt AC 2 ms 2064 KB
subtask_1_17.txt AC 18 ms 4424 KB
subtask_1_18.txt AC 17 ms 4456 KB
subtask_1_19.txt AC 16 ms 4712 KB
subtask_1_20.txt AC 17 ms 5888 KB
subtask_1_21.txt AC 13 ms 4632 KB
subtask_1_22.txt AC 22 ms 5076 KB
subtask_1_23.txt AC 22 ms 4788 KB
subtask_1_24.txt AC 15 ms 4884 KB
subtask_1_25.txt AC 16 ms 4596 KB
subtask_1_26.txt AC 23 ms 5572 KB
subtask_1_27.txt AC 9 ms 4476 KB
subtask_1_28.txt AC 18 ms 4424 KB
subtask_1_29.txt AC 15 ms 4424 KB
subtask_1_30.txt AC 14 ms 4444 KB
subtask_1_31.txt AC 10 ms 4484 KB
subtask_1_32.txt AC 10 ms 4456 KB