hiho week 228 register

Ended

Participants:231

Verdict:Accepted
Score:100 / 100
Submitted:2018-11-17 12:28:09

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<stack>
#include<stdio.h>
#include<string.h>
using namespace std;
char str[100001];
int res[100001] = { 0 };
int main()
{
    int max = 0;
    scanf("%s", str);
    stack<int>s;
    int len = strlen(str);
    for (int i = 0; i < len; ++i)
    {
        if (str[i] == '(')
        {
            s.push(i + 1);
            max = i + 1;
        }
        else if (!s.empty())
        {
            res[s.top()] = i + 1;
            s.pop();
        }
    }
    for (int i = 1; i <= max  ; ++i)
    {
        if(res[i]!=0)
            printf("%d %d\n", i, res[i]);
    }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX