小道消息!一蒟蒻写B3666单调栈不知为什么WA,求各位帮忙调试
  • 板块灌水区
  • 楼主Zq_water
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/7/29 20:30
  • 上次更新2024/7/29 21:37:22
查看原帖
小道消息!一蒟蒻写B3666单调栈不知为什么WA,求各位帮忙调试
895435
Zq_water楼主2024/7/29 20:30
#include<bits/stdc++.h>
#define INF 1e16
#define endl '\n'
#define PI acos(-1)
#define pb push_back
#define int long long
#define mem(x,v) memset(x,v,sizeof x)
using namespace std;
const int N = 1e6+5;
inline int read(){
	register int x=0,f=1;register char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}

int n,top,ans;
int a[N],st[N];

signed main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		while(top&&a[st[top]]<=a[i])ans^=st[top],top--;
		st[++top]=i,ans^=i;
		cout<<ans<<endl;
	}
	return 0;
}
2024/7/29 20:30
加载中...