53552023-04-26 11:16:36kohumarkZárójelekcpp17Wrong answer 14/10028ms6492 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>0&&b.second.first-b.second.second>0){ 
		if(a.second.second == b.second.second) return a.second.first > b.second.first;
		return a.second.second < b.second.second;
	}
	else if(a.second.first-a.second.second<0&&b.second.first-b.second.second<0){
		if(a.second.second == b.second.second) return a.second.first > b.second.first;
		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;
	vector<pair<int,pair<int,int>>> t;
	for(int i=0; i<n; i++){
		string x; cin >> x;
		pair<int,int> act;
		for(int j=0; j<(int)x.length(); j++){
			if(x[j]=='(') act.first++;
			else{
				if(act.first>0) act.first--;
				else{
					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
1Accepted3ms1812 KiB
2Accepted8ms2176 KiB
subtask20/11
3Accepted3ms2084 KiB
4Wrong answer3ms2212 KiB
5Wrong answer3ms2428 KiB
6Accepted3ms2508 KiB
7Accepted8ms3016 KiB
8Wrong answer8ms2976 KiB
subtask30/6
9Accepted8ms3020 KiB
10Wrong answer8ms3236 KiB
11Wrong answer8ms3448 KiB
subtask414/14
12Accepted8ms3404 KiB
13Accepted8ms3476 KiB
subtask50/23
14Wrong answer8ms3732 KiB
15Wrong answer8ms3940 KiB
subtask60/19
16Wrong answer8ms3808 KiB
17Wrong answer8ms3928 KiB
18Accepted8ms4044 KiB
19Wrong answer8ms4296 KiB
20Wrong answer8ms4420 KiB
21Accepted7ms4828 KiB
22Accepted6ms4920 KiB
23Accepted7ms4876 KiB
24Accepted7ms5004 KiB
subtask70/27
25Wrong answer8ms4804 KiB
26Wrong answer8ms4848 KiB
27Wrong answer9ms4864 KiB
28Wrong answer9ms4872 KiB
29Wrong answer13ms5376 KiB
30Wrong answer28ms6492 KiB
31Wrong answer8ms4868 KiB
32Wrong answer9ms5188 KiB
33Wrong answer8ms4864 KiB
34Wrong answer9ms5040 KiB
35Wrong answer8ms4796 KiB
36Wrong answer10ms5044 KiB
37Wrong answer8ms4880 KiB
38Wrong answer8ms4888 KiB
39Wrong answer16ms5756 KiB
40Accepted6ms4920 KiB
41Accepted4ms4992 KiB
42Accepted7ms5316 KiB
43Accepted6ms5068 KiB