結果
問題 | No.2822 Lights Up! (Tree Edition) |
ユーザー | Magentor |
提出日時 | 2024-07-26 22:20:13 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,395 bytes |
コンパイル時間 | 5,573 ms |
コンパイル使用メモリ | 318,184 KB |
実行使用メモリ | 11,648 KB |
最終ジャッジ日時 | 2024-07-26 22:20:29 |
合計ジャッジ時間 | 10,537 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 107 ms
11,520 KB |
testcase_03 | WA | - |
testcase_04 | AC | 109 ms
11,648 KB |
testcase_05 | AC | 111 ms
11,520 KB |
testcase_06 | AC | 109 ms
11,648 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 99 ms
11,008 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 75 ms
6,528 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 5 ms
5,376 KB |
testcase_18 | WA | - |
testcase_19 | AC | 5 ms
5,376 KB |
testcase_20 | AC | 6 ms
5,376 KB |
testcase_21 | WA | - |
testcase_22 | AC | 8 ms
5,376 KB |
testcase_23 | AC | 8 ms
5,376 KB |
testcase_24 | AC | 6 ms
5,376 KB |
testcase_25 | WA | - |
testcase_26 | AC | 8 ms
5,376 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 5 ms
5,376 KB |
testcase_32 | AC | 11 ms
5,376 KB |
testcase_33 | AC | 11 ms
5,376 KB |
testcase_34 | WA | - |
testcase_35 | AC | 11 ms
5,376 KB |
testcase_36 | WA | - |
testcase_37 | AC | 11 ms
5,376 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | AC | 11 ms
5,376 KB |
testcase_42 | AC | 12 ms
5,376 KB |
testcase_43 | AC | 11 ms
5,376 KB |
testcase_44 | AC | 11 ms
5,376 KB |
testcase_45 | AC | 11 ms
5,376 KB |
testcase_46 | AC | 10 ms
5,376 KB |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | AC | 2 ms
5,376 KB |
testcase_52 | AC | 2 ms
5,376 KB |
testcase_53 | WA | - |
testcase_54 | AC | 2 ms
5,376 KB |
testcase_55 | WA | - |
testcase_56 | AC | 3 ms
5,376 KB |
testcase_57 | AC | 3 ms
5,376 KB |
testcase_58 | AC | 3 ms
5,376 KB |
testcase_59 | AC | 3 ms
5,376 KB |
testcase_60 | AC | 2 ms
5,376 KB |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | AC | 2 ms
5,376 KB |
testcase_64 | AC | 3 ms
5,376 KB |
testcase_65 | AC | 2 ms
5,376 KB |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | AC | 3 ms
5,376 KB |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | AC | 1 ms
5,376 KB |
testcase_75 | AC | 3 ms
5,376 KB |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | AC | 2 ms
5,376 KB |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | AC | 2 ms
5,376 KB |
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 | 1 ms
5,376 KB |
testcase_90 | WA | - |
testcase_91 | WA | - |
testcase_92 | AC | 2 ms
5,376 KB |
testcase_93 | WA | - |
testcase_94 | WA | - |
testcase_95 | AC | 2 ms
5,376 KB |
testcase_96 | AC | 2 ms
5,376 KB |
testcase_97 | AC | 2 ms
5,376 KB |
testcase_98 | WA | - |
testcase_99 | AC | 2 ms
5,376 KB |
testcase_100 | WA | - |
testcase_101 | WA | - |
testcase_102 | WA | - |
testcase_103 | AC | 2 ms
5,376 KB |
testcase_104 | AC | 2 ms
5,376 KB |
testcase_105 | WA | - |
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 | AC | 2 ms
5,376 KB |
testcase_114 | WA | - |
testcase_115 | WA | - |
testcase_116 | AC | 2 ms
5,376 KB |
testcase_117 | WA | - |
testcase_118 | AC | 2 ms
5,376 KB |
testcase_119 | AC | 2 ms
5,376 KB |
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 | 2 ms
5,376 KB |
testcase_134 | AC | 2 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 | 3 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;#include <atcoder/all>using namespace atcoder;template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)#define rep2(i, m ,n) for (int i = (m); i < (long long)(n); i++)#define REP(i, n) for (long long i = 1; i < (long long)(n); i++)typedef long long ll;#define updiv(N,X) (N + X - 1) / X#define l(n) n.begin(),n.end()#define YesNo(Q) Q==1?cout<<"Yes":cout<<"No"using P = pair<int, int>;using mint = modint;const int MOD = 998244353LL;const ll INF = 999999999999LL;vector<long long> fact, fact_inv, inv;/* init_nCk :二項係数のための前処理計算量:O(n)*/template <typename T>void input(vector<T> &v){rep(i,v.size()){cin>>v[i];}return;}void init_nCk(int SIZE) {fact.resize(SIZE + 5);fact_inv.resize(SIZE + 5);inv.resize(SIZE + 5);fact[0] = fact[1] = 1;fact_inv[0] = fact_inv[1] = 1;inv[1] = 1;for (int i = 2; i < SIZE + 5; i++) {fact[i] = fact[i - 1] * i % MOD;inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;}}/* nCk :MODでの二項係数を求める(前処理 int_nCk が必要)計算量:O(1)*/long long nCk(int n, int k) {assert(!(n < k));assert(!(n < 0 || k < 0));return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;}long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}ll POW(ll a,ll n){long long res = 1;while (n > 0) {if (n & 1) res = res * a;a = a * a;n >>= 1;}return res;}int main() {int n;cin>>n;vector<ll> v(n,-1);rep(i,n-1){cin>>v[i+1];v[i+1]--;}string s;cin>>s;vector<ll> sm(n);for(int i = n-1;0<i;i--){sm[v[i]] += sm[i];if(s[i-1]=='#'){sm[i]++;sm[v[i]]++;}}dsu d(n);//rep(i,n){cout<<sm[i]<<" ";}int m;cin>>m;rep(i,m){ll a,b;cin>>a>>b;a--;b--;d.merge(a,b);}map<ll,ll> mp;rep(i,n){mp[d.leader(i)] += sm[i];}for(auto u : mp){if(u.second%2==1&&(!d.same(u.first,0))){cout<<"No"<<endl;return 0;}}cout<<"Yes"<<endl;}