0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-03 18:56:26 +00:00

#974. 【2019.10雅礼集训14日pmT3】动态数点

https://sjzezoj.com/submission/60760
This commit is contained in:
Baoshuo Ren 2022-10-18 18:14:37 +08:00
parent b233e7ae1d
commit b1eadac5b2
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
42 changed files with 183 additions and 0 deletions

60
S2OJ/974/974.cpp Normal file
View File

@ -0,0 +1,60 @@
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 5e5 + 5;
int n, a[N], val, pre[N], suf[N];
std::vector<int> ans;
std::stack<int> st_pre, st_suf;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
while (!st_pre.empty() && a[st_pre.top()] % a[i] == 0) st_pre.pop();
pre[i] = i - (st_pre.empty() ? 0 : st_pre.top()) - 1;
st_pre.emplace(i);
}
for (int i = n; i; i--) {
while (!st_suf.empty() && a[st_suf.top()] % a[i] == 0) st_suf.pop();
suf[i] = (st_suf.empty() ? n + 1 : st_suf.top()) - i - 1;
st_suf.emplace(i);
}
for (int i = 1; i <= n; i++) {
val = std::max(val, pre[i] + suf[i]);
}
for (int i = 1; i <= n; i++) {
if (pre[i] + suf[i] == val) {
ans.emplace_back(i - pre[i]);
}
}
std::sort(ans.begin(), ans.end());
ans.erase(std::unique(ans.begin(), ans.end()), ans.end());
cout << ans.size() << ' ' << val << endl;
for (int x : ans) {
cout << x << ' ';
}
cout << endl;
return 0;
}

BIN
S2OJ/974/data/point1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point16.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point17.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point18.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point19.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point20.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/974/data/point9.out (Stored with Git LFS) Normal file

Binary file not shown.

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

Binary file not shown.