結果

問題 No.2300 Substring OR Sum
ユーザー StstoneStstone
提出日時 2023-05-16 10:52:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,223 bytes
コンパイル時間 3,064 ms
コンパイル使用メモリ 217,532 KB
実行使用メモリ 14,056 KB
最終ジャッジ日時 2024-05-08 09:26:07
合計ジャッジ時間 14,125 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 247 ms
5,376 KB
testcase_04 AC 190 ms
5,376 KB
testcase_05 AC 251 ms
5,376 KB
testcase_06 AC 114 ms
5,376 KB
testcase_07 AC 1,093 ms
9,320 KB
testcase_08 AC 386 ms
5,732 KB
testcase_09 AC 283 ms
5,376 KB
testcase_10 AC 837 ms
7,904 KB
testcase_11 AC 959 ms
8,552 KB
testcase_12 AC 1,108 ms
9,188 KB
testcase_13 TLE -
testcase_14 AC 29 ms
5,376 KB
testcase_15 AC 400 ms
5,864 KB
testcase_16 AC 835 ms
7,904 KB
testcase_17 AC 1,070 ms
9,168 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
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++){
        ss.clear();
        for(ll j=0;j<n;j++){
            if(v[j]&(1<<i)) ss.insert(j);
        }
        ss.insert(mod1);
        for(ll j=0;j<n;j++){
            ll x = *ss.lower_bound(j);
            if(x!=mod1){
                ans += (1<<i) * (n-x);
            }
        }
    }
    cout << ans << '\n';
}

int main(){
    Ststone;
    //cin >> t;
    t = 1;
    while(t--){
        solve();
    }
}

/*
*/
0