QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#97576#5615. Two Charts Become OneNicolas125841WA 663ms102752kbJava111.5kb2023-04-17 11:15:072023-04-17 11:15:09

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:15:09]
  • 评测
  • 测评结果:WA
  • 用时:663ms
  • 内存:102752kb
  • [2023-04-17 11:15:07]
  • 提交

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() && Character.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

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 58ms
memory: 52428kb

input:

11 (10) (12 (13) (17) (28))
11 (12 (17) (28) (13)) (10)

output:

Yes

result:

ok single line: 'Yes'

Test #2:

score: 0
Accepted
time: 59ms
memory: 52252kb

input:

11 ( 10 ) ( 12 )
11(10(12))

output:

No

result:

ok single line: 'No'

Test #3:

score: 0
Accepted
time: 66ms
memory: 52488kb

input:

11 (10) (12)
11 (10) (13)

output:

No

result:

ok single line: 'No'

Test #4:

score: 0
Accepted
time: 663ms
memory: 102752kb

input:

289384 (694459 (751708 (887544 (519034 (207488 (373389 ) (912072 ) (191461 ) (91909 ) (5562 ) (705802 ) (469815 ) (726477 ) ) (204098 (530445 ) (655063 ) (156343 ) (980456 ) (186944 ) (198850 ) ) ) (502461 (427161 (615081 ) (801892 ) (594639 ) (786804 ) (811554 ) (810699 ) (935475 ) (717636 ) ) (537...

output:

No

result:

ok single line: 'No'

Test #5:

score: 0
Accepted
time: 455ms
memory: 79984kb

input:

289384 (694459 (751708 (887544 (519034 (207488 (373389 (912072 (191461 (91909 ) (5562 ) ) (705802 (469815 ) (726477 ) (204098 ) (530445 ) (655063 ) ) ) (156343 (980456 (186944 ) (198850 ) ) (502461 (427161 ) (615081 ) (801892 ) (594639 ) (786804 ) ) (811554 (810699 ) (935475 ) (717636 ) (537132 ) ) ...

output:

Yes

result:

ok single line: 'Yes'

Test #6:

score: 0
Accepted
time: 387ms
memory: 74436kb

input:

289384 (694459 (751708 (887544 (519034 (207488 (373389 (912072 (191461 (91909 ) (5562 ) ) (705802 (469815 ) (726477 ) (204098 ) (530445 ) (655063 ) ) ) (156343 (980456 (186944 ) (198850 ) ) (502461 (427161 ) (615081 ) (801892 ) (594639 ) (786804 ) ) (811554 (810699 ) (935475 ) (717636 ) (537132 ) ) ...

output:

No

result:

ok single line: 'No'

Test #7:

score: 0
Accepted
time: 424ms
memory: 76316kb

input:

289384 (694459 (751708 (887544 (519034 (207488 (373389 (912072 (191461 (91909 (5562 ) ) (705802 (469815 ) (726477 ) ) (204098 (530445 ) (655063 ) (156343 ) (980456 ) ) ) (186944 (198850 (502461 ) (427161 ) ) (615081 (801892 ) ) (594639 (786804 ) (811554 ) (810699 ) ) ) (935475 (717636 (537132 ) (678...

output:

Yes

result:

ok single line: 'Yes'

Test #8:

score: 0
Accepted
time: 431ms
memory: 81948kb

input:

289384 (694459 (751708 (887544 (519034 (207488 (373389 (912072 (191461 (91909 (5562 ) ) (705802 (469815 ) (726477 ) ) (204098 (530445 ) (655063 ) (156343 ) (980456 ) ) ) (186944 (198850 (502461 ) (427161 ) ) (615081 (801892 ) ) (594639 (786804 ) (811554 ) (810699 ) ) ) (935475 (717636 (537132 ) (678...

output:

No

result:

ok single line: 'No'

Test #9:

score: 0
Accepted
time: 375ms
memory: 70924kb

input:

289384 (694459 (751708 (887544 (519034 (207488 (373389 (912072 (191461 (91909 (5562 (705802 (469815 (726477 (204098 (530445 (655063 (156343 (980456 (186944 (198850 ) ) ) (502461 (427161 (615081 ) (801892 ) ) (594639 (786804 ) ) ) ) ) ) (811554 (810699 (935475 (717636 (537132 (678641 ) (777412 ) ) (6...

output:

Yes

result:

ok single line: 'Yes'

Test #10:

score: 0
Accepted
time: 378ms
memory: 70576kb

input:

289384 (694459 (751708 (887544 (519034 (207488 (373389 (912072 (191461 (91909 (5562 (705802 (469815 (726477 (204098 (530445 (655063 (156343 (980456 (186944 (198850 ) ) ) (502461 (427161 (615081 ) (801892 ) ) (594639 (786804 ) ) ) ) ) ) (811554 (810699 (935475 (717636 (537132 (678641 ) (777412 ) ) (6...

output:

No

result:

ok single line: 'No'

Test #11:

score: 0
Accepted
time: 63ms
memory: 52640kb

input:

10
10

output:

Yes

result:

ok single line: 'Yes'

Test #12:

score: -100
Wrong Answer
time: 66ms
memory: 50636kb

input:

10
1

output:

Yes

result:

wrong answer 1st lines differ - expected: 'No', found: 'Yes'