結果

問題 No.2300 Substring OR Sum
ユーザー umezoumezo
提出日時 2023-05-12 22:41:45
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 579 bytes
コンパイル時間 1,960 ms
コンパイル使用メモリ 203,304 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-28 19:16:57
合計ジャッジ時間 3,447 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  ll n;
  cin>>n;
  vector<ll> A(n);
  rep(i,n) cin>>A[i];
  
  ll ans=0;
  ll tt=1;
  rep(i,28){
    ll tmp=0;
    ll sum=n*(n+1)/2;
    rep(j,n){
      if(!(A[j]&(1LL<<i))) {
        tmp++;
      }
      else{
        sum-=(tmp+1)*tmp/2;
        tmp=0;
      }
    }
    sum-=(tmp+1)*tmp/2;
    ans+=sum*tt;
    tt*=2;
  }
  cout<<ans<<endl;
  
  return 0;
}
0