結果

問題 No.2300 Substring OR Sum
ユーザー yorry2101
提出日時 2023-05-12 22:52:29
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 460 bytes
コンパイル時間 677 ms
コンパイル使用メモリ 71,268 KB
最終ジャッジ日時 2025-02-12 23:27:22
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 TLE * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:23: warning: ‘bwor’ may be used uninitialized [-Wmaybe-uninitialized]
   17 |             else bwor = bwor | a[j];
main.cpp:11:9: note: ‘bwor’ was declared here
   11 |     int bwor;
      |         ^~~~

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    long long sum = 0;
    for (int i = 0; i < n; i++) cin >> a[i];
    
    int bwor;
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            if (j==i) {
                bwor = a[i] | a[j];
            }
            else bwor = bwor | a[j];
            sum += bwor;
        }
    }
    cout << sum << endl;
}
0