社区讨论
本人已疯
B3666求数列所有后缀最大值的位置参与者 4已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @lwvvyzbp
- 此快照首次捕获于
- 2024/06/01 17:03 2 年前
- 此快照最后确认于
- 2024/06/01 19:23 2 年前
CPP
#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之间反复横跳。。。
回复
共 3 条回复,欢迎继续交流。
正在加载回复...