結果

問題 No.1424 Ultrapalindrome
ユーザー GRMNGRMN
提出日時 2021-05-02 21:40:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,672 bytes
コンパイル時間 4,688 ms
コンパイル使用メモリ 269,664 KB
実行使用メモリ 10,236 KB
最終ジャッジ日時 2024-07-21 07:00:09
合計ジャッジ時間 6,960 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 3 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 78 ms
8,192 KB
testcase_10 AC 77 ms
8,320 KB
testcase_11 AC 53 ms
6,912 KB
testcase_12 AC 71 ms
7,936 KB
testcase_13 AC 18 ms
5,376 KB
testcase_14 AC 56 ms
7,168 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 42 ms
6,272 KB
testcase_17 AC 52 ms
7,040 KB
testcase_18 AC 33 ms
5,888 KB
testcase_19 AC 52 ms
6,912 KB
testcase_20 AC 13 ms
5,376 KB
testcase_21 AC 40 ms
6,144 KB
testcase_22 AC 25 ms
5,376 KB
testcase_23 AC 7 ms
5,376 KB
testcase_24 AC 11 ms
5,376 KB
testcase_25 AC 10 ms
5,376 KB
testcase_26 AC 65 ms
7,680 KB
testcase_27 WA -
testcase_28 AC 69 ms
8,832 KB
testcase_29 AC 71 ms
9,600 KB
testcase_30 AC 58 ms
10,236 KB
testcase_31 AC 70 ms
10,228 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/allocator.h:46,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/string:41,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/locale_classes.h:40,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/ios_base.h:41,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ios:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:38,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54,
                 from main.cpp:1:
In member function 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = int; _Args = {const int&}; _Tp = int]',
    inlined from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = int; _Args = {const int&}; _Tp = int]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/alloc_traits.h:516:17,
    inlined from 'void std::deque<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_deque.h:1543:30,
    inlined from 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define all(v) begin(v),end(v)
#define rall(v) rbegin(v),rend(v)
#define fi first
#define se second
#define re0 return 0
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
constexpr ll inf = 2e9;
constexpr ll llinf = 9e18;
//constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;
const double pai=acos(-1);

int main() {
    //cout<<fixed<<setprecision(15);
    int n;cin>>n;
    vector<vector<int>> g(n);
    rep(i,n-1){
        int a,b;cin>>a>>b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int tmp=0,id;
    rep(i,n){
        int a=g[i].size();
        if(a>tmp){
            tmp=a;
            id=i;
        }
    }
    if(tmp==1||tmp==2){
        cout<<"Yes"<<endl;
        re0;
    }
    //cout<<id<<endl;
    vector<int> vec(n);
    vector<int> d(n,-1);
    queue<int> que;
    d[id]=0;
    que.push(id);
    while(!que.empty()){
        int v=que.front();que.pop();
        for(auto u:g[v]){
            if(d[u]!=-1)continue;
            d[u]=d[v]+1;
            que.push(u);
            if(g[u].size()==1)vec[u]=1;
        }
    }
    //rep(i,n)cout<<d[i]<<endl;
    set<int> st;
    rep(i,n){
        if(vec[i])st.insert(d[i]);
    }
    if(st.size()==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
0