QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#573569#9313. Make MaxMeowStarCatCompile Error//C++201.0kb2024-09-18 19:15:122024-09-18 19:15:13

Judging History

你现在查看的是最新测评结果

  • [2024-09-18 19:15:13]
  • 评测
  • [2024-09-18 19:15:12]
  • 提交

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