結果
問題 | No.2822 Lights Up! (Tree Edition) |
ユーザー | Magentor |
提出日時 | 2024-07-26 22:18:37 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,387 bytes |
コンパイル時間 | 5,190 ms |
コンパイル使用メモリ | 317,020 KB |
実行使用メモリ | 11,904 KB |
最終ジャッジ日時 | 2024-07-26 22:19:07 |
合計ジャッジ時間 | 25,854 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | AC | 12 ms
6,940 KB |
testcase_43 | RE | - |
testcase_44 | RE | - |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | RE | - |
testcase_48 | RE | - |
testcase_49 | RE | - |
testcase_50 | RE | - |
testcase_51 | RE | - |
testcase_52 | RE | - |
testcase_53 | RE | - |
testcase_54 | RE | - |
testcase_55 | RE | - |
testcase_56 | RE | - |
testcase_57 | RE | - |
testcase_58 | RE | - |
testcase_59 | RE | - |
testcase_60 | RE | - |
testcase_61 | RE | - |
testcase_62 | RE | - |
testcase_63 | RE | - |
testcase_64 | RE | - |
testcase_65 | RE | - |
testcase_66 | RE | - |
testcase_67 | RE | - |
testcase_68 | RE | - |
testcase_69 | RE | - |
testcase_70 | RE | - |
testcase_71 | AC | 3 ms
6,944 KB |
testcase_72 | RE | - |
testcase_73 | RE | - |
testcase_74 | RE | - |
testcase_75 | RE | - |
testcase_76 | RE | - |
testcase_77 | RE | - |
testcase_78 | RE | - |
testcase_79 | RE | - |
testcase_80 | RE | - |
testcase_81 | RE | - |
testcase_82 | RE | - |
testcase_83 | RE | - |
testcase_84 | RE | - |
testcase_85 | RE | - |
testcase_86 | RE | - |
testcase_87 | RE | - |
testcase_88 | AC | 2 ms
6,940 KB |
testcase_89 | RE | - |
testcase_90 | RE | - |
testcase_91 | RE | - |
testcase_92 | RE | - |
testcase_93 | RE | - |
testcase_94 | RE | - |
testcase_95 | RE | - |
testcase_96 | RE | - |
testcase_97 | RE | - |
testcase_98 | RE | - |
testcase_99 | AC | 2 ms
6,940 KB |
testcase_100 | RE | - |
testcase_101 | RE | - |
testcase_102 | RE | - |
testcase_103 | AC | 2 ms
6,940 KB |
testcase_104 | RE | - |
testcase_105 | RE | - |
testcase_106 | RE | - |
testcase_107 | RE | - |
testcase_108 | RE | - |
testcase_109 | RE | - |
testcase_110 | RE | - |
testcase_111 | RE | - |
testcase_112 | RE | - |
testcase_113 | RE | - |
testcase_114 | RE | - |
testcase_115 | RE | - |
testcase_116 | RE | - |
testcase_117 | RE | - |
testcase_118 | AC | 2 ms
6,944 KB |
testcase_119 | RE | - |
testcase_120 | RE | - |
testcase_121 | RE | - |
testcase_122 | RE | - |
testcase_123 | RE | - |
testcase_124 | RE | - |
testcase_125 | RE | - |
testcase_126 | RE | - |
testcase_127 | RE | - |
testcase_128 | RE | - |
testcase_129 | RE | - |
testcase_130 | RE | - |
testcase_131 | AC | 2 ms
6,940 KB |
testcase_132 | RE | - |
testcase_133 | RE | - |
testcase_134 | RE | - |
testcase_135 | RE | - |
testcase_136 | RE | - |
testcase_137 | RE | - |
testcase_138 | RE | - |
testcase_139 | RE | - |
testcase_140 | RE | - |
testcase_141 | RE | - |
testcase_142 | RE | - |
testcase_143 | AC | 2 ms
6,944 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){cout<<"No"<<endl;assert(false);return 0;} } cout<<"Yes"<<endl; }