結果
問題 | No.2300 Substring OR Sum |
ユーザー |
![]() |
提出日時 | 2023-05-16 10:55:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 84 ms / 2,000 ms |
コード長 | 1,283 bytes |
コンパイル時間 | 2,167 ms |
コンパイル使用メモリ | 218,116 KB |
最終ジャッジ日時 | 2025-02-13 00:48:44 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#pragma target("popcnt") #pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef string str; typedef pair<ll,ll> pii; #define F first #define S second #define pb push_back #define pq priority_queue #define all(x) (x).begin(),(x).end() #define bug(x) cerr << (x) << ' ' #define debug(x) cerr << #x << " = " << x << '\n' #define yn(x) cout << (x==1?"Yes\n":"No\n") #define PI 3.14159265358979323 #define Ststone ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) const ll max_n=1e5+10,max_int=2147483647,mod1=1e9+7,mod2=998244353; ll t,n,m,h,w,a,b,c,d,q; long long ans=0; vector<ll> v,v1,v2; //str s1,s2,s; set<ll> s1,s2,ss; deque<ll> de; void solve(){ cin >> n; for(ll i=0;i<n;i++){ cin >> a; v.pb(a); } ll ans = 0; for(ll i=0;i<30;i++){ de.clear(); for(ll j=0;j<n;j++){ if(v[j]&(1<<i)) de.push_back(j); } de.push_back(mod1); for(ll j=0;j<n;j++){ while(de.front()<j) de.pop_front(); ll x = de.front(); if(x!=mod1){ ans += (1<<i) * (n-x); } } } cout << ans << '\n'; } int main(){ Ststone; //cin >> t; t = 1; while(t--){ solve(); } } /* */