用户输出
-1 -1
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#27446 | #1151. 把你挂在地灵殿门口当装饰品! | Wrong Answer | 5 | 658 ms | 11388 K | C++ 17 (Clang) / 2.1 K | Komeiji Koishi | 2020-06-30 11:15:42 |
#include <bits/stdc++.h>
#define maxn 200050
using namespace std;
int n, a[maxn];
struct node {
int cnt;
int lnum, llen;
int rnum, rlen;
} T[maxn << 2];
#define cnt(k) T[k].cnt
#define lnum(k) T[k].lnum
#define rnum(k) T[k].rnum
#define llen(k) T[k].llen
#define rlen(k) T[k].rlen
void update(int k) {
int ls = k << 1, rs = k << 1 | 1;
lnum(k) = cnt(ls) ? lnum(ls) : lnum(rs);
rnum(k) = cnt(rs) ? rnum(rs) : rnum(ls);
cnt(k) = cnt(ls) + cnt(rs);
llen(k) = llen(ls), rlen(k) = rlen(rs);
if (!cnt(ls) || !cnt(rs) || rnum(ls) < lnum(rs)) {
if (llen(ls) == cnt(ls))
llen(k) += llen(rs);
if (rlen(rs) == cnt(rs))
rlen(k) += rlen(ls);
}
}
void build(int k, int l, int r) {
if (l == r) {
cnt(k) = llen(k) = rlen(k) = 1;
lnum(k) = rnum(k) = a[l];
} else {
int mid = (l + r) >> 1;
build(k << 1, l, mid);
build(k << 1 | 1, mid + 1, r);
update(k);
}
// cout<<k<<" "<<l<<" "<<r<<":"<<cnt(k)<<" "<<lnum(k)<<","<<rnum(k)<<" "<<llen(k)<<","<<rlen(k)<<endl;
}
void change(int k, int l, int r, int p) {
if (l == r) {
cnt(k) = llen(k) = rlen(k) = 0;
lnum(k) = rnum(k) = 0;
} else {
int mid = (l + r) >> 1;
if (p <= mid)
change(k << 1, l, mid, p);
else
change(k << 1 | 1, mid + 1, r, p);
update(k);
}
}
int main() {
int Tc;
Tc = 1;
while (Tc--) {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", a + i);
build(1, 1, n);
int mn = n + 1, mx = 0;
if (llen(1) + rlen(1) >= n)
mn = mx = 0;
int j = 0;
for (int i = 1; i <= n; ++i) {
if (a[i - 1] > a[i])
break;
j = max(j, a[i]);
change(1, 1, n, a[i]);
// cout<<i<<":"<<llen(1)<<" "<<rlen(1)<<" "<<j-i<<endl;
if (llen(1) + rlen(1) >= cnt(1) && llen(1) >= j - i) {
// cout<<"upd:"<<i<<endl;
mn = min(mn, i);
mx = max(mx, i);
}
}
if (mn > mx)
mn = mx = -1;
printf("%d %d\n", mn, mx);
}
return 0;
}
用户输出
-1 -1
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
2 3
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
-1 -1
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
用户输出
0 6
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>
用户输出
-1 -1
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>
用户输出
-1 -1
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>
用户输出
-1 -1
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>
用户输出
-1 -1
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>
用户输出
-1 -1
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>
用户输出
-1 -1
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
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>
用户输出
-1 -1
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
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>
用户输出
-1 -1
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 18 19 20 21 22 23 24 25 26 27 28 30 31 32 34 35 36 37
<1288805 bytes omitted>
用户输出
-1 -1
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>
用户输出
-1 -1
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
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>
用户输出
-1 -1
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
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>
用户输出
-1 -1
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
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>
用户输出
-1 -1
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
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>
用户输出
-1 -1
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0