Logo
(追記) (追記ここまで)

29994번 - Investigating Zeroes and Ones 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.5 초 (추가 시간 없음) 1024 MB74504272.414%

문제

You find yourself in a mysterious binary world, where an array of N binary digits awaits your scrutiny. Each digit is either a zero or a one, creating a unique pattern across the landscape. Your quest is to uncover the hidden patterns of this binary realm by unraveling the significance of subarrays with an odd number of ones.

The array of digits is denoted as b1, b2, . . . , bN. Your task is to embark on a journey to discover the enigmatic subarrays – segments of consecutive digits – and determine the count of subarrays that harbor an odd number of ones.

As you traverse this binary landscape, remember that a subarray is defined by its starting and ending digits. For instance, in the sequence [b1, b2, b3], subarrays include [b1], [b2], [b3], [b1, b2], [b2, b3], and [b1, b2, b3].

Your mission is to design an algorithm that determines the total number of subarrays containing an odd number of ones within this binary sequence. Please don’t forget that the answer might not fit in a 32-bits integer.

입력

The first line contains an integer N (1 ≤ N ≤ 105) representing the length of the binary sequence.

The second line contains N binary digits b1, b2, . . . , bN (bi ∈ {0, 1}) representing the elements of the sequence.

출력

Output a single line with an integer representing the count of subarrays in the sequence that hold an odd number of ones.

제한

예제 입력 1

3
0 1 0

예제 출력 1

4

예제 입력 2

10
1 0 0 1 1 0 1 1 1 0

예제 출력 2

30

힌트

출처

ICPC > Regionals > Latin America > Sub-Regional Brasil do ACM ICPC > Maratona de Programação da SBC 2023 I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /