結果

問題 No.2300 Substring OR Sum
ユーザー 👑 hitonanodehitonanode
提出日時 2023-05-12 22:28:01
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 779 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 33,408 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-06 12:30:12
合計ジャッジ時間 1,489 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 12 ms
5,376 KB
testcase_04 AC 11 ms
5,376 KB
testcase_05 AC 13 ms
5,376 KB
testcase_06 AC 7 ms
5,376 KB
testcase_07 AC 37 ms
5,376 KB
testcase_08 AC 16 ms
5,376 KB
testcase_09 AC 13 ms
5,376 KB
testcase_10 AC 29 ms
5,376 KB
testcase_11 AC 37 ms
5,376 KB
testcase_12 AC 35 ms
5,376 KB
testcase_13 AC 10 ms
5,376 KB
testcase_14 AC 11 ms
5,376 KB
testcase_15 AC 16 ms
5,376 KB
testcase_16 AC 28 ms
5,376 KB
testcase_17 AC 35 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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 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