結果

問題 No.2343 (l+r)/2
コンテスト
ユーザー chro_96
提出日時 2023-06-09 23:09:08
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 813 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 253 ms
コンパイル使用メモリ 38,144 KB
最終ジャッジ日時 2026-02-22 10:45:26
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>

int main () {
  int t = 0;
  int n = 0;
  int a[200000] = {};
  
  int res = 0;
  
  res = scanf("%d", &t);
  while (t > 0) {
    int flag[2] = {};
    res = scanf("%d", &n);
    for (int i = 0; i < n; i++) {
      res = scanf("%d", a+i);
      flag[a[i]] = 1;
    }
    if (flag[0] <= 0 || flag[1] <= 0) {
      printf("No\n");
    } else if (a[0] != a[n-1]) {
      printf("Yes\n");
    } else {
      int is_ok = 0;
      int l = 0;
      int r = n-1;
      while (a[l] == a[0]) {
        l++;
      }
      while (a[r] == a[n-1]) {
        r--;
      }
      for (int i = l; i < r; i++) {
        if (a[i] == a[i+1]) {
          is_ok = 1;
        }
      }
      if (is_ok > 0) {
        printf("Yes\n");
      } else {
        printf("No\n");
      }
    }
    t--;
  }
  
  return 0;
}
0