0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

1471. 【2022.7.11】进化序列(evolve)

https://sjzezoj.com/submission/53672
This commit is contained in:
Baoshuo Ren 2022-07-11 17:33:30 +08:00
parent 6b2c7a391e
commit 2ed9f7a05d
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
22 changed files with 139 additions and 0 deletions

76
S2OJ/1471/1471.cpp Normal file
View File

@ -0,0 +1,76 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 100005;
int n, m, a[N];
long long ans;
struct node {
int l, r, s;
node()
: l(0), r(0), s(0) {}
node(int _l, int _r)
: l(_l), r(_r), s(0) {}
} tr[N << 2];
void pushup(int u) {
tr[u].s = tr[u << 1].s | tr[u << 1 | 1].s;
}
void build(int u, int l, int r) {
tr[u] = node(l, r);
if (l == r) {
tr[u].s = a[l];
return;
}
int mid = l + r >> 1;
build(u << 1, l, mid);
build(u << 1 | 1, mid + 1, r);
pushup(u);
}
int query(int u, int l, int r) {
if (l <= tr[u].l && tr[u].r <= r) return tr[u].s;
int mid = tr[u].l + tr[u].r >> 1;
int res = 0;
if (l <= mid) res |= query(u << 1, l, r);
if (r > mid) res |= query(u << 1 | 1, l, r);
return res;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
build(1, 1, n);
for (int i = 1, j = 1; i <= n; i++) {
while (j < i && query(1, j, i) >= m) j++;
ans += i - j;
}
cout << ans << endl;
return 0;
}

BIN
S2OJ/1471/data/evolve1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/evolve9.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1471/data/problem.conf (Stored with Git LFS) Normal file

Binary file not shown.