社区讨论
代码球跳
B3666求数列所有后缀最大值的位置参与者 4已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @lvf8ickl
- 此快照首次捕获于
- 2024/04/25 20:43 2 年前
- 此快照最后确认于
- 2024/04/26 06:55 2 年前
CPP
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int a[N],ans=0;
int b[N],n,c[N];
stack<int>st;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
a[0]=1e9;
st.push(0);
// b[0]=1e9;
for(int j=1;j<=n;j++)
{
for(int k=1;k<=j;k++)
c[k]=a[k];
for(int i=j;i>=1;i--)
{
while(c[st.top()]<=c[i])
st.pop();
b[i]=st.top();
st.push(i);
}
for(int k=1;k<=j;k++)
ans^=b[k];
cout<<ans<<'\n';
}
// for(int i=1;i<=n;i++)
// cout<<b[i]<<'\n';
return 0;
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...