結果

問題 No.2300 Substring OR Sum
ユーザー hitonanodehitonanode
提出日時 2023-05-12 22:27:10
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 774 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 33,664 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-28 18:55:47
合計ジャッジ時間 1,524 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 main() {
    int N = rdi();
    int A[200000];

    for (int i = 0; i < N; ++i) A[i] = rdi();
    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