結果
問題 | No.1424 Ultrapalindrome |
ユーザー | GRMN |
提出日時 | 2021-05-02 21:57:40 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,827 bytes |
コンパイル時間 | 5,482 ms |
コンパイル使用メモリ | 271,268 KB |
実行使用メモリ | 10,872 KB |
最終ジャッジ日時 | 2024-07-21 07:16:48 |
合計ジャッジ時間 | 8,065 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
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 | 1 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | AC | 59 ms
8,448 KB |
testcase_10 | AC | 58 ms
8,448 KB |
testcase_11 | AC | 41 ms
6,912 KB |
testcase_12 | AC | 54 ms
8,192 KB |
testcase_13 | AC | 15 ms
5,376 KB |
testcase_14 | AC | 45 ms
7,296 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 35 ms
6,400 KB |
testcase_17 | AC | 43 ms
7,040 KB |
testcase_18 | AC | 29 ms
5,888 KB |
testcase_19 | AC | 41 ms
7,168 KB |
testcase_20 | AC | 11 ms
5,376 KB |
testcase_21 | AC | 32 ms
6,400 KB |
testcase_22 | AC | 23 ms
5,376 KB |
testcase_23 | WA | - |
testcase_24 | AC | 10 ms
5,376 KB |
testcase_25 | AC | 9 ms
5,376 KB |
testcase_26 | AC | 49 ms
7,808 KB |
testcase_27 | AC | 69 ms
10,240 KB |
testcase_28 | AC | 62 ms
8,704 KB |
testcase_29 | AC | 63 ms
9,856 KB |
testcase_30 | WA | - |
testcase_31 | AC | 60 ms
10,620 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/
ソースコード
#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),vec1(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,vec1[v]++; } } //rep(i,n)cout<<d[i]<<endl; set<int> st; rep(i,n){ if(vec[i])st.insert(d[i]); } bool ok=true; if(st.size()!=1)ok=false; rep(i,n){ for(auto u:g[i]){ if(vec[i]&&vec1[u]>1)ok=false; } } if(ok)cout<<"Yes"<<endl; else cout<<"No"<<endl; }