Submission #2565315


Source Code Expand

Copy
#include <iostream>
#include <vector>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  long long int ans = 0;
  vector<int> id(20, -1), B(N);
  for(int i = 0; i < N; ++i){
    int l = -1;
    for(int j = 0; j < 20; ++j){
      if(!((A[i]>>j)&1)) continue;
      l = max(l, id[j]);
      id[j] = i;
    }
    B[i] = l + 1;
  }
  ans += 1;
  //for(int i = 0; i < N; ++i) cout << B[i] << " "; cout << endl;
  for(int i = 1; i < N; ++i){
    B[i] = max(B[i], B[i-1]);
    ans += i - B[i] + 1;
  }
  cout << ans << endl;
  return 0;
}

Submission Info

Submission Time
Task D - Xor Sum 2
User TAB
Language C++14 (GCC 5.4.1)
Score 500
Code Size 629 Byte
Status
Exec Time 82 ms
Memory 1792 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 500 / 500 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 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
subtask_1_01.txt 1 ms 256 KB
subtask_1_02.txt 1 ms 256 KB
subtask_1_03.txt 32 ms 1536 KB
subtask_1_04.txt 2 ms 256 KB
subtask_1_05.txt 32 ms 1152 KB
subtask_1_06.txt 31 ms 768 KB
subtask_1_07.txt 2 ms 256 KB
subtask_1_08.txt 27 ms 896 KB
subtask_1_09.txt 31 ms 1280 KB
subtask_1_10.txt 40 ms 1408 KB
subtask_1_11.txt 41 ms 1536 KB
subtask_1_12.txt 62 ms 1664 KB
subtask_1_13.txt 13 ms 768 KB
subtask_1_14.txt 10 ms 640 KB
subtask_1_15.txt 16 ms 896 KB
subtask_1_16.txt 2 ms 256 KB
subtask_1_17.txt 40 ms 1792 KB
subtask_1_18.txt 41 ms 1792 KB
subtask_1_19.txt 57 ms 1792 KB
subtask_1_20.txt 82 ms 1792 KB
subtask_1_21.txt 51 ms 1792 KB
subtask_1_22.txt 67 ms 1792 KB
subtask_1_23.txt 46 ms 1792 KB
subtask_1_24.txt 59 ms 1792 KB
subtask_1_25.txt 51 ms 1792 KB
subtask_1_26.txt 67 ms 1792 KB
subtask_1_27.txt 40 ms 1792 KB
subtask_1_28.txt 40 ms 1792 KB
subtask_1_29.txt 40 ms 1792 KB
subtask_1_30.txt 41 ms 1792 KB
subtask_1_31.txt 40 ms 1792 KB
subtask_1_32.txt 40 ms 1792 KB