hiho week 228 register

Ended

Participants:231

Verdict:Accepted
Score:100 / 100
Submitted:2018-11-11 20:10:24

Lang:Java

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
import java.util.*;
public class Main  {
    static class Node implements Comparable<Node>{
        int s;
        int e;
        Node(int sint e){
            this.s = s;
            this.e = e;
        }
        public int compareTo(Node o) {
            return  (s < o.s) ? -1 : 1;
        }
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Stack<Integer> st = new Stack();
        ArrayList<Node> arr = new ArrayList();
        for(int i = 0i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == '(') {
                st.push(i + 1);
            } else {
                int t = st.pop();
                arr.add(new Node(ti + 1));
            }
        }
        Collections.sort(arr);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX