每个测试文件均包含多组测试数据。第一行输入一个整数
代表数据组数,每组测试数据描述如下:
在一行上输入四个整数
代表小红的括号序列。
对于每组数据,如果能够将这些括号串连成一个合法的括号序列,在一行上输出
,否则输出
。
2 1 1 1 1 1 2 1 1
YES NO
对于第一组测试数据,可以按照如下顺序拼接 "
" + "
" + "
" + "
" ,填入内容后可以表示为
,这是一个合法的括号序列。
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
String [] ans = new String [t];
for (int i = 0 ; i < t ; i++) {
long a = in.nextLong(), b = in.nextLong(),
c = in.nextLong(), d = in.nextLong();
if (a == b) {
if (a > 0) {
ans[i] = "YES";
} else {
ans[i] = d == 0 ? "YES" : "NO";
}
} else ans[i] = "NO";
}
for (String a : ans) {
System.out.println(a);
}
in.close();
}
}