53482023-04-26 10:30:01kohumarkZárójelekcpp17Wrong answer 20/10028ms5992 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 << ' ';
	}
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1812 KiB
2Wrong answer8ms2224 KiB
subtask20/11
3Accepted3ms2388 KiB
4Wrong answer3ms2548 KiB
5Accepted3ms2544 KiB
6Accepted3ms2668 KiB
7Wrong answer8ms3008 KiB
8Accepted8ms3260 KiB
subtask36/6
9Accepted8ms3156 KiB
10Accepted8ms3328 KiB
11Accepted8ms3284 KiB
subtask414/14
12Accepted8ms3352 KiB
13Accepted8ms3664 KiB
subtask50/23
14Wrong answer8ms3732 KiB
15Wrong answer8ms3936 KiB
subtask60/19
16Wrong answer8ms3792 KiB
17Wrong answer8ms3908 KiB
18Wrong answer8ms3900 KiB
19Wrong answer8ms3896 KiB
20Wrong answer8ms4100 KiB
21Wrong answer6ms4116 KiB
22Wrong answer6ms4124 KiB
23Wrong answer6ms4116 KiB
24Wrong answer6ms4152 KiB
subtask70/27
25Wrong answer8ms4216 KiB
26Wrong answer8ms4328 KiB
27Wrong answer9ms4252 KiB
28Wrong answer9ms4300 KiB
29Wrong answer12ms4584 KiB
30Wrong answer28ms5840 KiB
31Wrong answer8ms4224 KiB
32Wrong answer9ms4656 KiB
33Wrong answer8ms4560 KiB
34Wrong answer9ms4752 KiB
35Wrong answer8ms4692 KiB
36Wrong answer9ms4928 KiB
37Wrong answer7ms4768 KiB
38Wrong answer8ms4796 KiB
39Wrong answer14ms5992 KiB
40Wrong answer6ms4956 KiB
41Wrong answer3ms5088 KiB
42Wrong answer7ms5388 KiB
43Wrong answer6ms5072 KiB