結果
| 問題 |
No.2822 Lights Up! (Tree Edition)
|
| コンテスト | |
| ユーザー |
FplusFplusF
|
| 提出日時 | 2024-06-28 15:51:07 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,492 bytes |
| コンパイル時間 | 3,399 ms |
| コンパイル使用メモリ | 253,312 KB |
| 実行使用メモリ | 817,024 KB |
| 最終ジャッジ日時 | 2024-06-28 15:51:16 |
| 合計ジャッジ時間 | 7,634 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 WA * 2 MLE * 1 -- * 135 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define replr(i,l,r) for (ll i=(ll)(l);i<(ll)(r);i++)
#define all(v) v.begin(),v.end()
#define len(v) ((ll)v.size())
template<class T> inline bool chmin(T &a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T &a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
vector<vector<ll>> g;
vector<ll> now;
void dfs(ll x,ll p){
for(auto i:g[x]){
if(i==p) continue;
dfs(i,x);
if(now[i]==1){
now[i]^=1;
now[x]^=1;
}
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n;
cin >> n;
g.resize(n);
vector<ll> p(n,-1);
replr(i,1,n){
cin >> p[i];
p[i]--;
}
string s(n,'x');
replr(i,1,n) cin >> s[i];
ll q;
cin >> q;
vector<ll> u(q),v(q);
rep(i,q){
cin >> u[i] >> v[i];
u[i]--;
v[i]--;
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
now.assign(n,-1);
replr(i,1,n){
if(s[i]=='.') now[i]=0;
else now[i]=1;
}
rep(i,n){
dfs(i,-1);
if(now[i]==1){
cout << "No\n";
return 0;
}
}
cout << "Yes\n";
}
FplusFplusF