hiho week 228 register

Ended

Participants:231

Verdict:Accepted
Score:100 / 100
Submitted:2018-11-12 14:32:50

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <vector>
#include <map>
#include <string>
using namespace std;
int main()
{
    string s;
    cin>>s;
    vector<int> stk;
    map<int, int> out;
    for(int i=0; i<s.size(); ++i){
        if(s[i] == '(') stk.push_back(i);
        else {
            out[stk.back()+1] = i +1;
            stk.pop_back();
        }
    }
    for(auto p : out){
        cout<<p.first<<' '<<p.second<<endl;
    }
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX