結果

問題 No.3220 Forest Creation
ユーザー GOTKAKO
提出日時 2025-08-01 22:51:11
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 718 bytes
コンパイル時間 1,440 ms
コンパイル使用メモリ 196,136 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-02 00:02:09
合計ジャッジ時間 2,823 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 45 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    vector<int> A(N+1);
    for(auto &a : A) cin >> a;

    long long sum = 0;
    for(int i=1; i<=N; i++) sum += 1LL*A.at(i)*i;

    long long deg = 0;
    for(int i=2; i<=N; i++) if(A.at(i)){
        if(deg == 0) deg = i,A.at(i)--;
        deg += 1LL*A.at(i)*(i-2);
    }
    int a0 = A.at(1);
    if(deg == 0){
        if(a0%2 == 0 || a0 > N) cout << "Yes\n";
        else cout << "No\n";
    }
    else{
        if(sum%2){cout << "No\n"; return 0;}
        a0 -= deg-1; a0++;
        if(a0 > 0 && (a0%2 == 0 || a0 > N)) cout << "Yes\n";
        else cout << "No\n";
    }
}
0