結果
問題 | No.2300 Substring OR Sum |
ユーザー | NAMIDAIRO |
提出日時 | 2023-05-12 21:29:57 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 112 ms / 2,000 ms |
コード長 | 1,040 bytes |
コンパイル時間 | 1,207 ms |
コンパイル使用メモリ | 116,140 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-05-06 11:06:02 |
合計ジャッジ時間 | 3,023 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | 33 ms
5,376 KB |
testcase_04 | AC | 28 ms
5,376 KB |
testcase_05 | AC | 35 ms
5,376 KB |
testcase_06 | AC | 19 ms
5,376 KB |
testcase_07 | AC | 109 ms
5,376 KB |
testcase_08 | AC | 47 ms
5,248 KB |
testcase_09 | AC | 37 ms
5,376 KB |
testcase_10 | AC | 86 ms
5,376 KB |
testcase_11 | AC | 100 ms
5,376 KB |
testcase_12 | AC | 112 ms
5,376 KB |
testcase_13 | AC | 90 ms
5,376 KB |
testcase_14 | AC | 37 ms
5,376 KB |
testcase_15 | AC | 50 ms
5,376 KB |
testcase_16 | AC | 86 ms
5,376 KB |
testcase_17 | AC | 109 ms
5,376 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 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <map> #include <queue> #include <set> #include <random> #include <iomanip> #include <string> #include <cmath> #include <complex> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) template<class T> using vi = vector<T>; template<class T> using vii = vector<vi<T>>; template<class T> using viii = vector<vii<T>>; using P = pair<ll, int>; void chmin(ll & x, ll y) { x = min(x, y); } void chmax(ll& x, ll y) { x = max(x, y); } int main() { ll n; cin >> n; vi<ll> a(n); rep(i, n) cin >> a[i]; ll ans = 0; const int mx = 28; rep(i, mx) { ll cnt = 0; ans += (1LL << i) * n * (n + 1) / 2; rep(j, n) { if (a[j] >> i & 1) { ans -= (1LL << i) * cnt * (cnt + 1) / 2; cnt = 0; } else cnt++; } if (cnt) ans -= (1LL << i) * cnt * (cnt + 1) / 2; } cout << ans << endl; return 0; }