5355 2023. 04. 26 11:16:36 kohumark Zárójelek cpp17 Wrong answer 14/100 28ms 6492 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 << ' ';
}
Subtask Sum Test Verdict Time Memory
subtask1 0/0
1 Accepted 3ms 1812 KiB
2 Accepted 8ms 2176 KiB
subtask2 0/11
3 Accepted 3ms 2084 KiB
4 Wrong answer 3ms 2212 KiB
5 Wrong answer 3ms 2428 KiB
6 Accepted 3ms 2508 KiB
7 Accepted 8ms 3016 KiB
8 Wrong answer 8ms 2976 KiB
subtask3 0/6
9 Accepted 8ms 3020 KiB
10 Wrong answer 8ms 3236 KiB
11 Wrong answer 8ms 3448 KiB
subtask4 14/14
12 Accepted 8ms 3404 KiB
13 Accepted 8ms 3476 KiB
subtask5 0/23
14 Wrong answer 8ms 3732 KiB
15 Wrong answer 8ms 3940 KiB
subtask6 0/19
16 Wrong answer 8ms 3808 KiB
17 Wrong answer 8ms 3928 KiB
18 Accepted 8ms 4044 KiB
19 Wrong answer 8ms 4296 KiB
20 Wrong answer 8ms 4420 KiB
21 Accepted 7ms 4828 KiB
22 Accepted 6ms 4920 KiB
23 Accepted 7ms 4876 KiB
24 Accepted 7ms 5004 KiB
subtask7 0/27
25 Wrong answer 8ms 4804 KiB
26 Wrong answer 8ms 4848 KiB
27 Wrong answer 9ms 4864 KiB
28 Wrong answer 9ms 4872 KiB
29 Wrong answer 13ms 5376 KiB
30 Wrong answer 28ms 6492 KiB
31 Wrong answer 8ms 4868 KiB
32 Wrong answer 9ms 5188 KiB
33 Wrong answer 8ms 4864 KiB
34 Wrong answer 9ms 5040 KiB
35 Wrong answer 8ms 4796 KiB
36 Wrong answer 10ms 5044 KiB
37 Wrong answer 8ms 4880 KiB
38 Wrong answer 8ms 4888 KiB
39 Wrong answer 16ms 5756 KiB
40 Accepted 6ms 4920 KiB
41 Accepted 4ms 4992 KiB
42 Accepted 7ms 5316 KiB
43 Accepted 6ms 5068 KiB