結果
| 問題 |
No.2518 Adjacent Larger
|
| コンテスト | |
| ユーザー |
yumekawayui
|
| 提出日時 | 2023-10-27 23:15:17 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,873 bytes |
| コンパイル時間 | 4,329 ms |
| コンパイル使用メモリ | 191,104 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-25 15:13:21 |
| 合計ジャッジ時間 | 6,642 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 5 WA * 16 RE * 7 |
コンパイルメッセージ
main.cpp:55:23: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
55 | if(pos=0){f=false;}
| ~~~^~
main.cpp:55:23: note: place parentheses around the assignment to silence this warning
55 | if(pos=0){f=false;}
| ^
| ( )
main.cpp:55:23: note: use '==' to turn this assignment into an equality comparison
55 | if(pos=0){f=false;}
| ^
| ==
main.cpp:60:23: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
60 | if(pos=2){f=false;}
| ~~~^~
main.cpp:60:23: note: place parentheses around the assignment to silence this warning
60 | if(pos=2){f=false;}
| ^
| ( )
main.cpp:60:23: note: use '==' to turn this assignment into an equality comparison
60 | if(pos=2){f=false;}
| ^
| ==
2 warnings generated.
ソースコード
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/extc++.h>
using namespace std;
using ld = long double;
const vector<int> dx = {0, 0, 1, -1};
const vector<int> dy = {1, -1, 0, 0};
#define vec vector
#define int long long
#define double long double
//cout<<setprecision(10)<<fixed<<..
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repp(i, x, n) for (int i = x; i < (int)(n); i++)
#define pii pair<int,int>
#define pq priority_queue
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;cin>>t;
rep(i,t){
int n;cin>>n;
deque<int> A;
set<int> S;
rep(i,n){
int a;
cin>>a;S.insert(a);
if(a==1&&i-1>=0&&A[i-1]==1){continue;}
A.push_back(a);
}
if(*S.begin()==1){cout<<"No\n";continue;}
bool f=true;
n=A.size();
if(A[0]==1){
if(A[n-1]==2&&A[1]==2){f=false;}
if(A[n-1]==0&&A[1]==0){f=false;}
}
if(A[0]==0){
if(A[n-1]==0||A[1]==0){f=false;}
}
if(A[0]==2){
if(A[n-1]==2||A[1]==2){f=false;}
}
int pos=A[0];
for(int i=1;i<n;i++){
if(!f){break;}
if(A[i]==1){
if((A[i-1]==0&&A[(i+1)%n]==0)||(A[i-1]==2&&A[(i+1)%n]==2)){
f=false;break;
}
}
if(A[i]==0){
if(pos=0){f=false;}
if(A[i-1]==0||A[(i+1)%n]==0){f=false;break;}
pos=0;
}
if(A[i]==2){
if(pos=2){f=false;}
if(A[i-1]==2||A[(i+1)%n]==2){f=false;break;}
pos=2;
}
}
if(f){
cout<<"Yes\n";
}else{
cout<<"No\n";
}
}
}
yumekawayui