結果

問題 No.2300 Substring OR Sum
コンテスト
ユーザー 👑 hitonanode
提出日時 2023-05-12 22:28:01
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 8 ms / 2,000 ms
+ 867µs
コード長 779 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 129 ms
コンパイル使用メモリ 43,356 KB
実行使用メモリ 9,896 KB
最終ジャッジ日時 2026-10-01 13:07:32
合計ジャッジ時間 2,267 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#pragma GCC optimize("O3,unroll-loops")
#include <cstdio>
#include <ctype.h>

template <typename T> T rd_integer() {
    T ret = 0;
    bool minus = false;

    char c = getchar_unlocked();
    while (!isdigit(c)) minus |= (c == '-'), c = getchar_unlocked();
    while (isdigit(c)) ret = (ret << 1) + (ret << 3) + (c ^ 48), c = getchar_unlocked();

    return minus ? -ret : ret;
}
int rdi() { return rd_integer<int>(); }

int A[200000];

int main() {
    int N = rdi();

    for (int i = 0; i < N; ++i) A[i] = rdi();
    unsigned long long ret = 0;

    for (int d = 27; d >= 0; --d, ret *= 2) {
        int last = 0;
        for (int i = 0; i < N; ++i) {
            if ((A[i] >> d) & 1) last = i + 1;
            ret += last;
        }
    }

    printf("%lld\n", ret / 2);
}
0