样例过了但wa了
(看了题解没多大区别,但就是找不出错误)
代码:
#include <bits/stdc++.h>
using namespace std;
int n,ans=0;
unsigned long long a[1000005];
stack <unsigned long long> st;
int main(){
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=n;i++){
while(st.size() && a[st.top()]<=a[i]){
ans^=a[st.top()];
st.pop();
}
ans^=i;
st.push(i);
cout<<ans<<endl;
}
return 0;
}
求大佬帮忙