@[TooAmazing](/user/780034) 建议您详细说说,不然会显得很无意义
by ifffer_2137 @ 2024-06-26 18:25:26
```cpp
#include <bits/stdc++.h>
using namespace std;
long long he = 1 , last[3000005] , a[3000005];
int main ()
{
int n;
cin >> n;
for (int i = 1;i <= n;i ++) cin >> a[i];
for (int i = n - 1;i >= 1;i --)
if (a[i] < a[i + 1]) last[i] = i + 1;
else
{
int j = last[i + 1];
while (j && a[j] < a[i]) j = last[j];
last[i] = j;
}
for (int i = 1;i <= n;i ++) cout << last[i] << " ";
}
```
by TooAmazing @ 2024-06-27 17:02:50
@[ifffer_2137](/user/677440)
大概就是如果右边的比他大,那么就直接赋值,否则就跳到第一个比他右边大的地方
by TooAmazing @ 2024-06-27 17:05:32
%%%
by DoctorBobo @ 2024-07-04 00:19:07
@[DoctorBobo](/user/83016) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
by TooAmazing @ 2024-07-06 19:16:36