結果
| 問題 |
No.2343 (l+r)/2
|
| コンテスト | |
| ユーザー |
FplusFplusF
|
| 提出日時 | 2023-06-09 22:09:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,264 bytes |
| コンパイル時間 | 1,811 ms |
| コンパイル使用メモリ | 202,520 KB |
| 最終ジャッジ日時 | 2025-02-13 23:57:04 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 WA * 7 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
template<class T> void chmin(T &a,T b){
if(a>b){
a=b;
}
}
template<class T> void chmax(T &a,T b){
if(a<b){
a=b;
}
}
bool f(ll n,vector<ll> &a){
a.push_back(INF);
vector<ll> v;
ll cnt=1;
rep(i,n){
if(a[i]!=a[i+1]){
v.push_back(cnt);
cnt=1;
}else{
cnt++;
}
}
ll m=v.size();
if(m==1) return false;
vector<vector<bool>> dp(m,vector<bool>(2,false));
dp[0][0]=true;
rep(i,m-1){
if(dp[i][0]){
dp[i+1][1]=true;
}
if(dp[i][1]){
dp[i+1][0]=true;
if(2<=v[i]) dp[i+1][1]=true;
}
}
return dp[m-1][1];
}
void solve(){
ll n;
cin >> n;
vector<ll> a(n);
rep(i,n) cin >> a[i];
vector<ll> ra=a;
reverse(all(ra));
if(f(n,a)||f(n,ra)) cout << "Yes\n";
else cout << "No\n";
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll t;
cin >> t;
while(t--){
solve();
}
}
FplusFplusF