0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 13:16:26 +00:00

#1462. SpireRound#1 红裤衩

https://sjzezoj.com/submission/54829
This commit is contained in:
Baoshuo Ren 2022-08-12 08:21:41 +08:00
parent ecea56b0ac
commit 9619e98817
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
47 changed files with 224 additions and 0 deletions

86
S2OJ/1462/1462.cpp Normal file
View File

@ -0,0 +1,86 @@
#include <iostream>
#include <algorithm>
#include <limits>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 3e5 + 5;
int t, n, a[N], d[N], cnt[N], f[N][35], g[N];
int calc(int l, int r) {
if (d[l] == 0) return 1;
std::for_each(f + l, f + r + 1, [](int *it) { std::fill_n(it, 35, -1); });
f[l][cnt[l]] = l - 1;
for (int i = l + 1; i <= r; i++) {
f[i][cnt[i]] = i - 1;
for (int j = cnt[i] + 1; j <= 32; j++) {
if (f[f[i][j - 1]][j - 1] == -1) break;
f[i][j] = f[f[i][j - 1]][j - 1];
if (f[i][j] < l) break;
}
}
std::fill(g + l, g + r + 1, std::numeric_limits<int>::max());
g[l - 1] = 0;
for (int i = l; i <= r; i++) {
for (int j = 0; j <= 32; j++) {
if (~f[i][j]) {
g[i] = std::min(g[i], g[f[i][j]] + 1);
}
}
}
return g[r];
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> t;
while (t--) {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i < n; i++) {
d[i] = a[i + 1] - a[i];
}
for (int i = 1; i < n; i++) {
cnt[i] = 0;
while (d[i] && !(d[i] & 1)) {
cnt[i]++;
d[i] >>= 1;
}
}
int lst = 1, ans = 0;
for (int i = 1; i < n - 1; i++) {
if (d[i] != d[i + 1]) {
ans += calc(lst, i);
lst = i + 1;
}
}
ans += calc(lst, n - 1);
cout << ans + 1 << endl;
}
return 0;
}

BIN
S2OJ/1462/data/download.zip (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/ex_red1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/ex_red1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/ex_red2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/ex_red2.out (Stored with Git LFS) Normal file

Binary file not shown.

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

Binary file not shown.

BIN
S2OJ/1462/data/red1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red16.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red17.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red18.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red19.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red20.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1462/data/red9.out (Stored with Git LFS) Normal file

Binary file not shown.