53152023-04-25 20:12:17rmlanZárójelekcpp14Wrong answer 0/10014ms6236 KiB
#include<bits/stdc++.h>
using namespace std;

struct z{
    int b=0,r=0,id;
};
bool comp(z a, z b){
    return a.r < b.r;
}
bool comp2(z a, z b){
    return a.r > b.r;
}

int main(){
    int n;
    cin >> n;
    vector<z> pos,neg;
    for(int i = 1; i <= n; i++){
        string s;
        cin >> s;
        z c;
        c.id = i;
        for(int j = 0; j < s.length(); j++){
            if(s[j]=='('){
                c.b++;
            }else{
                c.b--;
            }
            c.r = min(c.r, c.b);
        }
        c.r = abs(c.r);
        if(c.b >= 0){
            pos.push_back(c);
        }else{
            neg.push_back(c);
        }

    }
    cout << -1;
    return 0;
    sort(pos.begin(), pos.end(), comp);
    sort(neg.begin(), neg.end(), comp2);
    int b=0;
    vector<int> ans;
    for(z i:pos){
        if(i.r > b){
            cout << -1;
            return 0;
        }
        ans.push_back(i.id);
        b+=i.b;
    }
    for(z i:neg){
        if(i.r > b || b < 0){
            cout << -1;
            return 0;
        }
        ans.push_back(i.id);
        b+=i.b;
    }
    if(b != 0){
        cout << "-1";
        return 0;

    }
    for(int i:ans){
        cout << i << " ";
    }

}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1812 KiB
2Wrong answer8ms2232 KiB
subtask20/11
3Wrong answer3ms2328 KiB
4Wrong answer3ms2428 KiB
5Wrong answer3ms2536 KiB
6Wrong answer3ms2736 KiB
7Wrong answer7ms3072 KiB
8Accepted8ms3332 KiB
subtask30/6
9Wrong answer8ms3272 KiB
10Accepted8ms3532 KiB
11Accepted8ms3764 KiB
subtask40/14
12Wrong answer8ms3744 KiB
13Wrong answer8ms3724 KiB
subtask50/23
14Wrong answer8ms4072 KiB
15Wrong answer8ms4012 KiB
subtask60/19
16Wrong answer7ms4072 KiB
17Wrong answer8ms4212 KiB
18Wrong answer8ms4240 KiB
19Wrong answer8ms4148 KiB
20Wrong answer8ms4152 KiB
21Wrong answer6ms4448 KiB
22Wrong answer6ms4404 KiB
23Wrong answer6ms4408 KiB
24Wrong answer6ms4444 KiB
subtask70/27
25Accepted7ms4412 KiB
26Wrong answer8ms4396 KiB
27Wrong answer8ms4644 KiB
28Wrong answer8ms4616 KiB
29Wrong answer8ms4828 KiB
30Wrong answer14ms6236 KiB
31Wrong answer8ms4744 KiB
32Wrong answer8ms4892 KiB
33Wrong answer8ms5044 KiB
34Wrong answer8ms5196 KiB
35Wrong answer8ms4976 KiB
36Wrong answer8ms5196 KiB
37Accepted8ms4976 KiB
38Wrong answer8ms5068 KiB
39Wrong answer10ms5752 KiB
40Wrong answer4ms5016 KiB
41Wrong answer3ms4964 KiB
42Wrong answer7ms5184 KiB
43Wrong answer6ms5156 KiB