QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#176629#5108. Prehistoric ProgramspanzyWA 7ms5912kbC++14842b2023-09-11 20:38:012023-09-11 20:38:03

Judging History

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

  • [2023-09-11 20:38:03]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:5912kb
  • [2023-09-11 20:38:01]
  • 提交

answer

// Author:  panzy    	
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
struct node{
	string s;
	int k,i;
	bool operator<(const node &r)const{
		return k < r.k;
	}
};
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(15);
	int n;cin >> n;
	vector<node>a(n);
	for(int i = 1; i <= n; i ++){
		string s;cin >> s;
		int k = 0;
		for(auto c : s){
			if(c == '(') k --;
			else k ++;
		}
		a[i-1] = {s,k,i};
	}
	sort(a.begin(), a.end());
	int res = 0;
	for(int i = 0; i < n; i ++){
		for(auto c : a[i].s){
			if(c == '(') res --;
			else res ++;
			if(res > 0){
				cout << "impossible\n";
				exit(0);
			}
		}
	}
	if(res != 0)	cout << "impossible\n";
	else{
		for(int i = 0; i < n; i ++){
			cout << a[i].i << '\n';
		}
	}
	return 0;
}


詳細信息

Test #1:

score: 0
Wrong Answer
time: 7ms
memory: 5912kb

input:

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

output:

impossible

result:

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