98852024-03-14 22:39:55BakosCsongorZárójel cserecpp17Wrong answer 0/1001.1s8552 KiB
/*
4
)()(
*/
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int N;
    vector <char> zarojel;
    vector <int> sorszam;
    //ifstream cin("input0.txt");
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        char c;
        cin >> c;
        zarojel.push_back(c);
        sorszam.push_back(i);

    }
    for(int k = 0; k < N; k++){
        for(int j = 1; j < zarojel.size(); j++)
        {
            if(zarojel.at(j-1) == '(' and zarojel.at(j) == ')')
            {
                zarojel.erase(zarojel.begin()+j-1,zarojel.begin()+j+1);
                sorszam.erase(sorszam.begin()+j-1,sorszam.begin()+j+1);
            }
        }
    }
    cout << zarojel.size()/2 << endl;
    if(zarojel.size() != 0)
    {
        for(int i = 0; i < zarojel.size()/2; i++)
        {
            char a = zarojel.at(i);
            for(int j = 0; j < zarojel.size(); j++)
            {
                char b = zarojel.at(j);
                if(a != b)
                {
                    cout << sorszam.at(i) << " " << sorszam.at(j) << endl;
                    break;
                }
            }
        }
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1812 KiB
2Wrong answer3ms2004 KiB
3Accepted3ms2216 KiB
subtask20/33
4Wrong answer3ms2476 KiB
5Accepted2ms2492 KiB
6Wrong answer2ms2492 KiB
subtask30/44
7Wrong answer3ms2504 KiB
8Wrong answer9ms2556 KiB
9Wrong answer3ms2772 KiB
10Wrong answer3ms3144 KiB
11Wrong answer4ms3100 KiB
12Wrong answer3ms3096 KiB
subtask40/23
13Time limit exceeded1.1s5136 KiB
14Time limit exceeded1.044s5352 KiB
15Time limit exceeded1.047s5476 KiB
16Time limit exceeded1.042s8160 KiB
17Time limit exceeded1.078s8160 KiB
18Time limit exceeded1.077s8356 KiB
19Time limit exceeded1.07s8192 KiB
20Time limit exceeded1.057s8180 KiB
21Time limit exceeded1.072s8452 KiB
22Time limit exceeded1.072s8436 KiB
23Time limit exceeded1.044s8544 KiB
24Time limit exceeded1.075s8552 KiB