QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214842#5108. Prehistoric ProgramsderetoCompile Error//C++14849b2023-10-15 00:27:142023-10-15 00:27:14

Judging History

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

  • [2023-10-15 00:27:14]
  • 评测
  • [2023-10-15 00:27:14]
  • 提交

answer

#include<iostream>
#include<string>
#include<vector>
#include<tuple>
#include<algorithm>

using namespace std;

int main(){
	int n;
	cin >> n;
	string str;
	vector<tuple<int, int, int>> arr(n, tuple<int, int, int>(0, 0, 0));
	for(int i=0;i<n;i++){
		cin >> str;
		get<2>(arr[i]) = i + 1;
		for(int j=0;j<str.length();j++){
			if(str[j]=='('){
				get<1>(arr[i]) += 1;
			}else{
				get<1>(arr[i]) -= 1;
			}
			if(get<1>(arr[i]) < get<0>(arr[i])){
				get<0>(arr[i]) = get<1>(arr[i]);
			}
		}
	}
	sort(arr.begin(), arr.end(), greater());
	int sum = 0;
	for(int i=0;i<n;i++){
		if(sum + get<0>(arr[i]) < 0){
			cout << "impossible";
			return 0;
		}
		sum += get<1>(arr[i]);
	}
	if(sum != 0) {
		cout << "impossible";
	}else {
		for(int i=0;i<n;i++){
			cout << get<2>(arr[i]) << endl;
		}
	}
	return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:28:45: error: missing template arguments before ‘(’ token
   28 |         sort(arr.begin(), arr.end(), greater());
      |                                             ^