QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#97576 | #5615. Two Charts Become One | Nicolas125841 | WA | 663ms | 102752kb | Java11 | 1.5kb | 2023-04-17 11:15:07 | 2023-04-17 11:15:09 |
Judging History
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;
}
}
详细
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'