QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#214856#5108. Prehistoric ProgramsderetoWA 13ms3960kbC++14873b2023-10-15 00:35:222023-10-15 00:35:23

Judging History

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

  • [2023-10-15 00:35:23]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:3960kb
  • [2023-10-15 00:35:22]
  • 提交

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<tuple<int, int, int>>());
	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";
		return 0;
	}
	for(int i=0;i<n;i++){
		cout << get<2>(arr[i]) << endl;
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 13ms
memory: 3960kb

input:

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

output:

impossible

result:

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