5348 2023. 04. 26 10:30:01 kohumark Zárójelek cpp17 Wrong answer 20/100 28ms 5992 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool ren(pair<int,pair<int,int>> a, pair<int,pair<int,int>> b){
	if(a.second.first==b.second.first) return a.second.second < b.second.second;
	return a.second.first > b.second.first;
}

int main(){
	int n; cin >> n; bool y=false; int s=0;
	vector<pair<int,pair<int,int>>> t;
	for(int i=0; i<n; i++){
		string x; cin >> x;
		pair<int,int> act;
		bool ok=true;
		for(int j=0; j<(int)x.length(); j++){
			if(x[j]=='(') act.first++;
			else{
				if(act.first>0) act.first--;
				else{
					act.second++;
					ok=false;
				}
			}
		}
		y|=ok; s+=act.first-act.second;
		t.push_back(make_pair(i+1,act));
	}
	if(s!=0||!y) cout << -1;
	else{
		sort(t.begin(), t.end(), ren);
		for(auto it=t.begin(); it!=t.end(); it++) cout << (*it).first << ' ';
	}
}
Subtask Sum Test Verdict Time Memory
subtask1 0/0
1 Accepted 3ms 1812 KiB
2 Wrong answer 8ms 2224 KiB
subtask2 0/11
3 Accepted 3ms 2388 KiB
4 Wrong answer 3ms 2548 KiB
5 Accepted 3ms 2544 KiB
6 Accepted 3ms 2668 KiB
7 Wrong answer 8ms 3008 KiB
8 Accepted 8ms 3260 KiB
subtask3 6/6
9 Accepted 8ms 3156 KiB
10 Accepted 8ms 3328 KiB
11 Accepted 8ms 3284 KiB
subtask4 14/14
12 Accepted 8ms 3352 KiB
13 Accepted 8ms 3664 KiB
subtask5 0/23
14 Wrong answer 8ms 3732 KiB
15 Wrong answer 8ms 3936 KiB
subtask6 0/19
16 Wrong answer 8ms 3792 KiB
17 Wrong answer 8ms 3908 KiB
18 Wrong answer 8ms 3900 KiB
19 Wrong answer 8ms 3896 KiB
20 Wrong answer 8ms 4100 KiB
21 Wrong answer 6ms 4116 KiB
22 Wrong answer 6ms 4124 KiB
23 Wrong answer 6ms 4116 KiB
24 Wrong answer 6ms 4152 KiB
subtask7 0/27
25 Wrong answer 8ms 4216 KiB
26 Wrong answer 8ms 4328 KiB
27 Wrong answer 9ms 4252 KiB
28 Wrong answer 9ms 4300 KiB
29 Wrong answer 12ms 4584 KiB
30 Wrong answer 28ms 5840 KiB
31 Wrong answer 8ms 4224 KiB
32 Wrong answer 9ms 4656 KiB
33 Wrong answer 8ms 4560 KiB
34 Wrong answer 9ms 4752 KiB
35 Wrong answer 8ms 4692 KiB
36 Wrong answer 9ms 4928 KiB
37 Wrong answer 7ms 4768 KiB
38 Wrong answer 8ms 4796 KiB
39 Wrong answer 14ms 5992 KiB
40 Wrong answer 6ms 4956 KiB
41 Wrong answer 3ms 5088 KiB
42 Wrong answer 7ms 5388 KiB
43 Wrong answer 6ms 5072 KiB