2020CCPC网络选拔赛 1010 Reports
程序员文章站
2022-06-09 17:42:45
...
1010 Reports
题目大意:
给定一个0/1的整数数列,如果序列中存在相邻数字相同,输出YES,否则输出NO
Java代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
int t = read.nextInt();
while (t-- > 0) {
int p = read.nextInt();
int n = 0;
int first = read.nextInt();
while (--p > 0) {
int second = read.nextInt();
if (first == 1 && second == 1 || first == 0 && second == 0) {
n++;
}
first = second;
}
if (n == 0) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
read.close();
}
}