結果

問題 No.1424 Ultrapalindrome
ユーザー ぷらぷら
提出日時 2021-03-12 22:31:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 582 bytes
コンパイル時間 1,864 ms
コンパイル使用メモリ 169,716 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-22 13:34:55
合計ジャッジ時間 3,980 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 56 ms
5,376 KB
testcase_10 AC 57 ms
5,376 KB
testcase_11 AC 40 ms
5,376 KB
testcase_12 AC 54 ms
5,376 KB
testcase_13 AC 16 ms
5,376 KB
testcase_14 AC 44 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 34 ms
5,376 KB
testcase_17 AC 41 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 5 ms
5,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 75 ms
6,400 KB
testcase_28 AC 59 ms
5,376 KB
testcase_29 AC 59 ms
5,376 KB
testcase_30 AC 48 ms
5,376 KB
testcase_31 AC 61 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int N;
    cin >> N;
    vector<int>cnt(N),tmp(N);
    for(int i = 0; i < N-1; i++) {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        cnt[a]++;
        cnt[b]++;
        tmp[a] = b;
        tmp[b] = a;
    }
    int cnt2 = 0;
    set<int>st;
    for(int i = 0; i < N; i++) {
        if(cnt[i] == 1) {
            cnt2++;
            st.insert(tmp[i]);
        }
    }
    if(cnt2 == 2 || st.size() == 1) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
0