用户输出
0 1
0 1
0 7
0 7
0 7
0 7
0 7
0 7
0 7
0 7
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#27414 | #1151. 把你挂在地灵殿门口当装饰品! | Wrong Answer | 0 | 15270 ms | 15168 K | C++ 17 (Clang) / 2.9 K | Komeiji Koishi | 2020-06-30 10:59:09 |
#include <bits/stdc++.h>
#define N 200009
#define ll long long
#define setIO(s) freopen(s ".in", "r", stdin)
using namespace std;
int n, FL, sum;
int a[N], pos[N], id[N], L[N], R[N];
set<int> se[N];
set<int>::iterator it;
set<int> S;
int merge(int x, int y) {
if (x < 1 || x > sum)
return y;
if (y < 1 || y > sum)
return x;
it = se[x].end();
it--;
if (a[*it] < a[*se[y].begin()]) {
if (se[x].size() < se[y].size())
swap(x, y);
L[x] = min(L[x], L[y]);
R[x] = max(R[x], R[y]);
for (it = se[y].begin(); it != se[y].end(); it++) id[*it] = x, se[x].insert(*it);
S.erase(y);
return x;
} else
return y;
}
void solve() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
int x;
scanf("%d", &x), a[x] = i, pos[i] = x;
}
sum = 0;
for (int i = 1, j; i <= n; i = j) {
int pre = a[i];
++sum;
for (j = i; a[j] >= pre; ++j) se[sum].insert(j), pre = a[j], id[j] = sum;
L[sum] = sum - 1, R[sum] = sum + 1;
S.insert(sum);
}
// 有 sum 个平衡树
int pre = 0;
int size = sum;
int minn = N, maxx = -N;
int flag = 0;
for (int i = 0; i <= n; ++i) {
if (i) {
if (pos[i] < pre)
break;
else
pre = pos[i];
// 删掉 pos[i]
int cur = id[pos[i]];
// 删掉 se[cur] 中的 pos[i]
se[cur].erase(pos[i]);
if (se[cur].empty()) {
int a = L[cur], b = R[cur];
R[L[cur]] = R[cur];
L[R[cur]] = L[cur];
S.erase(cur);
merge(a, b);
} else {
int u = cur;
if (L[cur])
u = merge(L[cur], cur);
if (R[u] <= sum)
merge(u, R[u]);
}
}
if (flag == 1) {
minn = min(minn, i), maxx = max(maxx, i);
continue;
}
if (S.size() <= 2) {
if (S.size() <= 1)
minn = min(minn, i), maxx = max(maxx, i), flag = 1;
else {
it = S.begin();
it++;
if ((*se[*it].begin()) > pre)
minn = min(minn, i), maxx = max(maxx, i), flag = 1;
}
}
}
S.clear();
for (int i = 0; i <= n + 1; ++i) se[i].clear();
for (int i = 0; i <= n + 1; ++i) a[i] = pos[i] = id[i] = L[i] = R[i] = 0;
FL = sum = 0;
if (minn == N)
printf("-1 -1\n");
else
printf("%d %d\n", minn, maxx);
}
int main() {
// setIO("input");
int T;
scanf("%d", &T);
while (T--) solve();
return 0;
}
用户输出
0 1
0 1
0 7
0 7
0 7
0 7
0 7
0 7
0 7
0 7
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0 1
0 3
0 9
0 9
0 9
0 9
0 9
0 9
0 9
0 9
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0 2
-1 -1
0 7
0 7
0 7
0 7
0 7
0 7
0 7
0 7
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0 1
-1 -1
0 4
0 4
0 4
0 4
0 4
0 4
0 4
0 4
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0 2
-1 -1
0 7
0 7
0 7
0 7
0 7
0 7
0 7
0 7
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
200000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
<1288805 bytes omitted>
200000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
<1288805 bytes omitted>
200000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
<1288805 bytes omitted>
200000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
<1288805 bytes omitted>
200000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
<1288805 bytes omitted>
200000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
<1288805 bytes omitted>
200000
1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 3
<1288805 bytes omitted>
200000
1 2 3 4 5 6 7 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 3
<1288805 bytes omitted>
200000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 28 30 31 32 34 35 36 37
<1288805 bytes omitted>
200000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
<1288805 bytes omitted>
200000
1 2 4 5 7 8 9 12 13 14 16 18 19 21 22 23 25 27 29 30 33 35 38 40 41 42 43 44 47 50 51 52 53
<1288805 bytes omitted>
200000
1 4 5 9 10 11 13 14 15 16 20 21 25 26 28 31 32 33 35 36 37 38 39 40 41 42 45 46 47 56 58 59
<1288805 bytes omitted>
200000
1 4 5 6 7 9 10 11 16 19 20 21 22 23 29 33 38 40 41 42 43 44 49 50 51 52 54 55 57 60 61 63 64
<1288805 bytes omitted>
200000
3 4 9 11 13 14 15 18 20 22 23 24 25 27 30 32 34 37 40 43 44 47 48 49 50 51 60 62 63 65 67 69
<1288805 bytes omitted>