結果
| 問題 |
No.2343 (l+r)/2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-09 21:08:24 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 5,796 bytes |
| コンパイル時間 | 2,628 ms |
| コンパイル使用メモリ | 81,540 KB |
| 実行使用メモリ | 59,884 KB |
| 最終ジャッジ日時 | 2025-01-02 01:49:54 |
| 合計ジャッジ時間 | 4,525 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 5 WA * 9 |
ソースコード
/*
_ _
| (_)
_ __ __ _ _ __ __ _ ___ ___ ___ __| |_ _ __ __ _
| '_ \ / _` | '__/ _` / __|/ __/ _ \ / _` | | '_ \ / _` |
| |_) | (_| | | | (_| \__ \ (_| (_) | (_| | | | | | (_| |
| .__/ \__,_|_| \__,_|___/\___\___/ \__,_|_|_| |_|\__, |
| | __/ |
|_| |___/
*/
import java.lang.*;
import java.math.*;
import java.io.*;
import java.util.*;
public class Main{
public static Reader br;
public static PrintWriter ot;
public static int[] take_arr(int n) throws IOException{
int a[] = new int[n];
for(int i = 0; i < n; i++)
a[i] = br.nextInt();
return a;
}
public static List<Integer> take_list(int n) throws IOException{
List<Integer> a = new ArrayList<>();
for(int i = 0; i < n; i++)
a.add(br.nextInt());
return a;
}
public static void main (String[] args) throws IOException {
br = new Reader();
ot = new PrintWriter(System.out);
int t = br.nextInt();
pre();
while(t-- > 0){
int n = br.nextInt();
// int m = br.nextInt();
// int k = br.nextInt();
solve(n);
}
ot.close();
br.close();
}
static void solve() throws IOException{
}
static void solve(int n) throws IOException{
int a[] = take_arr(n);
List<Integer> list = new ArrayList<>();
int i = 0;
while(i < n){
int j = i;
while(j < n && a[i] == a[j])
j++;
list.add(a[i]);
i = j;
}
if(list.size() % 2 == 1){
ot.println("No");
return;
}
boolean ans = false, temp = true;
int ele = 1;
for(int x : list){
if(x != ele){
temp = false;
break;
}
ele ^= 1;
}
ans |= temp;
temp = true;
ele = 0;
for(int x : list){
if(x != ele){
temp = false;
break;
}
ele ^= 1;
}
ans |= temp;
if(ans)
ot.println("Yes");
else
ot.println("No");
}
static void solve(int n, int m) throws IOException{
}
static List<List<Integer>> adj;
static long mod = (long)(1e9 + 7);
static void pre() throws IOException {
}
// Template Functions
static long exp(long a, long b, long mod){
long ans = 1;
while(b > 0){
if((b & 1) == 1)
ans = (ans * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return ans;
}
}
class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader()
{
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public Reader(String file_name) throws IOException
{
din = new DataInputStream(
new FileInputStream(file_name));
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public String readLine() throws IOException
{
byte[] buf = new byte[(int)(1e5 + 1)]; // line length
int cnt = 0, c;
while ((c = read()) != -1) {
if (c == '\n') {
if (cnt != 0) {
break;
}
else {
continue;
}
}
buf[cnt++] = (byte)c;
}
return new String(buf, 0, cnt);
}
public int nextInt() throws IOException
{
int ret = 0;
byte c = read();
while (c <= ' ') {
c = read();
}
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public long nextLong() throws IOException
{
long ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public double nextDouble() throws IOException
{
double ret = 0, div = 1;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (c == '.') {
while ((c = read()) >= '0' && c <= '9') {
ret += (c - '0') / (div *= 10);
}
}
if (neg)
return -ret;
return ret;
}
private void fillBuffer() throws IOException
{
bytesRead = din.read(buffer, bufferPointer = 0,
BUFFER_SIZE);
if (bytesRead == -1)
buffer[0] = -1;
}
private byte read() throws IOException
{
if (bufferPointer == bytesRead)
fillBuffer();
return buffer[bufferPointer++];
}
public void close() throws IOException
{
if (din == null)
return;
din.close();
}
}