跳到正文

个人记录

gjbiforjbior

hhsyh约 1 分钟
原文
文章信息与版本

文章信息

收录
2026年2月28日
更新
2026年2月28日
篇幅
约 1 分钟

版本

  1. v2当前
  2. v1
C++
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
struct node{
	unsigned long long x;
	int y;
};
stack<node>q;
int n;
unsigned long long ans;
node tmp;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>tmp.x;
		tmp.y=i;
		while(!q.empty()&&q.top().x<=tmp.x){
			ans^=q.top().y;
			q.pop();
		}
		ans^=i;
		q.push(tmp);
		cout<<ans<<"\n";
	}
	return 0;
}
原文