QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#573569 | #9313. Make Max | MeowStarCat | Compile Error | / | / | C++20 | 1.0kb | 2024-09-18 19:15:12 | 2024-09-18 19:15:13 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while(t --) {
int n ;
int a[200010] = {};
int lef[200010] = {};
int rig[200010] = {};
stack<int> s;
cin >> n;
for(int i = 1 ; i <= n ; i ++) {
cin >> a[i];
}
for(int i = 1 ; i <= n ; i ++) {
if(s.empty() || a[i] < a[s.top()]) {
s.push(i);
}
else {
while(!s.empty() && a[i] >= a[s.top()]) {
rig[s.top()] = i;
s.pop();
}
s.push();
}
}
while(!s.empty()) {
rig[s.top()] = n + 1;
s.pop();
}
for(int i = n ;;i --) {
if(s.empty() || a[i] < a[s.top()]) {
s.push(i);
}
else {
while(!s.empty() && a[i] >= a[s.top()]) {
lef[s.top()] = i;
s.pop();
}
s.push(i);
}
}
while(!s.empty()) {
lef[s.top()] = 0;
s.pop();
}
long long ans = 0LL;
for(int i = 1 ; i <= n ; i ++) {
if(!lef[i] || a[lef[i]] != a[i]) {
ans += rig[i] - lef[i] - 2;
}
else {
ans += rig[i] - i - 1;
}
}
cout << ans << endl;
}
}
详细
answer.code: In function ‘int main()’: answer.code:27:39: error: no matching function for call to ‘std::stack<int>::push()’ 27 | s.push(); | ~~~~~~^~ In file included from /usr/include/c++/13/stack:63, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:160, from answer.code:1: /usr/include/c++/13/bits/stl_stack.h:260:7: note: candidate: ‘void std::stack<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]’ 260 | push(const value_type& __x) | ^~~~ /usr/include/c++/13/bits/stl_stack.h:260:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/13/bits/stl_stack.h:265:7: note: candidate: ‘void std::stack<_Tp, _Sequence>::push(value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]’ 265 | push(value_type&& __x) | ^~~~ /usr/include/c++/13/bits/stl_stack.h:265:7: note: candidate expects 1 argument, 0 provided