53502023-04-26 10:42:16kohumarkZárójelekcpp17Wrong answer 14/10027ms6560 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;
	if(a.second.second==b.second.second) return a.second.first-a.second.second > b.second.first-b.second.second;
	return a.second.second < 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));
	}
	sort(t.begin(), t.end(), ren);
	for(auto it=t.begin(); it!=t.end(); it++) cout << (*it).first << ' ';
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1808 KiB
2Accepted8ms2228 KiB
subtask20/11
3Accepted3ms2388 KiB
4Wrong answer3ms2364 KiB
5Wrong answer3ms2524 KiB
6Accepted3ms2776 KiB
7Accepted8ms3372 KiB
8Wrong answer8ms3284 KiB
subtask30/6
9Accepted8ms3332 KiB
10Wrong answer8ms3288 KiB
11Wrong answer8ms3552 KiB
subtask414/14
12Accepted8ms3876 KiB
13Accepted7ms3944 KiB
subtask50/23
14Wrong answer8ms4152 KiB
15Wrong answer8ms3996 KiB
subtask60/19
16Wrong answer8ms3976 KiB
17Wrong answer8ms4100 KiB
18Accepted8ms4464 KiB
19Wrong answer8ms4420 KiB
20Wrong answer8ms4492 KiB
21Wrong answer6ms4464 KiB
22Wrong answer6ms4652 KiB
23Wrong answer6ms4680 KiB
24Wrong answer6ms4680 KiB
subtask70/27
25Wrong answer8ms4620 KiB
26Wrong answer8ms4892 KiB
27Wrong answer8ms5004 KiB
28Wrong answer9ms4976 KiB
29Wrong answer12ms5292 KiB
30Wrong answer27ms6560 KiB
31Wrong answer8ms4944 KiB
32Wrong answer8ms5124 KiB
33Wrong answer8ms4948 KiB
34Wrong answer9ms5008 KiB
35Wrong answer7ms4772 KiB
36Wrong answer9ms5216 KiB
37Wrong answer7ms5116 KiB
38Wrong answer8ms5200 KiB
39Wrong answer16ms6016 KiB
40Wrong answer4ms5020 KiB
41Wrong answer3ms4964 KiB
42Accepted7ms5184 KiB
43Wrong answer6ms5140 KiB