mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 16:28:47 +00:00
Compare commits
27 Commits
3256f5c172
...
efa569b497
Author | SHA1 | Date | |
---|---|---|---|
efa569b497 | |||
546fa22701 | |||
fefe23f287 | |||
882d6e0cd9 | |||
273f8ac7ff | |||
4ba381064b | |||
65803a3023 | |||
a4335d561f | |||
0317384c93 | |||
1a5233b4cb | |||
5ef3680762 | |||
487d68a098 | |||
1d2f77ea7d | |||
686aaa9256 | |||
e10acb110f | |||
244f91eef3 | |||
0c692c1357 | |||
67fcc9cd0a | |||
9f201129c2 | |||
2e41798985 | |||
e429788bf5 | |||
7579397dc7 | |||
aa464c71a2 | |||
c971054ca4 | |||
592ff4f485 | |||
fa7add2782 | |||
f738250c11 |
84
BZOJ/1015/1015.cpp
Normal file
84
BZOJ/1015/1015.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 4e5 + 5;
|
||||
|
||||
int n, m, k, a[N], fa[N], ans[N];
|
||||
bool vis[N], del[N];
|
||||
std::vector<int> g[N];
|
||||
|
||||
int find(int x) {
|
||||
return fa[x] == x ? x : fa[x] = find(fa[x]);
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> m;
|
||||
|
||||
for (int i = 0, x, y; i < m; i++) {
|
||||
cin >> x >> y;
|
||||
|
||||
g[x].push_back(y);
|
||||
g[y].push_back(x);
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; i++) fa[i] = i;
|
||||
|
||||
cin >> k;
|
||||
|
||||
for (int i = 1; i <= k; i++) {
|
||||
cin >> a[i];
|
||||
|
||||
del[a[i]] = true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (!del[i]) {
|
||||
for (int v : g[i]) {
|
||||
if (!del[v]) {
|
||||
int f1 = find(i),
|
||||
f2 = find(v);
|
||||
|
||||
fa[f1] = f2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int cnt = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (fa[i] == i && !del[i]) cnt++;
|
||||
}
|
||||
ans[k] = cnt;
|
||||
|
||||
for (int i = k; i; i--) {
|
||||
del[a[i]] = false;
|
||||
cnt++;
|
||||
|
||||
for (int v : g[a[i]]) {
|
||||
if (!del[v]) {
|
||||
int f1 = find(a[i]),
|
||||
f2 = find(v);
|
||||
|
||||
if (f1 != f2) {
|
||||
fa[f1] = f2;
|
||||
cnt--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ans[i - 1] = cnt;
|
||||
}
|
||||
|
||||
for (int i = 0; i <= k; i++) {
|
||||
cout << ans[i] << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
BZOJ/1015/data/1.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/1.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/10.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/10.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/2.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/2.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/3.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/3.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/4.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/4.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/5.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/5.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/6.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/6.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/7.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/7.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/8.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/8.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/9.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1015/data/9.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1015/data/9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
68
BZOJ/1226/1226.cpp
Normal file
68
BZOJ/1226/1226.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 1005;
|
||||
const int INF = 0x3f3f3f3f;
|
||||
|
||||
int c, n, f[N][1 << 8][20];
|
||||
std::pair<int, int> a[N];
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> c;
|
||||
|
||||
while (c--) {
|
||||
memset(f, 0x3f, sizeof(f));
|
||||
|
||||
cin >> n;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i].first >> a[i].second;
|
||||
}
|
||||
|
||||
f[1][0][7] = 0;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 0; j < 1 << 8; j++) {
|
||||
for (int k = -8; k <= 7; k++) {
|
||||
if (f[i][j][k + 8] != INF) {
|
||||
if (j & 1) { // 当前同学吃了,无需考虑后方
|
||||
f[i + 1][j >> 1][k + 7] = std::min(f[i + 1][j >> 1][k + 7], f[i][j][k + 8]);
|
||||
} else {
|
||||
int t = INF;
|
||||
|
||||
for (int l = 0; l <= 7; l++) {
|
||||
if (j & 1 << l) continue;
|
||||
if (i + l > t) break;
|
||||
|
||||
if (i + l <= n) t = std::min(t, i + l + a[i + l].second);
|
||||
else t = std::min(t, i + l);
|
||||
|
||||
if (i + k) {
|
||||
int x = i + k <= n ? a[i + k].first : 0,
|
||||
y = i + l <= n ? a[i + l].first : 0;
|
||||
f[i][j | 1 << l][l + 8] = std::min(f[i][j | 1 << l][l + 8], f[i][j][k + 8] + (x ^ y));
|
||||
} else {
|
||||
f[i][j | 1 << l][l + 8] = std::min(f[i][j | 1 << l][l + 8], f[i][j][k + 8]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ans = INF;
|
||||
for (int i = 0; i <= 8; i++) {
|
||||
ans = std::min(ans, f[n + 1][0][i]);
|
||||
}
|
||||
cout << ans << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
BZOJ/1226/data/1.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/1.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/10.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/10.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/11.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/11.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/12.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/12.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/12.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/12.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/13.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/13.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/13.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/13.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/14.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/14.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/14.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/14.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/15.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/15.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/15.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/15.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/16.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/16.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/16.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/16.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/17.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/17.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/17.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/17.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/18.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/18.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/18.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/18.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/19.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/19.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/19.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/19.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/2.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/2.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/20.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/20.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/20.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/20.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/21.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/21.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/21.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/21.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/22.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/22.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/22.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/22.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/23.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/23.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/23.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/23.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/24.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/24.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/24.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/24.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/25.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/25.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/25.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/25.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/3.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/3.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/4.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/4.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/5.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/5.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/6.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/6.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/7.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/7.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/8.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/8.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/9.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1226/data/9.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1226/data/9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
112
BZOJ/1499/1499.cpp
Normal file
112
BZOJ/1499/1499.cpp
Normal file
@ -0,0 +1,112 @@
|
||||
#include <iostream>
|
||||
#include <deque>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 205;
|
||||
|
||||
int n, m, x, y, k, s, t, d, f[N][N], ans;
|
||||
bool g[N][N];
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> m >> x >> y >> k;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= m; j++) {
|
||||
char c;
|
||||
cin >> c;
|
||||
g[i][j] = c == 'x';
|
||||
f[i][j] = -0x3f3f3f3f;
|
||||
}
|
||||
}
|
||||
|
||||
f[x][y] = 0;
|
||||
for (int i = 1; i <= k; i++) {
|
||||
cin >> s >> t >> d;
|
||||
|
||||
int len = t - s + 1;
|
||||
switch (d) {
|
||||
case 1: { // 上
|
||||
for (int y = 1; y <= m; y++) {
|
||||
std::deque<std::pair<int, int>> q;
|
||||
for (int j = 1, x = n; x; j++, x--) {
|
||||
if (g[x][y]) {
|
||||
q.clear();
|
||||
} else {
|
||||
while (!q.empty() && q.back().second < f[x][y] - j) q.pop_back();
|
||||
q.push_back(std::make_pair(j, f[x][y] - j));
|
||||
while (!q.empty() && j - q.front().first > len) q.pop_front();
|
||||
f[x][y] = q.front().second + j;
|
||||
ans = std::max(ans, f[x][y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: { // 下
|
||||
for (int y = 1; y <= m; y++) {
|
||||
std::deque<std::pair<int, int>> q;
|
||||
for (int j = 1, x = 1; x <= n; j++, x++) {
|
||||
if (g[x][y]) {
|
||||
q.clear();
|
||||
} else {
|
||||
while (!q.empty() && q.back().second < f[x][y] - j) q.pop_back();
|
||||
q.push_back(std::make_pair(j, f[x][y] - j));
|
||||
while (!q.empty() && j - q.front().first > len) q.pop_front();
|
||||
f[x][y] = q.front().second + j;
|
||||
ans = std::max(ans, f[x][y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: { // 左
|
||||
for (int x = 1; x <= n; x++) {
|
||||
std::deque<std::pair<int, int>> q;
|
||||
for (int j = 1, y = m; y; j++, y--) {
|
||||
if (g[x][y]) {
|
||||
q.clear();
|
||||
} else {
|
||||
while (!q.empty() && q.back().second < f[x][y] - j) q.pop_back();
|
||||
q.push_back(std::make_pair(j, f[x][y] - j));
|
||||
while (!q.empty() && j - q.front().first > len) q.pop_front();
|
||||
f[x][y] = q.front().second + j;
|
||||
ans = std::max(ans, f[x][y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: { // 右
|
||||
for (int x = 1; x <= n; x++) {
|
||||
std::deque<std::pair<int, int>> q;
|
||||
for (int j = 1, y = 1; y <= m; j++, y++) {
|
||||
if (g[x][y]) {
|
||||
q.clear();
|
||||
} else {
|
||||
while (!q.empty() && q.back().second < f[x][y] - j) q.pop_back();
|
||||
q.push_back(std::make_pair(j, f[x][y] - j));
|
||||
while (!q.empty() && j - q.front().first > len) q.pop_front();
|
||||
f[x][y] = q.front().second + j;
|
||||
ans = std::max(ans, f[x][y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << ans << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
BZOJ/1499/data/1.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/1.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/10.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/10.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/2.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/2.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/3.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/3.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/4.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/4.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/5.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/5.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/6.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/6.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/7.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/7.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/8.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/8.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/9.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1499/data/9.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1499/data/9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
183
BZOJ/1552/1552.cpp
Normal file
183
BZOJ/1552/1552.cpp
Normal file
@ -0,0 +1,183 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <limits>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 1e5 + 5;
|
||||
|
||||
struct node {
|
||||
node *lchild, *rchild;
|
||||
size_t size;
|
||||
unsigned key;
|
||||
int value, min;
|
||||
bool reversed;
|
||||
|
||||
node()
|
||||
: lchild(nullptr),
|
||||
rchild(nullptr),
|
||||
size(0),
|
||||
key(rand()),
|
||||
value(0),
|
||||
min(std::numeric_limits<int>::max()),
|
||||
reversed(false) {}
|
||||
|
||||
node(int _value)
|
||||
: lchild(nullptr),
|
||||
rchild(nullptr),
|
||||
size(1),
|
||||
key(rand()),
|
||||
value(_value),
|
||||
min(_value),
|
||||
reversed(false) {}
|
||||
|
||||
~node() {
|
||||
if (lchild != nullptr) delete lchild;
|
||||
if (rchild != nullptr) delete rchild;
|
||||
}
|
||||
|
||||
inline size_t lsize() {
|
||||
return lchild == nullptr ? 0 : lchild->size;
|
||||
}
|
||||
|
||||
inline size_t rsize() {
|
||||
return rchild == nullptr ? 0 : rchild->size;
|
||||
}
|
||||
|
||||
inline void pushup() {
|
||||
size = lsize() + 1 + rsize();
|
||||
min = value;
|
||||
|
||||
if (lchild != nullptr) {
|
||||
min = std::min(min, lchild->min);
|
||||
}
|
||||
|
||||
if (rchild != nullptr) {
|
||||
min = std::min(min, rchild->min);
|
||||
}
|
||||
}
|
||||
|
||||
inline void pushdown() {
|
||||
if (reversed) {
|
||||
std::swap(lchild, rchild);
|
||||
if (lchild != nullptr) lchild->reversed = !lchild->reversed;
|
||||
if (rchild != nullptr) rchild->reversed = !rchild->reversed;
|
||||
reversed = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
int n, b[N];
|
||||
std::pair<int, int> a[N];
|
||||
node *root;
|
||||
|
||||
std::pair<node *, node *> split(node *u, int k) {
|
||||
if (u == nullptr) return std::make_pair(nullptr, nullptr);
|
||||
|
||||
u->pushdown();
|
||||
|
||||
if (k <= u->lsize()) {
|
||||
auto o = split(u->lchild, k);
|
||||
|
||||
u->lchild = o.second;
|
||||
u->pushup();
|
||||
o.second = u;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
auto o = split(u->rchild, k - u->lsize() - 1);
|
||||
|
||||
u->rchild = o.first;
|
||||
u->pushup();
|
||||
o.first = u;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
node *merge(node *x, node *y) {
|
||||
if (x == nullptr) return y;
|
||||
if (y == nullptr) return x;
|
||||
|
||||
if (x->key < y->key) {
|
||||
x->pushdown();
|
||||
x->rchild = merge(x->rchild, y);
|
||||
x->pushup();
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
y->pushdown();
|
||||
y->lchild = merge(x, y->lchild);
|
||||
y->pushup();
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
void reverse(int k) {
|
||||
auto x = split(root, k);
|
||||
auto y = split(x.first, k - 1);
|
||||
if (y.first != nullptr) y.first->reversed = !y.first->reversed;
|
||||
delete y.second;
|
||||
root = merge(y.first, x.second);
|
||||
}
|
||||
|
||||
int find(node *p) {
|
||||
int k = 1;
|
||||
|
||||
while (p != nullptr) {
|
||||
p->pushdown();
|
||||
|
||||
if (p->lchild != nullptr && p->min == p->lchild->min) {
|
||||
p = p->lchild;
|
||||
} else if (p->rchild != nullptr && p->min == p->rchild->min) {
|
||||
k += p->lsize() + 1;
|
||||
p = p->rchild;
|
||||
} else {
|
||||
return k + p->lsize();
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i].first;
|
||||
|
||||
a[i].second = i;
|
||||
}
|
||||
|
||||
std::sort(a + 1, a + 1 + n);
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
b[a[i].second] = i;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
root = merge(root, new node(b[i]));
|
||||
}
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
int k = find(root);
|
||||
|
||||
reverse(k);
|
||||
|
||||
cout << k + i - 1 << ' ';
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
|
||||
// Cleanup
|
||||
delete root;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
BZOJ/1552/data/1.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1552/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1552/data/1.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1552/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1552/data/10.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1552/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1552/data/10.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1552/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1552/data/11.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1552/data/11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1552/data/11.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1552/data/11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user