QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#97575#5615. Two Charts Become OneNicolas125841Compile Error//Java111.4kb2023-04-17 11:14:282023-04-17 11:14:30

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-17 11:14:30]
  • 评测
  • [2023-04-17 11:14:28]
  • 提交

answer

import java.io.*;
import java.util.*;

public class tcbo {

	public static void main(String args[]) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		
		HashMap<Integer, TreeSet<Integer>> a = createTree(br);
		HashMap<Integer, TreeSet<Integer>> b = createTree(br);
		
		//System.out.println(a);
		//System.out.println(b);
		
		if(a.equals(b))
			pw.println("Yes");
		else
			pw.println("No");
		
		pw.close();
	}
	
	static HashMap<Integer, TreeSet<Integer>> createTree(BufferedReader br) throws IOException{
		Stack<Integer> stack = new Stack<Integer>();		
		HashMap<Integer, TreeSet<Integer>> tree = new HashMap<>();
		
		String[] line = br.readLine().split(" ");
		
		Queue<Character> clist = new LinkedList<Character>();
				
		for(String s : line)
			s.chars().forEach(c -> clist.add((char) c));		
				
		while(!clist.isEmpty()) {
			if(Character.isDigit(clist.peek())) {
				int num = clist.poll()-'0';
				
				while(!clist.isEmpty() && .isDigit(clist.peek())) {
					num *= 10;
					num += clist.poll()-'0';
				}
				
				if(!stack.isEmpty()) {
					tree.putIfAbsent(stack.peek(), new TreeSet<Integer>());
					tree.get(stack.peek()).add(num);
				}
				
				stack.push(num);
			}else {
				if(clist.poll().charValue() == ')')
					stack.pop();
			}
		}
		
		return tree;
	}
}

Details

tcbo.java:41: error: illegal start of expression
				while(!clist.isEmpty() && .isDigit(clist.peek())) {
				                          ^
tcbo.java:41: error: ';' expected
				while(!clist.isEmpty() && .isDigit(clist.peek())) {
				                                                ^
2 errors