結果
問題 | No.2822 Lights Up! (Tree Edition) |
ユーザー | GOTKAKO |
提出日時 | 2024-07-27 16:08:35 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,632 bytes |
コンパイル時間 | 2,747 ms |
コンパイル使用メモリ | 215,236 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-07-27 16:08:43 |
合計ジャッジ時間 | 7,793 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 58 ms
11,136 KB |
testcase_03 | WA | - |
testcase_04 | AC | 58 ms
11,008 KB |
testcase_05 | AC | 61 ms
11,008 KB |
testcase_06 | AC | 54 ms
10,496 KB |
testcase_07 | AC | 56 ms
10,752 KB |
testcase_08 | AC | 28 ms
6,272 KB |
testcase_09 | AC | 52 ms
10,368 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 3 ms
5,376 KB |
testcase_17 | AC | 3 ms
5,376 KB |
testcase_18 | AC | 6 ms
5,376 KB |
testcase_19 | AC | 4 ms
5,376 KB |
testcase_20 | AC | 4 ms
5,376 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 6 ms
5,376 KB |
testcase_24 | AC | 5 ms
5,376 KB |
testcase_25 | AC | 4 ms
5,376 KB |
testcase_26 | AC | 5 ms
5,376 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 4 ms
5,376 KB |
testcase_32 | AC | 7 ms
5,376 KB |
testcase_33 | AC | 7 ms
5,376 KB |
testcase_34 | WA | - |
testcase_35 | AC | 7 ms
5,376 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | AC | 7 ms
5,376 KB |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | AC | 7 ms
5,376 KB |
testcase_42 | AC | 7 ms
5,376 KB |
testcase_43 | AC | 7 ms
5,376 KB |
testcase_44 | AC | 7 ms
5,376 KB |
testcase_45 | AC | 7 ms
5,376 KB |
testcase_46 | AC | 7 ms
5,376 KB |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | AC | 3 ms
5,376 KB |
testcase_52 | AC | 2 ms
5,376 KB |
testcase_53 | AC | 2 ms
5,376 KB |
testcase_54 | AC | 3 ms
5,376 KB |
testcase_55 | WA | - |
testcase_56 | AC | 2 ms
5,376 KB |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | AC | 3 ms
5,376 KB |
testcase_60 | AC | 2 ms
5,376 KB |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | AC | 3 ms
5,376 KB |
testcase_68 | WA | - |
testcase_69 | AC | 2 ms
5,376 KB |
testcase_70 | WA | - |
testcase_71 | AC | 2 ms
5,376 KB |
testcase_72 | AC | 2 ms
5,376 KB |
testcase_73 | AC | 2 ms
5,376 KB |
testcase_74 | AC | 3 ms
5,376 KB |
testcase_75 | AC | 2 ms
5,376 KB |
testcase_76 | WA | - |
testcase_77 | AC | 3 ms
5,376 KB |
testcase_78 | WA | - |
testcase_79 | AC | 2 ms
5,376 KB |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | WA | - |
testcase_83 | WA | - |
testcase_84 | AC | 2 ms
5,376 KB |
testcase_85 | AC | 2 ms
5,376 KB |
testcase_86 | WA | - |
testcase_87 | WA | - |
testcase_88 | AC | 2 ms
5,376 KB |
testcase_89 | AC | 2 ms
5,376 KB |
testcase_90 | AC | 2 ms
5,376 KB |
testcase_91 | WA | - |
testcase_92 | AC | 3 ms
5,376 KB |
testcase_93 | WA | - |
testcase_94 | AC | 2 ms
5,376 KB |
testcase_95 | AC | 2 ms
5,376 KB |
testcase_96 | AC | 2 ms
5,376 KB |
testcase_97 | WA | - |
testcase_98 | WA | - |
testcase_99 | AC | 2 ms
5,376 KB |
testcase_100 | WA | - |
testcase_101 | AC | 2 ms
5,376 KB |
testcase_102 | AC | 2 ms
5,376 KB |
testcase_103 | AC | 2 ms
5,376 KB |
testcase_104 | AC | 2 ms
5,376 KB |
testcase_105 | AC | 2 ms
5,376 KB |
testcase_106 | WA | - |
testcase_107 | WA | - |
testcase_108 | WA | - |
testcase_109 | WA | - |
testcase_110 | WA | - |
testcase_111 | WA | - |
testcase_112 | AC | 2 ms
5,376 KB |
testcase_113 | WA | - |
testcase_114 | WA | - |
testcase_115 | WA | - |
testcase_116 | WA | - |
testcase_117 | AC | 2 ms
5,376 KB |
testcase_118 | AC | 2 ms
5,376 KB |
testcase_119 | WA | - |
testcase_120 | WA | - |
testcase_121 | WA | - |
testcase_122 | WA | - |
testcase_123 | AC | 2 ms
5,376 KB |
testcase_124 | WA | - |
testcase_125 | WA | - |
testcase_126 | AC | 2 ms
5,376 KB |
testcase_127 | WA | - |
testcase_128 | AC | 2 ms
5,376 KB |
testcase_129 | WA | - |
testcase_130 | WA | - |
testcase_131 | AC | 2 ms
5,376 KB |
testcase_132 | WA | - |
testcase_133 | AC | 3 ms
5,376 KB |
testcase_134 | AC | 3 ms
5,376 KB |
testcase_135 | WA | - |
testcase_136 | AC | 2 ms
5,376 KB |
testcase_137 | WA | - |
testcase_138 | AC | 2 ms
5,376 KB |
testcase_139 | AC | 2 ms
5,376 KB |
testcase_140 | AC | 2 ms
5,376 KB |
testcase_141 | AC | 2 ms
5,376 KB |
testcase_142 | AC | 2 ms
5,376 KB |
testcase_143 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<int> P(N-1); for(auto &p : P) cin >> p,p--; string s; cin >> s; s.insert(s.begin(),'.'); vector<vector<int>> Graph(N); for(int i=0; i<N-1; i++){ Graph.at(P.at(i)).push_back(i+1); Graph.at(i+1).push_back(P.at(i)); } vector<int> diff(N); auto dfs = [&](auto dfs,int pos,int back) -> int { bool leaf = true; int ret = 0; for(auto to : Graph.at(pos)){ if(to == back) continue; leaf = false; int ko = dfs(dfs,to,pos); if(s.at(pos) != s.at(to)) diff.at(pos) += ko; ret += ko; } if(leaf && s.at(pos) == '#') diff.at(pos)++,ret = 1; return ret; }; dfs(dfs,0,-1); for(auto &d : diff) d &= 1; Graph.assign(N,{}); int K; cin >> K; while(K--){ int u,v; cin >> u >> v; u--; v--; Graph.at(u).push_back(v); Graph.at(v).push_back(u); } vector<bool> already(N); bool yes = true; for(int i=0; i<N; i++) if(already.at(i) == false){ already.at(i) = true; queue<int> Q; Q.push(i); int sumd = 0; while(Q.size()){ int pos = Q.front(); Q.pop(); sumd += diff.at(pos); for(auto to : Graph.at(pos)) if(already.at(to) == false){ already.at(to) = true; Q.push(to); } } if(sumd%2) yes = false; } if(yes) cout << "Yes" << endl; else cout << "No" << endl; }