hiho week 228 register

Ended

Participants:231

Verdict:Accepted
Score:100 / 100
Submitted:2018-11-10 23:42:38

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
24
25
26
27
28
29
30
31
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int MAXN=1e5+10;
char str[MAXN];
int l[MAXN],lcnt;
int r[MAXN];
int main(){
    cin.sync_with_stdio(false);
    scanf("%s", 1+str);
    lcnt=0;
    memset(r,-1,sizeof(r));
    for(int i=1;str[i];i++){
        if(str[i]=='('){
            l[lcnt++]=i;
        }else{
            r[l[--lcnt]]=i;
        }
    }
    for(int i=1;str[i];i++){
        if(-1!=r[i]){
            printf("%d %d\n",i,r[i]);
        }
    }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX