zaobei @ 2023-12-16 15:42:06
import java.util.*;
import static java.lang.Math.pow;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
Stack<Integer> stack=new Stack<>();
int n=scan.nextInt();
for(int i=0;i<n;i++){
int z=0;
int k=scan.nextInt();
for(int j=0;j<k;j++){
stack.push(scan.nextInt());
}
for(int j=0;j<k;j++){
int y=scan.nextInt();
if(y!=stack.pop()){
z=1;
}
}
if(z==0)System.out.println("Yes");
else System.out.println("No");
stack.clear();
}
}
}
by code953 @ 2023-12-16 16:12:55
@zaobei 你是不是没处理多组询问
by 编码落寞 @ 2023-12-16 16:30:32
@zaobei
你这判断是全进全出。有可能中间出的情况
by zaobei @ 2023-12-16 16:40:49
感谢