QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214961#5108. Prehistoric ProgramsderetoWA 14ms3860kbC++14900b2023-10-15 01:47:132023-10-15 01:47:14

Judging History

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

  • [2023-10-15 01:47:14]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:3860kb
  • [2023-10-15 01:47:13]
  • 提交

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;
			}
			get<0>(arr[i]) = std::min(get<0>(arr[i]), get<1>(arr[i]));
		}
		get<1>(arr[i]) += get<0>(arr[i]);
	}
	sort(arr.begin(), arr.end(), greater<tuple<int, int, int>>());
	int sum = 0;
	int min = 0;
	for(int i=0;i<n;i++){
		min = std::min(min, sum + get<0>(arr[i]));
		sum += get<1>(arr[i]) - get<0>(arr[i]);
	}
	if(sum != 0 || min < 0) {
		cout << "impossible";
		return 0;
	}
	for(int i=0;i<n;i++){
		cout << get<2>(arr[i]) << '\n';
	}
	
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 14ms
memory: 3860kb

input:

50000
(
(
))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()(
)
(
)
(((
(
(
(
(
(
()
(
)
(
)((())()((
)))))(
(
)
))
)()
(
)
)
)()(
(
(
()
(
)
(
)()((((())()))())(
(
(
)(
(
(
(()())())
)
)
(
(
(
)((())))((())))))))))((((()()))()))))))))((()())()))
)
)()
)
)
)
)
)
())(())))))()(()((()(())...

output:

impossible

result:

wrong answer you didn't find a solution but jury did