結果
| 問題 | No.2343 (l+r)/2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-03 13:30:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 57 ms / 2,000 ms |
| コード長 | 527 bytes |
| コンパイル時間 | 2,014 ms |
| コンパイル使用メモリ | 194,568 KB |
| 最終ジャッジ日時 | 2025-02-13 22:11:53 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 14 |
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:6:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf("%d",&N);
| ~~~~~^~~~~~~~~
main.cpp:8:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | for(auto& v:A){ scanf("%d",&v); }
| ~~~~~^~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:30:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
30 | scanf("%d",&T);
| ~~~~~^~~~~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
void solve(){
int N;
scanf("%d",&N);
vector<int> A(N);
for(auto& v:A){ scanf("%d",&v); }
if(A[0]!=A[N-1]){
printf("Yes\n");
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){
printf("Yes\n");
return;
}
}
int C=count(A.begin(),A.end(),1);
printf(C>=4?"Yes\n":"No\n");
}
int main(){
int T;
scanf("%d",&T);
while(T--){
solve();
}
}