hiho week 228 register

Ended

Participants:231

Verdict:Accepted
Score:100 / 100
Submitted:2018-11-10 23:18:43

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
#include<bits/stdc++.h>
int N;
int L;
char s[100010];
int pe[50010][2];
int stack[50010];
int main()
{
    int i,j,k;
    scanf("%s",&s[1]);
    L=strlen(&s[1]);
    N=L/2;
    j=k=0;
    for(i=1;i<=L;i++)
    {
        if(s[i]=='('){
            pe[++k][0]=i;
            stack[++j]=k;
        }else{
            pe[stack[j--]][1]=i;
        }
    }
    for(i=1;i<=N;i++)printf("%d %d\n",pe[i][0],pe[i][1]);
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX