結果

問題 No.2343 (l+r)/2
ユーザー ytqm3ytqm3
提出日時 2023-06-02 13:35:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 324 ms / 2,000 ms
コード長 518 bytes
コンパイル時間 1,839 ms
コンパイル使用メモリ 200,024 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 07:49:25
合計ジャッジ時間 3,679 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 324 ms
4,380 KB
testcase_02 AC 5 ms
4,376 KB
testcase_03 AC 56 ms
4,376 KB
testcase_04 AC 13 ms
4,376 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 6 ms
4,380 KB
testcase_07 AC 14 ms
4,376 KB
testcase_08 AC 19 ms
4,376 KB
testcase_09 AC 14 ms
4,376 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 16 ms
4,380 KB
testcase_12 AC 13 ms
4,380 KB
testcase_13 AC 9 ms
4,380 KB
testcase_14 AC 20 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

void solve(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;++i){ cin>>A[i]; }
  if(A[0]!=A[N-1]){
    cout<<"Yes"<<endl;
    return;
  }
  if(A[0]==1 && A[N-1]==1){
    for(int i=0;i<N;++i){
      A[i]=1-A[i];
    }
  }
  for(int i=0;i<N-1;++i){
    if(A[i]==1 && A[i+1]==1){
      cout<<"Yes"<<endl;
      return;
    }
  }
  int C=count(A.begin(),A.end(),1);
  cout<<(C>=4?"Yes":"No")<<endl;
}

int main(){
  int T;
  cin>>T;
  while(T--){
    solve();
  }
}
0