結果

問題 No.2343 (l+r)/2
ユーザー FplusFplusFFplusFplusF
提出日時 2023-06-09 22:09:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,264 bytes
コンパイル時間 2,300 ms
コンパイル使用メモリ 208,116 KB
実行使用メモリ 7,784 KB
最終ジャッジ日時 2023-08-30 13:22:47
合計ジャッジ時間 3,439 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 67 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 14 ms
7,784 KB
testcase_05 AC 6 ms
4,744 KB
testcase_06 AC 6 ms
4,452 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 11 ms
5,584 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 13 ms
6,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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();
    }
}
0