結果
問題 | No.2343 (l+r)/2 |
ユーザー | Paras Yadav |
提出日時 | 2023-06-09 21:08:24 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,796 bytes |
コンパイル時間 | 2,047 ms |
コンパイル使用メモリ | 79,016 KB |
実行使用メモリ | 47,136 KB |
最終ジャッジ日時 | 2024-06-10 12:39:41 |
合計ジャッジ時間 | 3,993 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 199 ms
47,136 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 60 ms
37,740 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 50 ms
36,948 KB |
testcase_11 | AC | 65 ms
38,520 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 73 ms
38,632 KB |
ソースコード
/* _ _ | (_) _ __ __ _ _ __ __ _ ___ ___ ___ __| |_ _ __ __ _ | '_ \ / _` | '__/ _` / __|/ __/ _ \ / _` | | '_ \ / _` | | |_) | (_| | | | (_| \__ \ (_| (_) | (_| | | | | | (_| | | .__/ \__,_|_| \__,_|___/\___\___/ \__,_|_|_| |_|\__, | | | __/ | |_| |___/ */ 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(); } }