#include <bits/stdc++.h>
using namespace std;
stack<pair<unsigned long long, int>> sta;
int n;unsigned long long ans;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
long long x;
cin >> x;
while (!sta.empty() && sta.top().first <= x) {
ans ^= sta.top().second;
sta.pop();
}
sta.push({x, i});
ans ^= sta.top().second;
cout << ans << '\n';
}
return 0;
}
这代码一直在#1TLE与#2WA之间反复横跳。。。