@[FanSizhe127](/user/576173) 不妨反向思考,倒着枚举牛,去找可以看到这头牛的牛,这样就不会超了。
by _AC_problem_er_ @ 2022-10-18 21:21:23
我定义 $f$ 为答案数组。
```cpp
j = i - 1;
while(a[j] < a[i] && j > 0 && f[j] == 0) {
f[j] = i;
-- j;
}
```
by _AC_problem_er_ @ 2022-10-18 21:22:29