53492023-04-26 10:35:04kohumarkZárójelekcpp17Wrong answer 20/10028ms6200 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-a.second.second==b.second.first-b.second.second) return a.second.second < b.second.second;
	return a.second.first-a.second.second > b.second.first-b.second.second;
}

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 answer8ms2228 KiB
subtask20/11
3Accepted3ms2396 KiB
4Wrong answer3ms2508 KiB
5Wrong answer3ms2760 KiB
6Accepted3ms2932 KiB
7Accepted8ms3344 KiB
8Accepted8ms3320 KiB
subtask36/6
9Accepted8ms3400 KiB
10Accepted8ms3568 KiB
11Accepted7ms3376 KiB
subtask414/14
12Accepted8ms3372 KiB
13Accepted8ms3632 KiB
subtask50/23
14Wrong answer8ms3712 KiB
15Wrong answer8ms4008 KiB
subtask60/19
16Wrong answer8ms3956 KiB
17Wrong answer8ms4048 KiB
18Wrong answer8ms4136 KiB
19Wrong answer8ms3940 KiB
20Wrong answer8ms3940 KiB
21Wrong answer6ms3984 KiB
22Wrong answer6ms3988 KiB
23Wrong answer6ms4240 KiB
24Wrong answer6ms4448 KiB
subtask70/27
25Wrong answer8ms4336 KiB
26Wrong answer8ms4448 KiB
27Wrong answer9ms4488 KiB
28Wrong answer9ms4396 KiB
29Accepted13ms4756 KiB
30Wrong answer28ms6200 KiB
31Wrong answer8ms4664 KiB
32Wrong answer8ms4828 KiB
33Wrong answer8ms4656 KiB
34Wrong answer9ms4864 KiB
35Wrong answer8ms4624 KiB
36Wrong answer9ms5116 KiB
37Wrong answer7ms4856 KiB
38Wrong answer8ms4884 KiB
39Wrong answer14ms5676 KiB
40Wrong answer4ms4924 KiB
41Wrong answer4ms5004 KiB
42Wrong answer7ms5312 KiB
43Wrong answer6ms5148 KiB