結果
問題 | No.1424 Ultrapalindrome |
ユーザー | GRMN |
提出日時 | 2021-05-02 21:57:40 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,827 bytes |
コンパイル時間 | 4,364 ms |
コンパイル使用メモリ | 268,732 KB |
実行使用メモリ | 10,468 KB |
最終ジャッジ日時 | 2023-09-28 12:38:50 |
合計ジャッジ時間 | 7,001 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,384 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 1 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 71 ms
8,316 KB |
testcase_10 | AC | 71 ms
8,324 KB |
testcase_11 | AC | 50 ms
6,796 KB |
testcase_12 | AC | 68 ms
8,124 KB |
testcase_13 | AC | 17 ms
4,380 KB |
testcase_14 | AC | 54 ms
7,092 KB |
testcase_15 | AC | 2 ms
4,380 KB |
testcase_16 | AC | 40 ms
6,288 KB |
testcase_17 | AC | 51 ms
7,048 KB |
testcase_18 | AC | 32 ms
5,728 KB |
testcase_19 | AC | 49 ms
7,076 KB |
testcase_20 | AC | 11 ms
4,376 KB |
testcase_21 | AC | 40 ms
6,276 KB |
testcase_22 | AC | 24 ms
4,940 KB |
testcase_23 | WA | - |
testcase_24 | AC | 10 ms
4,376 KB |
testcase_25 | AC | 10 ms
4,376 KB |
testcase_26 | AC | 60 ms
7,592 KB |
testcase_27 | AC | 87 ms
10,280 KB |
testcase_28 | AC | 66 ms
8,584 KB |
testcase_29 | AC | 69 ms
9,660 KB |
testcase_30 | WA | - |
testcase_31 | AC | 65 ms
10,468 KB |
コンパイルメッセージ
次のファイルから読み込み: /usr/local/gcc7/include/c++/12.2.0/x86_64-pc-linux-gnu/bits/c++allocator.h:33, 次から読み込み: /usr/local/gcc7/include/c++/12.2.0/bits/allocator.h:46, 次から読み込み: /usr/local/gcc7/include/c++/12.2.0/string:41, 次から読み込み: /usr/local/gcc7/include/c++/12.2.0/bits/locale_classes.h:40, 次から読み込み: /usr/local/gcc7/include/c++/12.2.0/bits/ios_base.h:41, 次から読み込み: /usr/local/gcc7/include/c++/12.2.0/ios:42, 次から読み込み: /usr/local/gcc7/include/c++/12.2.0/istream:38, 次から読み込み: /usr/local/gcc7/include/c++/12.2.0/sstream:38, 次から読み込み: /usr/local/gcc7/include/c++/12.2.0/complex:45, 次から読み込み: /usr/local/gcc7/include/c++/12.2.0/ccomplex:39, 次から読み込み: /usr/local/gcc7/include/c++/12.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:54, 次から読み込み: main.cpp:1: メンバ関数 ‘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 /usr/local/gcc7/include/c++/12.2.0/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 /usr/local/gcc7/include/c++/12.2.0/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 /usr/local/gcc7/include/c++/12.2.0/bits/stl_queue.h:286:20, inlined from ‘int main()’ at main.cpp:50:13: /usr/local/gcc7/include/c++/12.2.0/bits/new_allocator.h:175:11: 警告: ‘id’ may be used uninitialized [-Wmaybe-uninitialized] 175 |
ソースコード
#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; }