diff --git a/S2OJ/1471/1471.cpp b/S2OJ/1471/1471.cpp new file mode 100644 index 00000000..aa16fa3a --- /dev/null +++ b/S2OJ/1471/1471.cpp @@ -0,0 +1,76 @@ +#include + +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; +} diff --git a/S2OJ/1471/data/evolve1.in b/S2OJ/1471/data/evolve1.in new file mode 100644 index 00000000..01cff954 --- /dev/null +++ b/S2OJ/1471/data/evolve1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f43f350b56957865eb3ac2d47e6122ec7cd10e3177300dd227d6e73473c42be +size 118 diff --git a/S2OJ/1471/data/evolve1.out b/S2OJ/1471/data/evolve1.out new file mode 100644 index 00000000..d790bd49 --- /dev/null +++ b/S2OJ/1471/data/evolve1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2e6d31a5983a91251bfae5aefa1c0a19d8ba3cf601d0e8a706b4cfa9661a6b8a +size 2 diff --git a/S2OJ/1471/data/evolve10.in b/S2OJ/1471/data/evolve10.in new file mode 100644 index 00000000..06b913cb --- /dev/null +++ b/S2OJ/1471/data/evolve10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9058dcd280a254a34bb13a616392c92a2cf373c1eea3aad95ad18597a0c5c25d +size 988150 diff --git a/S2OJ/1471/data/evolve10.out b/S2OJ/1471/data/evolve10.out new file mode 100644 index 00000000..40e8777b --- /dev/null +++ b/S2OJ/1471/data/evolve10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a592eedc7aabc45581ea7d71f55c89db3e98d8321c546f4d0485d07880f1968a +size 11 diff --git a/S2OJ/1471/data/evolve2.in b/S2OJ/1471/data/evolve2.in new file mode 100644 index 00000000..fad1625d --- /dev/null +++ b/S2OJ/1471/data/evolve2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cc697fe61427f091e58e1bea7b8056235378a64d0054cfa3c7ca9526ae1532c0 +size 1038 diff --git a/S2OJ/1471/data/evolve2.out b/S2OJ/1471/data/evolve2.out new file mode 100644 index 00000000..8615f82d --- /dev/null +++ b/S2OJ/1471/data/evolve2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d7eaf29180c90f15bdd1e6dd78b6785e206a9d040e6e3bf085846cbc007e922 +size 4 diff --git a/S2OJ/1471/data/evolve3.in b/S2OJ/1471/data/evolve3.in new file mode 100644 index 00000000..918ad66f --- /dev/null +++ b/S2OJ/1471/data/evolve3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cf053b86b7eb41529fd1abb8e0f6d93dd5cc30663092dca30574f2843b3ecb46 +size 10021 diff --git a/S2OJ/1471/data/evolve3.out b/S2OJ/1471/data/evolve3.out new file mode 100644 index 00000000..a8d595dc --- /dev/null +++ b/S2OJ/1471/data/evolve3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab42a23a83739854f25562051063cd7442c7290b164619e72ab554d580d7a25c +size 6 diff --git a/S2OJ/1471/data/evolve4.in b/S2OJ/1471/data/evolve4.in new file mode 100644 index 00000000..b1f4533e --- /dev/null +++ b/S2OJ/1471/data/evolve4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d9ab1bb4358b6ce31412382222816606b26747f0663c019cf6774e65bec7b3d0 +size 493731 diff --git a/S2OJ/1471/data/evolve4.out b/S2OJ/1471/data/evolve4.out new file mode 100644 index 00000000..e98d9a11 --- /dev/null +++ b/S2OJ/1471/data/evolve4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ba6f9952abddce8a3628fbe8070c7197d887040a4c50d07f1a72ce2113ce65d4 +size 10 diff --git a/S2OJ/1471/data/evolve5.in b/S2OJ/1471/data/evolve5.in new file mode 100644 index 00000000..23765bb8 --- /dev/null +++ b/S2OJ/1471/data/evolve5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae6b8e5be9441e8e3b3fdef7a8c72308be80d8903b3917c5a76c6b44d58f55ed +size 494087 diff --git a/S2OJ/1471/data/evolve5.out b/S2OJ/1471/data/evolve5.out new file mode 100644 index 00000000..80e1d133 --- /dev/null +++ b/S2OJ/1471/data/evolve5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f09fa7f5d19127cabb4f826aaef6dd8a827a6e61be6ba3b3de5d698eab7a4a2c +size 10 diff --git a/S2OJ/1471/data/evolve6.in b/S2OJ/1471/data/evolve6.in new file mode 100644 index 00000000..99ab6fae --- /dev/null +++ b/S2OJ/1471/data/evolve6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9eb132bed0f59759654c707d9fb3c48116790bceaa126ab7ef9c6fd55682a6b4 +size 493847 diff --git a/S2OJ/1471/data/evolve6.out b/S2OJ/1471/data/evolve6.out new file mode 100644 index 00000000..1d4d7b25 --- /dev/null +++ b/S2OJ/1471/data/evolve6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dcf560676163cf554e0ab9a8d54edef82f9e3c7d3b07f52b9250da66ca95f09a +size 10 diff --git a/S2OJ/1471/data/evolve7.in b/S2OJ/1471/data/evolve7.in new file mode 100644 index 00000000..1c0175d0 --- /dev/null +++ b/S2OJ/1471/data/evolve7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:25d391178818135aa626fbb0f6f5f15f3ec8d07cde0616f5981bd9447dacf66f +size 987998 diff --git a/S2OJ/1471/data/evolve7.out b/S2OJ/1471/data/evolve7.out new file mode 100644 index 00000000..b03daa6c --- /dev/null +++ b/S2OJ/1471/data/evolve7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:05493c6e443fab9a7127ecc2d124e4007272343e4cd320e2f83d7a755b26453e +size 11 diff --git a/S2OJ/1471/data/evolve8.in b/S2OJ/1471/data/evolve8.in new file mode 100644 index 00000000..6775a489 --- /dev/null +++ b/S2OJ/1471/data/evolve8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:328c6612b3e66ea1b655e37549078d9d825090663d02c66b631051236c5801c5 +size 988006 diff --git a/S2OJ/1471/data/evolve8.out b/S2OJ/1471/data/evolve8.out new file mode 100644 index 00000000..07201ce4 --- /dev/null +++ b/S2OJ/1471/data/evolve8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9476d2b4e8088cfab8e1b194aaba0c424b029d11d3486cc91ac04caaf046fcd3 +size 11 diff --git a/S2OJ/1471/data/evolve9.in b/S2OJ/1471/data/evolve9.in new file mode 100644 index 00000000..f1194bb5 --- /dev/null +++ b/S2OJ/1471/data/evolve9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ac4fea99cc39df95c7453b54e4509ca21d5ea02a2a3fd81434aa55f903ed8f3e +size 988518 diff --git a/S2OJ/1471/data/evolve9.out b/S2OJ/1471/data/evolve9.out new file mode 100644 index 00000000..b11e5357 --- /dev/null +++ b/S2OJ/1471/data/evolve9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dfc08a8e5ee4d9d134221ee1c3c7d88907c2dd6fda8f7ac2cb9223a66ef859c0 +size 11 diff --git a/S2OJ/1471/data/problem.conf b/S2OJ/1471/data/problem.conf new file mode 100644 index 00000000..32857c9a --- /dev/null +++ b/S2OJ/1471/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b51ba9b9cd7b90dafa2aa147c0628213531b19dcea7d54a803b40ba4bed05277 +size 181